Skip to content

Instantly share code, notes, and snippets.

@greggroth
Created August 28, 2012 15:19
Show Gist options
  • Save greggroth/3499022 to your computer and use it in GitHub Desktop.
Save greggroth/3499022 to your computer and use it in GitHub Desktop.
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
@margaretdax
Copy link

Shouldn't the describe call be like this, in order to have RequestHelpers included?

describe "Search courses", type: :request do
  ...
end

Enjoyed the blog post but this was fairly confusing as I am unfamiliar with this way of writing specs

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment