Skip to content

Instantly share code, notes, and snippets.

@carlows
Forked from them0nk/rspec_rails_cheetsheet.rb
Created March 15, 2016 15:42
Show Gist options
  • Select an option

  • Save carlows/c8aeeafa2c52bc81a0bb to your computer and use it in GitHub Desktop.

Select an option

Save carlows/c8aeeafa2c52bc81a0bb to your computer and use it in GitHub Desktop.
Rspec Rails cheatsheet (include capybara matchers)
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
#Matchers
response.body.should have_content("Hello world")
response.body.should have_no_content("Hello world")
response.body.should have_selector("input") #checks for the presence of the input tag
response.body.should have_selector("input", :value =>"Twelve Angry Men") # checks for input tag with value
response.body.should have_no_selector("input")
response.body.should have_css("input#movie_title")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment