Created
August 28, 2012 15:19
-
-
Save greggroth/3499022 to your computer and use it in GitHub Desktop.
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
describe "Search courses" do | |
it "by topic" do | |
create_course_catalog | |
create_biology_courses("A001", "B205") | |
search_for('biology') | |
page.should have_content "A001" | |
page.should have_content "B205" | |
end | |
end | |
# in spec/support/request_helpers.rb | |
module RequestHelpers | |
def create_course_catalog | |
240.times { Course.create! } | |
end | |
def create_biology_courses(*names) | |
names.each { |name| Course.create!(topic: "biology", name: name) | |
end | |
def search_for(query) | |
visit search_path | |
fill_in "Search", with: query | |
click_button "Search" | |
end | |
end | |
RSpec.configure do |config| | |
config.include RequestHelpers, type: :request | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't the describe call be like this, in order to have RequestHelpers included?
Enjoyed the blog post but this was fairly confusing as I am unfamiliar with this way of writing specs
Thanks :)