Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Created February 27, 2013 10:10
Show Gist options
  • Save kylewelsby/5046844 to your computer and use it in GitHub Desktop.
Save kylewelsby/5046844 to your computer and use it in GitHub Desktop.
Simple RSpec Controller Examples
class ClientController < ApplicationController
respont_to :html
def show
@client = Client.find(params[:id])
respond_with @client
end
end
describe "GET show" do
let(:client) { Client.new }
before do
Client.stub(:find).with('1').and_return(client)
get :show, :id => 1
end
example { expect(response).to be_success }
example { expect(assigns[:client]).to be_a Client }
example { expect(assigns[:client]).to eql client }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment