Created
July 1, 2013 21:12
-
-
Save geku/5904674 to your computer and use it in GitHub Desktop.
Q quick test to show how MiniTest let works. The let block is reevaluated for everytime, so it is basically the same as before but lazily evaluated whereas before is executed always even if none of the results are used for a test.
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 'rubygems' | |
require 'minitest/autorun' | |
describe 'let_test' do | |
let(:sub) { | |
puts " - lazy :sub called" | |
true | |
} | |
it("is empty") { | |
puts "=== call 1.1" | |
sub.must_equal true | |
puts "=== call 1.2" | |
sub.must_equal true | |
puts "=== call 1.3" | |
sub.must_equal true | |
} | |
it("is filled") { | |
puts "=== call 2.1" | |
sub.must_equal true | |
puts "=== call 2.2" | |
sub.must_equal true | |
puts "=== call 2.3" | |
sub.must_equal true | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The result of
ruby let_test.rb
is: