English 中文(简体)
Cu木步骤之间是否有 persist和 st?
原标题:Can mocks and stubs persist between Cucumber steps?

我有一份依靠第3个称为“PSC的当事人的电文,但我想把我的黄瓜测试从APIC电话中分离出来。

因此,我写了几个黄瓜步骤:

When /^we pretend that PSC is up$/ do
  PscV1.default_psc_connection("test user").stub!(:default_connection_is_up?).and_return(true)
end

When /^we pretend like PSC assignments exist for all subjects$/ do
  PscV1.default_psc_connection("test user").stub!(:assignment_exists?).and_return(true)
end

......以及这些要达到的麻烦使得Cucumber情景认为,APIC电话正在发挥作用。 然而,在步骤之间似乎没有留下任何麻烦,因此,在我的设想中,进一步的步骤没有达到令人困惑的返回价值,而是试图发出实际的APIC呼吁,因此失败。

至少只要整个情景存在,是否有办法坚持下去? 我在其他 Cu木试验中成功地使用了ub,因此我知道这些ub子一般都在发挥作用,但这是我第一次写出一个木板步骤,其全部目的是提供麻烦。

最佳回答

就我所知,对是否坚持下去的回答完全是“否”。

我撰写了以下共同步骤:

When /^I follow "([^"]*)" while pretending that PSC is up and assignments exists for all users$/ do |link_text|
  PscV1.stub!(:default_connection_is_up?).and_return(true)
  PscV1.default_psc_connection("test user").stub!(:assignment_exists?).and_return(true)
  click_link link_text
end

......工作。 不幸的是,我不得不重复这些 st,作为他们自己的步骤,但这样做是可行的。

<>>>> 你们也许可以通过将 st放在一个等级变量上来克服这一限制,在同样情况下,其他步骤都可以进入。

问题回答

暂无回答




相关问题
Why Cucumber hook methods aren t lowercase?

Cucumber has a few different hook methods like Before, After or AfterStep. I was wondering - why doesn t these method names follow Ruby s naming conventions to write method names all lowercase? ...

Cucumber Table Diff and colspan

I love cucumber, and its table diff feature. But I, often use a td colspan to display the title of the table. And I can t seem to get the table diff to work when I use colspan. (Table diff expects a ...

cucumber features --guess

I m setting up my Authlogic user session features. And I m in some kind of confusion. When I run: cucumber features I get some red errors Scenario: User signs in successfully ...

Rails | Cucumber | acl9 | AccessDenied

I am ramping up Cucumber, and I am having a issue getting one of my first tests to pass. The exception I am getting is: And I visit the new contract screen Acl9::AccessDenied (Acl9::AccessDenied) ...

Silencing Factory Girl logging

Just to clear the air, I am not some cruel factory master trying to silence working ladies. I am having a very annoying problem where when using Thoughtbot s factory girl in my specs, every time ...

How to resolve Rails model namespace collision

The story so far: I have a rails app with a model named "Term". All is well until trying to install Cucumber. Upon running rake cucumber I get Term is not a class (TypeError) This happens because ...

rspec testing views with internationalization?

I want to make sure I have the right meta desc/keyword and title text in my view so I want to create rspec views tests for that. Now the real challange here is how to make it work across multiple ...

热门标签