How does the TeSLa version know what :item4 is for, or where
it goes, or what 'size' refers to? The example has no
reference to Catalog; how does the code know to test that class?
I know nothing about TeSLA, but I can make a guess.
test_method :add_item => [:item4] do
requires {@items = [:item1, :item2, :item3]}
assert {size == 4}
end
This creates a testcase that will call the "add_item" method on an
instance of the class (I'm guessing that you define test_method within
the context of a class). Before calling the method, it will set the
instance variable @items to the value [:item1, :item2, :item3]. It will
then pass that arguments [:item4] to the method, and afterwards call the
size method and ensure that it equals 4. It does the equivalent of:
c = Catalogue.new
c.instance_eval { @items = [:item1, :item2, :item3] }
c.instance_eval { send(:add_item, :item4) }
raise unless c.instance_eval { size == 4 }
Or, that's my impression....
···
-----Original Message-----
From: James Britt [mailto:james_b@neurogami.com]
Sent: Monday, 31 October 2005 4:41 PM
To: ruby-talk ML
Subject: Re: <ANN> TeSLa, a Domain Specific Language for Unit Testingjavierg1975@gmail.com wrote:
> Hi
> I just posted version 0.1.0 of TeSLa, a Domain Specific
Language (DSL)
> for Unit Testing.
> You can download TeSLa along with a small example script from
> http://theniceweb.com/projects/tesla/tesla.zip (zip) or here
> http://theniceweb.com/projects/tesla/tesla.tar.gz (tar.gz) I also
> posted a small article/tutorial explaining the rationale and use of
> TeSLa here
>
http://www.theniceweb.com/JaviersBlog/2005/10/tesla-test-specific-lang
> uage-for-ruby.htmlThis looks quite interesting. Two questions:
1. How does this compare to behavior-driven development?
http://daveastels.com/index.php?p=5
2. The TeSLa docs give this example, comparing Test::Unit and TesLa:
class TestCatalog < Test::Unit::TestCase
def test_add_item
catalog = Catalog.new()
catalog.items = [:item1, :item2, :item3]
catalog.add_item :item4
assert_equal(catalog.size, 4, "length should be 4")
end
endwould look like this in TeSLa
test_method :add_item => [:item4] do
requires {@items = [:item1, :item2, :item3]}
assert {size == 4}
endHow does the TeSLa version know what :item4 is for, or where
it goes, or what 'size' refers to? The example has no
reference to Catalog; how does the code know to test that class?Thanks,
James
--http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for
Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby
Stuff http://www.jamesbritt.com - Playing with Better Toys
#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################