Skip to content

Instantly share code, notes, and snippets.

@simonmorley
Forked from them0nk/rspec_rails_cheetsheet.rb
Last active January 1, 2016 15:49
Show Gist options
  • Select an option

  • Save simonmorley/8166390 to your computer and use it in GitHub Desktop.

Select an option

Save simonmorley/8166390 to your computer and use it in GitHub Desktop.
#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")
response.body.should have_css("input#movie_title", :value => "Twelve Angry Men")
response.body.should have_xpath("//a")
response.body.should have_xpath("//a",:href => "google.com")
@simonmorley
Copy link
Author

all('a').select {|elt| elt.text == "#tag1" }.first.click

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