Skip to content

Instantly share code, notes, and snippets.

@acnalesso
Created May 28, 2013 00:59
Show Gist options
  • Save acnalesso/5659878 to your computer and use it in GitHub Desktop.
Save acnalesso/5659878 to your computer and use it in GitHub Desktop.
Good or Bad? Poor or Fine?
require 'spec_helper'
describe AdminController do
# Stubs out, returns true. Logged in as Admin
login(true)
describe 'GET' do
let(:admin) { mock_model(Admin) }
describe '#index' do
before { Admin.should_receive(:find).with('1').and_return(admin) ; subject }
subject { get :index, id: 1 }
it { should be_success }
it { assigns(:admin).should eq(admin) }
it 'does not find an admin' do #is this a good spectation?
Admin.should_receive(:find).with('0')
.and_return { raise ActiveRecord::RecordNotFound }
expect { get :index, id: 0 }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment