Skip to content

Commit 60935eb

Browse files
committed
Add hound and some browser tests
1 parent 213dadb commit 60935eb

10 files changed

+61
-10
lines changed

config/test.exs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Mix.Config
44
# you can enable the server option below.
55
config :elixir_friends, ElixirFriends.Endpoint,
66
http: [port: 4001],
7-
server: false
7+
server: true
88

99
# Print only warnings and errors during test
1010
config :logger, level: :warn
@@ -17,3 +17,6 @@ config :elixir_friends, ElixirFriends.Repo,
1717
password: System.get_env("DATABASE_POSTGRESQL_PASSWORD") || "postgres",
1818
database: "elixir_friends_test",
1919
pool_size: 1 # Use a single connection for transactional tests
20+
21+
# Configure hound for integration tests
22+
config :hound, driver: "chrome_driver"

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ defmodule ElixirFriends.Mixfile do
4848
{:extwitter, "~> 0.5.1"},
4949
{:oauth, github: "tim/erlang-oauth"},
5050
{:scrivener, "~> 0.12.0"},
51-
{:honeybadger, "~> 0.3"}
51+
{:honeybadger, "~> 0.3"},
52+
{:hound, "~> 0.7.4"}
5253
]
5354
end
5455
end

mix.lock

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
%{"combine": {:hex, :combine, "0.5.3"},
2-
"cowboy": {:hex, :cowboy, "1.0.3"},
3-
"cowlib": {:hex, :cowlib, "1.0.1"},
1+
%{"certifi": {:hex, :certifi, "0.1.1"},
2+
"combine": {:hex, :combine, "0.5.3"},
3+
"cowboy": {:hex, :cowboy, "1.0.4"},
4+
"cowlib": {:hex, :cowlib, "1.0.2"},
45
"decimal": {:hex, :decimal, "1.1.0"},
56
"ecto": {:hex, :ecto, "0.15.0"},
6-
"extwitter": {:hex, :extwitter, "0.5.1"},
7+
"extwitter": {:hex, :extwitter, "0.5.4"},
78
"fs": {:hex, :fs, "0.9.2"},
8-
"hackney": {:hex, :hackney, "1.3.2"},
9+
"hackney": {:hex, :hackney, "1.4.4"},
910
"honeybadger": {:hex, :honeybadger, "0.3.0"},
10-
"httpoison": {:hex, :httpoison, "0.7.4"},
11+
"hound": {:hex, :hound, "0.7.6"},
12+
"httpoison": {:hex, :httpoison, "0.8.0"},
1113
"idna": {:hex, :idna, "1.0.2"},
14+
"mimerl": {:hex, :mimerl, "1.0.0"},
1215
"oauth": {:git, "https://github.com/tim/erlang-oauth.git", "cd31addc828179983564fd57738f1680a4a4d1ff", []},
1316
"phoenix": {:hex, :phoenix, "1.0.3"},
1417
"phoenix_ecto": {:hex, :phoenix_ecto, "1.0.0"},
@@ -18,8 +21,8 @@
1821
"poison": {:hex, :poison, "1.5.0"},
1922
"poolboy": {:hex, :poolboy, "1.5.1"},
2023
"postgrex": {:hex, :postgrex, "0.9.1"},
21-
"ranch": {:hex, :ranch, "1.1.0"},
24+
"ranch": {:hex, :ranch, "1.2.0"},
2225
"scrivener": {:hex, :scrivener, "0.12.0"},
2326
"ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"},
2427
"timex": {:hex, :timex, "0.19.5"},
25-
"tzdata": {:hex, :tzdata, "0.5.4"}}
28+
"tzdata": {:hex, :tzdata, "0.5.5"}}
Loading

priv/static/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"robots.txt":"robots-067185ba27a5d9139b10a759679045bf.txt","images/phoenix.png":"images/phoenix-5bd99a0d17dd41bc9d9bf6840abcc089.png"}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2+
#
3+
# To ban all spiders from the entire site uncomment the next two lines:
4+
# User-agent: *
5+
# Disallow: /
Binary file not shown.

priv/static/robots.txt.gz

164 Bytes
Binary file not shown.

test/integration/posts_test.exs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
defmodule Integration.PostsTest do
2+
use ExUnit.Case
3+
use Hound.Helpers
4+
alias ElixirFriends.Post
5+
alias ElixirFriends.ImageTweetStreamer
6+
hound_session
7+
8+
@post %Post{
9+
image_url: "http://elixirsips.com/images/194_Interoperability_Ports_Screenshot.png",
10+
content: "Fake content",
11+
source_url: "http://elixirsips.com",
12+
username: "knewter"
13+
}
14+
15+
test "loading the home page" do
16+
navigate_to "http://localhost:4001/"
17+
assert page_source =~ "ElixirFriends"
18+
end
19+
20+
test "seeing posts on the home page" do
21+
ImageTweetStreamer.store_post(@post)
22+
navigate_to "http://localhost:4001/"
23+
assert page_source =~ @post.content
24+
end
25+
26+
test "new posts are injected onto the page" do
27+
navigate_to "http://localhost:4001/"
28+
this_post = %Post{ @post | content: "this post"}
29+
ImageTweetStreamer.store_post(this_post)
30+
assert page_source =~ this_post.content
31+
end
32+
end

test/test_helper.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ ExUnit.start
44
Mix.Task.run "ecto.create", ["--quiet"]
55
Mix.Task.run "ecto.migrate", ["--quiet"]
66
Ecto.Adapters.SQL.begin_test_transaction(ElixirFriends.Repo)
7+
8+
# Start hound for integration tests...
9+
Application.ensure_all_started(:hound)
10+
11+
# Start chromedriver
12+
#Port.open("chromedriver", []) # Can't do this until we can make sure this executable closes when the port dies - look into spawnkillable

0 commit comments

Comments
 (0)