Created
August 27, 2013 13:09
-
-
Save bkutil/6353301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "A method stub" do | |
def decorate(klass, scope) | |
klass.class_eval <<-EOF | |
#{scope} | |
def some_stubbed_method | |
end | |
def self.#{scope} | |
end | |
EOF | |
klass | |
end | |
describe "using stub" do | |
it "works when method with a name equal to visibility scope is defined" do | |
%w(public protected private).each do |visibility_scope| | |
instance = decorate(Class.new, visibility_scope).new | |
expect { instance.stub(:some_stubbed_method) }.to_not raise_error | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rspec/rspec-mocks#43
http://ruby-doc.org/core-2.0/Module.html#method-i-public