The question is a bit odd, but what I want is an alternative for stub! in Rspec, which does not give a failure warning.
Scenario:
I use stub! to drown out some helper methods in my helper specification.
for instance
stub!(:t_with_partner_lookup).and_return("test")
Rspec, than suggests using a stub without an exclamation mark.
So I write (as suggested):
stub(:t_with_partner_lookup).and_return("test")
However, this causes an error:
Stub :t_with_partner_lookup received unexpected message :and_return with ("test")
In another question I found, I had to use the helper. prefix helper. . I did this, but he did not remove the obsolescence warning, but caused an error.
helper.stub(:t_with_partner_lookup).and_return("test")
It produces:
undefined method `t_with_partner_lookup' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_3:0x00000103256d50>
I also tried this syntax, but this results in the same error as above:
helper.stub(:t_with_partner_lookup){"test"}
What is the correct syntax for creating a helper method?
Gemstones I use :
- rails 3.2.17
- the latest version of rspec-rails
Ruby version 2.1.0
source share