我正在使用与 Jeff Morgan 的书“Cucumber & Cheese”几乎完全相同的设置,并且我有一个这样的页面对象
class NewPublicationPage
include PageObject
include RSpec::Matchers
...
def submit_basic_message_with_tag
@tag = Time.now.to_i
...
self.tag_entry = @tag
# the tag ends up getting added later on down the road to a div container.
...
end
def verify_last_tag
done_loading
# tag_list is a div container that should contain the tag.
tag_list.should include @tag
end
end
当我在 Cucumber 步骤中运行以下命令时,每个命令都有自己的步骤,它会说cannot convert nil to string
. 我知道这与实例变量@tag 有关,但我不确定为什么。
When /^I submit a basic message with tags$/ do
on_page(NewPublicationPage).submit_basic_message_with_tag
end
Then /^I should see the tag under Publish History$/ do
visit_page(PublishHistoryPage) # goes to page with div container that holds tags
on_page(NewPublicationPage).verify_last_tag #this creates the error
end