Hi, I’m trying to write BDD-style Test::Unit tests like so:
class StackTest < Test::Unit::TestCase
must “return top element” do
#…
end
as opposed to the more usual
class StackTest < Test::Unit::TestCase
def test_return_top_element
#…
end
The trick is explained here:
and the source of the extension is here:
When I run the code I get this:
undefined method `must’ for StackTest:Class (NoMethodError)
Does anyone know why this alternative syntax does not work? In Gregory
Brown’s book it is described as something one can use out of the box,
without installing anything extra. Or is the Ruby version the problem
(I’m using v. 1.9.2p0)?
On Sat, Apr 30, 2011 at 10:11:04PM +0900, Vahagn H. wrote:
Ping…
I, for one, see your messages to the list – but I do not use that
syntax
for my unit tests, so I’m afraid I have nothing to offer. Hopefully
someone else will be able to help.
are you including that code at the top of your test file? or at least
having
a “test_helper.rb” file you require into your tests?? i’ve used this
syntax
before but not extensively, so i dont know how much help i will be.
hex
or at least having a “test_helper.rb” file you require into your tests??
I wasn’t doing that since I had the impression (from reading about this
syntax) that this method was integrated into Test::Unit, so one could
just use it “out of the box”. Apparently I was wrong - I’ve pasted it
into a helper file and required it and now it’s working.
Thanks! V.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.