I thought the outermost context would be run only once. It seems to
be running multiple times. I took one of the examples on the shoulda
site and added some puts statements.
require 'test/unit'
require 'shoulda'
class QueueTest < Test::Unit::TestCase
context "A Queue instance" do
setup do
puts "OUTER SETUP"
@queue = Queue.new
end
should "respond to :push" do
assert_respond_to @queue, :push
end
context "with a single element" do
setup { puts "INNER SETUP"; @queue.push(:something) }
should "return that element on :pop" do
assert_equal :something, @queue.pop
end
should "return 1 on :size" do
assert_equal 1, @queue.size
end
end
end
end
I expected to see OUTER SETUP printed only once. But here is what was
printed: