Skip to content

Instantly share code, notes, and snippets.

@feroult
Created February 7, 2011 21:10
Show Gist options
  • Save feroult/815226 to your computer and use it in GitHub Desktop.
Save feroult/815226 to your computer and use it in GitHub Desktop.
RSpec for a Rails Controller, using macros
require 'spec_helper'
describe CustomersController do
before(:each) do
mock_filter(:require_user_owner)
end
# GET /customers
get :index do
default :stub => :off
before(:each) do
Customer.stub(:find_all_by_user_id) { [mock_customer] }
Customer.stub(:smart_offerings) { mock_customer }
Customer.stub(:keep_in_touch) { mock_customer }
end
it { should assign(:customer_smart_offerings => mock_customer) }
it { should assign(:customer_keep_in_touch => mock_customer) }
end
# GET /customers/6
get :show, :id => 6
# GET /customers/new
get :new
# GET /customers/6/edit
get :edit, :id => 6
# POST /customers
post :create
# PUT /customers/6
put :update, :id => 6
# DELETE /customers/6
delete :destroy, :id => 6
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment