Created
February 27, 2013 10:10
-
-
Save kylewelsby/5046844 to your computer and use it in GitHub Desktop.
Simple RSpec Controller Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ClientController < ApplicationController | |
| respont_to :html | |
| def show | |
| @client = Client.find(params[:id]) | |
| respond_with @client | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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