Ruby on rails 水豚找不到工厂创建的对象的链接
当我做示例题时,类似的问题也发生在我身上。水豚没有选择那里的文字。在这种情况下,水豚并没有为存在的对象拾取链接。我错过什么了吗 错误消息:Ruby on rails 水豚找不到工厂创建的对象的链接,ruby-on-rails,rspec,cucumber,capybara,factory-bot,Ruby On Rails,Rspec,Cucumber,Capybara,Factory Bot,当我做示例题时,类似的问题也发生在我身上。水豚没有选择那里的文字。在这种情况下,水豚并没有为存在的对象拾取链接。我错过什么了吗 错误消息: When I click the link "Why is earth round?" # features/step_definitions/queston_steps.rb:6 no link with title, id or text 'Why is earth round?' found (Capybara::El
When I click the link "Why is earth round?" # features/step_definitions/queston_steps.rb:6
no link with title, id or text 'Why is earth round?' found (Capybara::ElementNotFound)
(eval):2:in `click_link'
./features/step_definitions/queston_steps.rb:7:in `/^I click the link "([^"]*)"$/'
features/viewing_questions.feature:9:in `When I click the link "Why is earth round?"'
这些是我的测试宝石:
group :test, :development do
gem 'rspec-rails'
end
group :test do
gem 'cucumber-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'factory_girl'
gem 'factory_girl_rails'
end
这是我的密码
情景:
Scenario: Listing questions
Given I am on the home page
And there is a question "Why is earth round?"
When I click the link "Why is earth round?"
Then I should be on the page for "Why is earth round?"
And I should see "Question: Why is earth round?"
工厂定义:
Factory.define(:queston) do |q|
q.question "Why is earth round?"
end
Given /^there is a question "([^"]*)"$/ do |question|
FactoryGirl.create(:queston, :question => question)
#Queston.create(:question => question)
end
When /^I click the link "([^"]*)"$/ do |link|
click_link(link)
end
步骤定义:
Factory.define(:queston) do |q|
q.question "Why is earth round?"
end
Given /^there is a question "([^"]*)"$/ do |question|
FactoryGirl.create(:queston, :question => question)
#Queston.create(:question => question)
end
When /^I click the link "([^"]*)"$/ do |link|
click_link(link)
end
视图:
Queston是模型类,question是它的属性。这可能是输入错误:FactoryGirl工厂定义了一个名为
Queston
,而不是question的模型。
如果不是,我会试着提出问题和回答主体,看看每个地方都产生了什么。显然有些东西没有正确生成。这可能是输入错误:FactoryGirl工厂定义了一个名为
queston
的模型,而不是问题。
如果不是,我会试着提出问题和回答主体,看看每个地方都产生了什么。显然有些东西没有正确生成。问题在于我的场景。我必须首先声明对象,如下所示:
Scenario: Listing questions
Given there is a question "Why is earth round?"
And I am on the home page
而不是
Scenario: Listing questions
Given I am on the home page
And there is a question "Why is earth round?"
问题在于我的情景。我必须首先声明对象,如下所示:
Scenario: Listing questions
Given there is a question "Why is earth round?"
And I am on the home page
而不是
Scenario: Listing questions
Given I am on the home page
And there is a question "Why is earth round?"
你能发布你在尝试运行此程序时收到的错误吗?你能发布你在尝试运行此程序时收到的错误吗?是的,Queston是模型。这不是打字错误。是的,奎斯顿是模特。这不是打字错误。