调用`request`的参数数量错误(0表示1)(ArgumentError)

时间:2013-06-18 19:36:06

标签: ruby-on-rails-3.2 cucumber

我正在将cucumber-rails-0.3.2升级为cucumber-rails-1.3.1,这是Gemfile

group :development, :test do
  gem "cucumber-rails", "1.3.1", :require => false
  gem "database_cleaner"
  gem "rspec-rails", ">= 2.8.1"
  gem "webrat"
end

我有登录方案,这里是

Scenario: Navigating to the login page
    Given an unauthenticated visitor

    When visitor goes to the home page
    And clicks on 'Login'

    Then visitor should see the people login page

和相应的步骤定义是

Given "an unauthenticated visitor" do
  request.session.delete if request && request.session
end

OR

类似这样的事情

request.session[:user_id].should == Person.find_by_username(user).id

在这个阶段,我得到wrong number of arguments calling request (0 for 1) (ArgumentError)

我根据cucumber-rails-1.3.1设置了黄瓜环境,我正在使用Mocks (RSpec::Mocks)

任何有关此欢迎和赞赏的想法或帮助。

1 个答案:

答案 0 :(得分:0)

request.session对象实际上只是一个哈希值,delete(doc)需要1个参数(要删除的键删除)。

以下是您的步骤定义:

Given "an unauthenticated visitor" do
  Capybara.reset_sessions!
end