Ruby on rails 4 水豚;不重置Cookie/会话
以下是我在测试中所做的Ruby on rails 4 水豚;不重置Cookie/会话,ruby-on-rails-4,cucumber,capybara,Ruby On Rails 4,Cucumber,Capybara,以下是我在测试中所做的 用户输入他们的店铺名称 用户提供凭据 用户将记录添加到数据库 第一种情况,一切都很顺利。第二种情况下,问题是我们跳过了OAuth凭据页面,因此测试失败 我如何避免这种情况?(我是测试新手) 步骤文件: Before do @shop = FactoryGirl.build(:shop) end Given /^I am a logged in user$/ do visit root_path fil
Before do
@shop = FactoryGirl.build(:shop)
end
Given /^I am a logged in user$/ do
visit root_path
fill_in :shop, :with => "jims-spears"
click_button 'Install'
expect(page).to have_content('Log in to manage')
fill_in :login, :with => 'jackson@example.com'
fill_in :password, :with => "12345"
click_button 'Log in'
expect(page).to have_content("We'll automatically")
end
Given /^the customer is a (.+) athlete$/ do |type|
athlete_type = (type + "_athlete").to_sym
@customer = create(athlete_type, :shop => @shop)
end
功能文件:
Feature: User adds a customer manually
Background:
Given I am a logged in user
Scenario: User adds a customer who is a swimming athlete
Given the customer is a swimming athlete
When I add the customer
Then I should see that the customer is an athlete
Scenario: User adds a customer who is a rowing athlete
Given the customer is a rowing athlete
When I add the customer
Then I should see that the customer is an athlete
我尝试在step文件中添加一个钩子,但没有成功
After do
@shop.destroy
end
有什么想法吗?测试失败在哪里?是登录步骤失败还是创建@customer?我认为您的测试非常混乱——您的场景说明用户正在添加一个客户,该客户是一个X运动员,但随后您说明一个给定的客户是一个特定类型的运动员——Givens通常用于测试系统设置中预先存在的东西。在您的案例中,我希望“当我添加一名游泳运动员”作为测试中的一个步骤——但您没有显示“我添加一名客户”步骤的定义,因此我可能误读了一些内容。另外,与其添加销毁商店的后续步骤,不如查看数据库