我正在尝试测试一个依赖于由 Padrino::Admin::AccessControl 提供的 current_account 的 padrino 控制器
为此,我需要模拟 current_account。
代码类似于:
App.controller :post do
post :create, map => '/create' do
Post.create :user => current_account
end
end
和 rspec:
describe "Post creation" do
it 'should create' do
account = Account.create :name => 'someone'
loggin_as account #to mock current_account
post '/create'
Post.first.user.should == account
end
end
如何实现“loggin_as”或如何编写此测试?