我想在黄瓜一步获得cookie值:水豚&黄瓜|获取饼干
步骤定义
When /^I log in$/ do
# code to log in
end
Then /^cookies should be set$/ do
cookies[:author].should_not be_nil
end
控制器
class SessionsController < ApplicationController
def create
cookies[:author] = 'me'
redirect_to authors_path
end
end
但它不工作:
结果
expected: not nil
got: nil
有趣的是,在该RSpec的例子所有的作品就好了:
控制器规格
require 'spec_helper'
describe SessionsController do
describe 'create' do
it 'sets cookies' do
post :create
cookies[:author].should_not be_nil
end
end
end
我怎样才能获得使用水豚黄瓜步骤cookie值?
谢谢。
Debian GNU/Linux 6.0.4;
Ruby 1.9.3;
Ruby on Rails 3.2.1;
黄瓜1.1.4;
Cucumber-Rails 1.2.1;
水豚1.1.2;
机架测试0.6.1。
您可以将其解压为自定义方法,例如https://github.com/cucumber/cucumber/wiki/Cucumber-Backgrounder#steps-within-steps--an-anti-pattern中所述(朝向结尾的部分)。 – juanrpozo 2013-05-25 10:58:55