Created
April 30, 2014 06:13
-
-
Save afshinator/a169a15fb203743ed9a8 to your computer and use it in GitHub Desktop.
search_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
# require 'database_cleaner' | |
require 'capybara-webkit' | |
feature "Search" do | |
# before { visit about_path } | |
describe "Home page" do | |
it "should not have a searchbox" do | |
visit root_path | |
expect(page).to_not have_css('#st-search-input') | |
end | |
end | |
# Static pages should have a search-box | |
describe "Static pages" do | |
it "About should have a searchbox" do | |
visit about_path | |
expect(page).to have_css('#st-search-input') | |
end | |
it "Studygroups should have a searchbox" do | |
visit studygroups_path | |
expect(page).to have_css('#st-search-input') | |
end | |
end | |
# Non-static pages should have a search-box | |
describe "Curriculum pages" do | |
before { visit curriculum_path } | |
it "brings up results modal with valid input", :js => true do | |
fill_in 'st-search-input', :with => 'controller' | |
# expect(page).to have_css('#st-results-modal') | |
# page.should have_css('#st-results-modal') | |
# page.should has_css('#st-results-modal') | |
page.has_css?('#st-results-modal') | |
end | |
it "doesn't bring up results modal with empty input", :js => true do | |
fill_in 'st-search-input', :with => "\n" | |
page.has_no_css?('#st-results-modal') | |
# page.has_css?('#st-results-modal').not_to be_true | |
# expect(page).not_to have_css('#st-results-modal') # <-- works just as well | |
end | |
it "has the search term in the results", :js => true do | |
fill_in 'st-search-input', :with => "SQL\n" | |
within('.st-search-summary') { expect(page).to have_content('SQL' && "1") } | |
#page.has_css?('.st-result-text', text: 'SQL') # <---FP passes | |
#page.find('.st-result-text').have_content('SQL') | |
#page.has_css?('.st-query', text: 'SQL') # <--FP passes | |
#expect(find("#st-query")).to have_text('SQL') | |
end | |
it "finds the one instance of Sandi in the content", :js => true do | |
fill_in 'st-search-input', :with => "sandi\n" | |
within('.st-search-summary') { expect(page).to have_content('Sandi Metz' && "1") } | |
end | |
it "go to the right results page", :js => true do | |
fill_in 'st-search-input', :with => "pothibo\n" | |
within('.st-search-summary') { expect(page).to have_content('Sessions, Cookies, and Authentication' && "1") } | |
click_link('Sessions, Cookies, and Authentication') | |
page.has_content?('are the idea that your user') | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment