Skip to content

Instantly share code, notes, and snippets.

@amed
Forked from mlr/rspec_rails_cheetsheet.rb
Created March 18, 2017 06:58
Show Gist options
  • Select an option

  • Save amed/6dd0cf2b6a78d59b2802f91d23eb5cda to your computer and use it in GitHub Desktop.

Select an option

Save amed/6dd0cf2b6a78d59b2802f91d23eb5cda to your computer and use it in GitHub Desktop.
Rspec Rails cheatsheet with expect syntax (including 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