Skip to content

Instantly share code, notes, and snippets.

@epinault
Created August 30, 2012 23:20
Show Gist options
  • Save epinault/3544674 to your computer and use it in GitHub Desktop.
Save epinault/3544674 to your computer and use it in GitHub Desktop.
require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/mock'
class A
def method1(url)
submethod(url)
end
def submethod(url)
puts 'do something'
end
end
describe 'lambda issue' do
before :each do
@obj = A.new
end
it "should not break when using lambda" do
@obj.stub :submethod, lambda{raise('hello')} do
@obj.method1('hi')
end
end
end
@zenspider
Copy link

require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/mock'

class A
def submethod url
raise "you should not see this"
end

def method1
url = "xxxx"
submethod(url)
end
end

describe 'lambda issue' do
before :each do
@obj = A.new
end

it "should not break when using lambda" do
@obj.stub :submethod, lambda{ raise('hello') } do
@obj.method1
end
end
end

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