Skip to content

Instantly share code, notes, and snippets.

@bkutil
Created August 27, 2013 13:09
Show Gist options
  • Save bkutil/6353301 to your computer and use it in GitHub Desktop.
Save bkutil/6353301 to your computer and use it in GitHub Desktop.
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