Skip to content

Commit

Permalink
Update tests to use capybara methods instead of regex
Browse files Browse the repository at this point in the history
This way, we're getting text as the user would see it.
See: teamcapybara/capybara#1341
  • Loading branch information
carols10cents committed Oct 8, 2014
1 parent 6e28b6a commit 10b719d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
24 changes: 18 additions & 6 deletions test/acceptance/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
it "allows access to search" do
search_for("droids")

assert_match @update_text, page.body
within '#search' do
assert has_text? @update_text
end
end
end

Expand All @@ -47,7 +49,9 @@
it "allows access to search" do
search_for("droids")

assert_match @update_text, page.body
within '#search' do
assert has_text? @update_text
end
end

it "returns updates on blank search" do
Expand All @@ -71,25 +75,33 @@
it "gets a match for a word in the update" do
search_for("droids")

assert_match @update_text, page.body
within '#search' do
assert has_text? @update_text
end
end

it "doesn't get a match for a substring ending a word in the update" do
search_for("roids")

assert_match "No statuses match your search.", page.body
within '#content' do
assert has_text? "No statuses match your search."
end
end

it "doesn't get a match for a substring starting a word in the update" do
search_for("loo")

assert_match "No statuses match your search.", page.body
within '#content' do
assert has_text? "No statuses match your search."
end
end

it "gets a case-insensitive match for a word in the update" do
search_for("DROIDS")

assert_match @update_text, page.body
within '#search' do
assert has_text? @update_text
end
end

it "gets a match for hashtag search" do
Expand Down
4 changes: 3 additions & 1 deletion test/enhancements/elasticsearch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
it "gets a match for words in the update out of order" do
search_for("for looking")

assert_match @update_text, page.body
within '#search' do
assert has_text? @update_text
end
end
end

0 comments on commit 10b719d

Please sign in to comment.