Skip to content

Commit

Permalink
Merge branch 'master' of github.com:HashNuke/hound
Browse files Browse the repository at this point in the history
  • Loading branch information
HashNuke committed Nov 15, 2015
2 parents a576f94 + 816eeee commit c4abc23
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,20 @@ Hound requires Elixir 1.0.2 or higher.

* Add dependency to your mix project

```elixir
# If you are using hex
{ :hound, "~> 0.7.4" }

# If you are not using hex
{ :hound, github: "HashNuke/hound", tag: "v0.7.4" }
```
```elixir
# If you are using hex
{ :hound, "~> 0.7.4" }

* Add Hound to the list of applications to start in your `mix.exs`. Recommended to start Hound in test environment only.
# If you are not using hex
{ :hound, github: "HashNuke/hound", tag: "v0.7.4" }
```

```elixir
def application do
[ applications: app_list(Mix.env) ]
end
* Start Hound in your `test/test_helper.exs` file **before** the `ExUnit.start()` line:

defp app_list(:test), do: [:hound | app_list]
defp app_list(_), do: app_list
```
```elixir
Application.ensure_all_started(:hound)
ExUnit.start()
```

When you run `mix tests`, Hound is automatically started. __You'll need a webdriver server__ running, like Selenium Server or Chrome Driver. If you aren't sure what it is, then [read this](https://github.com/HashNuke/hound/wiki/Starting-a-webdriver-server).

Expand Down
14 changes: 0 additions & 14 deletions lib/hound/connection_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,8 @@ defmodule Hound.ConnectionServer do
:gen_server.start_link({:local, __MODULE__}, __MODULE__, state, [])
end

defp start_browser("phantomjs") do
case System.cmd("pgrep", ["phantomjs"]) do
{"", _} ->
port = Port.open({:spawn, "phantomjs --webdriver=8910"}, [])
{:os_pid, os_pid} = Port.info(port, :os_pid)

System.at_exit(fn _exit_status ->
System.cmd("kill", [to_string(os_pid)])
end)
_ -> nil
end
end
defp start_browser(_), do: nil

def init(state) do
start_browser(state[:driver_info][:driver])
{:ok, state}
end

Expand Down
4 changes: 4 additions & 0 deletions lib/hound/helpers/navigation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ defmodule Hound.Helpers.Navigation do
make_req(:get, "session/#{session_id}/url")
end

@doc "Gets the path of the current page."
def current_path do
URI.parse(current_url).path
end

@doc """
Navigates to a url or relative path.
Expand Down
5 changes: 5 additions & 0 deletions test/helpers/navigation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ defmodule NavigationTest do
assert url == current_url
end

test "should get current path" do
url = "http://localhost:9090/page1.html"
navigate_to(url)
assert current_path == "/page1.html"
end

test "should navigate to a url" do
url = "http://localhost:9090/page1.html"
Expand Down

0 comments on commit c4abc23

Please sign in to comment.