Skip to content

Instantly share code, notes, and snippets.

@okitan
Created March 4, 2010 02:41
Show Gist options
  • Save okitan/321339 to your computer and use it in GitHub Desktop.
Save okitan/321339 to your computer and use it in GitHub Desktop.
describe MyController, '#index' do
include PureControllerTestHelper
let(:user) { MyModel.make_unsaved }
before do
mock(MyModel).find { user }
end
it 'should assign @user'
expect { controller.index }.to change { assigns[:user] }.from(nil).to(user)
end
end
module PureControllerTestHelper
def self.included(target)
target.instance_eval do
before do
@_assigns_hash_proxy = Spec::Rails::Example::AssignsHashProxy.new(self) { controller }
controller.send(:initialize_template_class, response)
controller.send(:assign_shortcuts, request, response)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment