Skip to content

Instantly share code, notes, and snippets.

@ilstar
Last active August 29, 2015 13:57
Show Gist options
  • Save ilstar/9864334 to your computer and use it in GitHub Desktop.
Save ilstar/9864334 to your computer and use it in GitHub Desktop.
Rspec Rails cheat sheet
# version
# gem 'rspec-rails', '~> 2.14.2'
# render and redirect
response.should be_success
response.status.should == 404
response.response_code.should == 404
response.should render_template('index')
response.should redirect_to(movies_path)
# template
response.body.should =~ /welcome to rails world/m
# variables
assigns(:players).should be_empty
assigns(:players).should_not be_empty
# stub
Player.any_instance.stub(:save).and_return(false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment