上下文子句中的sign_in_as声明?

时间:2015-03-26 16:40:49

标签: ruby-on-rails rspec

“sign_in_as:user”代表什么?
这只是前一个块的快捷方式吗? 刚刚继承了代码库,我无法找到它的工作原理 反正有没有将它重构为更加文档化的格式?

context 'when an User is logged in', sign_in_as: :user do

    context 'without the System Administrator role' do


        let :user do 
            create :user
        end




        it 'redirects to root' do
            action
            expect(response).to redirect_to root_path
        end

    end

1 个答案:

答案 0 :(得分:1)

这是在您的上下文中包含帮助程序的语法。 Here是此功能的说明和示例。

因此,请检查您的spec/spec_helper.rbspec/rails_helper.rb个文件。我想你可以在其中找到sign_in_as的声明。