Last active
August 29, 2015 14:15
-
-
Save carols10cents/a4238d43ff2acfa608df to your computer and use it in GitHub Desktop.
Unexpected ruby minitest must_equal parsing silliness
This file contains hidden or 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 'minitest/autorun' | |
| class Poop < Minitest::Spec | |
| def subject | |
| {} | |
| end | |
| describe 'silliness' do | |
| it 'is an empty hash' do | |
| subject.must_equal {} | |
| end | |
| it 'is an empty hash in parens' do | |
| subject.must_equal({}) | |
| end | |
| end | |
| end |
This file contains hidden or 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 poop.rb | |
| Run options: --seed 60711 | |
| # Running: | |
| F. | |
| Finished in 0.029188s, 68.5213 runs/s, 68.5213 assertions/s. | |
| 1) Failure: | |
| silliness#test_0001_is an empty hash [poop.rb:10]: | |
| Expected: nil | |
| Actual: {} | |
| 2 runs, 2 assertions, 1 failures, 0 errors, 0 skips |
This file contains hidden or 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
| def method_with_splat(*args, &block) | |
| puts "args = #{args.inspect}" | |
| puts "block = #{block.inspect}" | |
| end | |
| def method_without_splat(args, &block) | |
| puts "args = #{args.inspect}" | |
| puts "block = #{block.inspect}" | |
| end | |
| puts "with splat:" | |
| method_with_splat {} | |
| method_with_splat({}) | |
| puts "without splat:" | |
| # method_without_splat {} # This causes an argument error | |
| method_without_splat({}) |
This file contains hidden or 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
| with splat: | |
| args = [] | |
| block = #<Proc:[email protected]:12> | |
| args = [{}] | |
| block = nil | |
| without splat: | |
| args = {} | |
| block = nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment