开发者

Is the @routes be created after "before(:all)" and before "before(:each)"?

开发者 https://www.devze.com 2023-03-23 17:20 出处:网络
In the开发者_StackOverflow社区 rails project, when i write some controller\'s spec like this: describe "POST \'create\'" do

In the开发者_StackOverflow社区 rails project, when i write some controller's spec like this:

describe "POST 'create'" do
context "valid user" do
    before(:all) {
  @user_attributes = Factory.attributes_for(:user)
  @user = Factory(:user, @user_attributes)
  post :create, :user=>@user_attributes
}
specify { flash[:notice].should eq("Welcome")}
specify { response.should redirect_to(:action=> :index) }
end
end

I got some errors like this:

Failure/Error: post :create, :user=>@user_attributes

RuntimeError:

@routes is nil: make sure you set it in your test's setup method.

# ./spec/controllers/sessions_controller_spec.rb:22

# ./magazine_slave.rb:22:in `run' # magazine_slave_provider.rb:17

When I change before(:all) to before(:each),the test will be pass.

Is the @routes be created after "before(:all)" and before "before(:each)"


Yes, I think this is answered in another question. From the conversation here, it looks like a fix might be coming.

0

精彩评论

暂无评论...
验证码 换一张
取 消