Created
May 18, 2014 02:25
-
-
Save jamonholmgren/311fb8d252f2fc1de962 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
class MyObj | |
def now(&callback) | |
return callback.call @my_ivar if @my_ivar | |
Dispatch::Queue.new("a").async do | |
sleep 0.1 # simulate an http response | |
Dispatch::Queue.main.sync do | |
@my_ivar = { result: "real" } | |
callback.call @my_ivar | |
end | |
end | |
end | |
end | |
describe "Application 'rm_mocking_issue'" do | |
before do | |
@my_obj = MyObj.new | |
# Removing this line allows the spec to pass. | |
# Adding it causes the spec to hang. | |
@my_obj.instance_variable_set("@my_ivar", { result: "fake" }) | |
end | |
it "hangs" do | |
@my_obj.now do |response| | |
response.should.be.kind_of(Hash) | |
resume | |
end | |
wait {} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment