Last active
November 10, 2018 09:21
-
-
Save floehopper/150effd6a3da1b9106280371dd0c6f25 to your computer and use it in GitHub Desktop.
Mocha issue 349
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
source 'https://rubygems.org' | |
gem 'minitest' | |
gem 'mocha' |
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
GEM | |
remote: https://rubygems.org/ | |
specs: | |
metaclass (0.0.4) | |
minitest (5.11.3) | |
mocha (1.7.0) | |
metaclass (~> 0.0.1) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
minitest | |
mocha | |
BUNDLED WITH | |
1.17.1 |
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
$ ruby my_test.rb | |
Run options: --seed 53332 | |
# Running: | |
F. | |
Finished in 0.002206s, 906.6181 runs/s, 453.3091 assertions/s. | |
1) Failure: | |
MyTest#test_blah_fail [my_test.rb:5]: | |
unexpected invocation: MyClass.new("SomeKey", 1234, 2018-11-10 09:17:45 +0000 (1541841465.160419 secs)) | |
unsatisfied expectations: | |
- expected exactly once, not yet invoked: MyClass.new("SomeKey", 4321, anything) | |
2 runs, 1 assertions, 1 failures, 0 errors, 0 skips |
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 'bundler/setup' | |
require 'minitest/autorun' | |
require 'mocha/minitest' | |
class MyClass; end | |
class SomethingElse | |
def blah | |
MyClass.new('SomeKey', 1234, Time.now) | |
end | |
end | |
class MyTest < Minitest::Test | |
def test_blah_pass | |
object = mock | |
MyClass.expects(:new).with('SomeKey', 1234, anything).returns(object) | |
test_obj = SomethingElse.new | |
test_obj.blah | |
end | |
def test_blah_fail | |
object = mock | |
MyClass.expects(:new).with('SomeKey', 4321, anything).returns(object) | |
test_obj = SomethingElse.new | |
test_obj.blah | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment