Skip to content

Instantly share code, notes, and snippets.

@carols10cents
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save carols10cents/a4238d43ff2acfa608df to your computer and use it in GitHub Desktop.

Select an option

Save carols10cents/a4238d43ff2acfa608df to your computer and use it in GitHub Desktop.
Unexpected ruby minitest must_equal parsing silliness
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
$ 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
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({})
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