Skip to content

Instantly share code, notes, and snippets.

@23inhouse
Created April 4, 2011 02:36
Show Gist options
  • Save 23inhouse/901072 to your computer and use it in GitHub Desktop.
Save 23inhouse/901072 to your computer and use it in GitHub Desktop.
spec/support/authentication.rb
def login!(user = false)
@current_user = user
controller.stub!(:current_user).and_return(@current_user)
view.stub!(:current_user).and_return(@current_user)
session[:user_id] = @current_user.id
end
def login_as_seller!(seller = Seller.make(:valid))
login!(seller.account)
controller.stub!(:current_seller).and_return(seller)
view.stub!(:current_seller).and_return(seller)
end
------------------------------
require 'spec_helper'
describe Seller::ProspectivesController do
render_views
before(:all) do
@account = Account.make(:seller)
@seller = Seller.make(:paypal, :account_id => @account.id)
end
before(:each) do
@request.host = "#{@seller.subdomain}.#{DEFAULT_HOST}"
login_as_seller!(@seller)
end
describe "GET index" do
it "should show do something" do
get :index
end
end
end
---------------------
Failures:
1) Seller::ProspectivesController index should show do something
Failure/Error: login_as_seller!(@seller)
NameError:
undefined local variable or method `view' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x0000010475c8f8>
# ./spec/support/authentication.rb:4:in `login!'
# ./spec/support/authentication.rb:9:in `login_as_seller!'
# ./spec/controllers/seller/prospectives_controller_spec.rb:13:in `block (2 levels) in <top (required)>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment