Look at the code below :-
#!/usr/bin/env ruby
class Foo
def baz
11
end
end
Now my Rspec code :-
require_relative "../test.rb"
describe Foo do
before { Foo.any_instance.stub(:baz).and_return(20) }
it "defines #foo dynamically" do
expect_any_instance_of(Foo).to receive(:baz).and_return(20)
subject.baz
end
end
And finally I got :-
Deprecation Warnings:
Using `any_instance` from rspec-mocks' old `:should` syntax without explicitly
enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly
enable `:should` instead. Called from /home/arup/Ruby/spec/test_spec.rb:4:in
`block (2 levels) in <top (required)>'.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
1 deprecation warning total
Finished in 0.04004 seconds (files took 0.47731 seconds to load)
1 example, 0 failures
arup@linux-wzza:~/Ruby>
What else way I can write this ?
--
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore,
if you write the code as cleverly as possible, you are, by definition, not
smart enough to debug it.
--Brian Kernighan
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/29269646.tYJQcMUKxg%40linux-wzza.site.
For more options, visit https://groups.google.com/d/optout.