Skip to content

Instantly share code, notes, and snippets.

@sam
Created October 4, 2012 15:18
Show Gist options
  • Save sam/3834315 to your computer and use it in GitHub Desktop.
Save sam/3834315 to your computer and use it in GitHub Desktop.
new lambda syntax + must_raise
it "must raise an exception if the file does not exist" do
Helper::tmp do |tmp|
assert_raises(Errno::ENOENT) do
Doubleshot::Compiler::Classpath.new.add(tmp + "asdf")
end
end
end
it "must raise an exception if the file does not exist" do
Helper::tmp do |tmp|
lambda do
Doubleshot::Compiler::Classpath.new.add(tmp + "asdf")
end.must_raise(Errno::ENOENT)
end
end
it "must raise an exception if the file does not exist" do
Helper::tmp do |tmp|
-> do
Doubleshot::Compiler::Classpath.new.add(tmp + "asdf")
end.must_raise(Errno::ENOENT)
end
end
@sam
Copy link
Author

sam commented Oct 4, 2012

I've been using assertion style because lambda style just seemed awkward to me. But the new lambda syntax is growing on me in this example.

I didn't dislike the new syntax before, I just don't do much assigning lambdas to variables so I haven't had much opportunity to use it. But in this case, it looks nice I think even if it's the same amount of "words" as the old style. I dunno, just some food for thought since the #must_raise matcher in Minitest was one of my few gripes with it.

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