Капибара и огурец | Получение файлов cookie

Я пытаюсь получить значения cookie на шаге Cucumber:

Определения шагов

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 в шагах Cucumber с помощью Capybara?

Спасибо.

Debian GNU / Linux 6.0.4;

Ruby 1.9.3;

Ruby on Rails 3.2.1;

Cucumber 1.1.4;

Cucumber-Rails 1.2.1;

Capybara 1.1.2;

Rack-Test 0.6.1.

11
задан James A. Rosen 31 May 2019 в 15:01
поделиться