Skip to content

Instantly share code, notes, and snippets.

@AlexParamonov
Created April 5, 2012 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexParamonov/2311105 to your computer and use it in GitHub Desktop.
Save AlexParamonov/2311105 to your computer and use it in GitHub Desktop.
Rspec and delegate
require "delegate"
class A < SimpleDelegator
def ex(foo)
end
end
require_relative "rspec_and_delegate"
describe "stub" do
it "should not raise any error" do
a = A.new([])
a.stub(:ex) # it did not actually stub ex method on A
expect { a.ex }.to_not raise_error # this will raise wrong number of arguments
end
end
@AlexParamonov
Copy link
Author

solved this issue by explicitly defining method on an instance by instance_eval.
any ideas how to solve this with rspec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment