ANN: ZenTest 3.4.0 Released

R

Ryan Davis

ZenTest version 2.4.0 has been released!

http://www.zenspider.com/ZSS/Products/ZenTest/

** DESCRIPTION:

ZenTest scans your target and unit-test code and writes your missing
code based on simple naming rules, enabling XP at a much quicker
pace. ZenTest only works with Ruby and Test::Unit.

There are two strategies intended for ZenTest: test conformance
auditing and rapid XP.

For auditing, ZenTest provides an excellent means of finding methods
that have slipped through the testing process. I've run it against my
own software and found I missed a lot in a well tested
package. Writing those tests found 4 bugs I had no idea existed.

ZenTest can also be used to evaluate generated code and execute your
tests, allowing for very rapid development of both tests and
implementation.

** FEATURES/PROBLEMS:

+ Scans your ruby code and tests and generates missing methods for you.
+ Includes a very helpful filter for Test::Unit output called
unit_diff.rb
+ Includes a LinuxJournal article on testing with ZenTest written by
Pat Eyler.

http://www.zenspider.com/ZSS/Products/ZenTest/

Changes:

+ 3 minor enhancements
+ Able to audit standard class library (so now we can audit
rubicon!).
+ Able to map against class methods (self.blah <=>
test_class_blah).
+ Added -I=rubypath support
+ 4 bug fixes
+ bug:1151 Fixed stupid problem w/ unit_diff.
+ bug:1454 code generation correctly matches class/module for
nested classes.
+ bug:1455 Updated method mapping to work on all operators
listed in my quickref.
+ Realized I'm a moron and did NOT release in March like I
thought...

http://www.zenspider.com/ZSS/Products/ZenTest/
 
C

Christophe Grandsire

Selon Ryan Davis said:
ZenTest version 2.4.0 has been released!

Thank you very much for it! I've always wanted to learn about unit testin=
g, but
never got around to do it because no tutorial I could find was really
practical. Now I can easily begin learning through use by letting ZenTest
generate tests around some of my old untested code! Thanks a lot for this=
great
tool!
--
Christophe Grandsire.

http://rainbow.conlang.free.fr

It takes a straight mind to create a twisted conlang.
 
R

Ryan Davis

Thank you very much for it! I've always wanted to learn about unit
testing, but
never got around to do it because no tutorial I could find was really
practical. Now I can easily begin learning through use by letting
ZenTest
generate tests around some of my old untested code! Thanks a lot
for this great
tool!

You are very welcome. I look forward to your feedback.
 
W

Warren Seltzer

I see this notation, which appears to be undefined outside of hash literals, all over the
place. What does it do? The online version of the pickaxe book doesn't have it.

Here's a rails example:

def do_something
redirect_to :action => "elsewhere"
render :action => "overthere" # raises DoubleRenderError
end

Warren Seltzer
 
C

Christophe Grandsire

En r=E9ponse =E0 Warren Seltzer :
I see this notation, which appears to be undefined outside of hash lite= rals, all over the
place. What does it do? The online version of the pickaxe book doesn= 't have it.
=20
Here's a rails example:
=20
def do_something
redirect_to :action =3D> "elsewhere"
render :action =3D> "overthere" # raises DoubleRenderError
end
=20

Basically, those are hash literals too. They look a bit like keyword=20
arguments because of the syntactic sugar that Ruby allows:
- If the only argument of a method is a hash, you can lose the {}:=20
"mymethod({:foo =3D> "bar"})" can be written "mymethod:)foo =3D> "bar")"
- Parentheses around the parameter list of a method are optional:
"mymethod(foo)" can be written "mymethod foo"
Add both rules, and you get exactly the syntax of your example.=20
"redirect_to" and "render" are actually just methods that take hash=20
arguments ('redirect_to :action =3D> "elsewhere"' is just another way to=20
write 'redirect_to({:action =3D> "elsewhere"})' in a clearer and key-hit=20
saving way ;) ), and the two syntactic sugar rules allows one to use=20
them in a keyword+keyword argument fashion. Neat isn't it? :)

As for why the online Pickaxe doesn't have it, it may be because the=20
hash syntactic sugar is only present since Ruby 1.8, while the online=20
Pickaxe covers Ruby 1.6. But I could be wrong.
--=20
Christophe Grandsire.

http://rainbow.conlang.free.fr

You need a straight mind to invent a twisted conlang.
 
J

Jamis Buck

As you know, you can create a hash like so:

hash = { :action => "overthere" }

You could, if you so desired, then pass this hash to a method:

render(hash)

You could combine the two to get:

render({ :action => "overthere" })

Ruby actually lets you omit the curly braces when the hash is the
last parameter of a method:

render :action => "overthere"

The above just calls render with a single hash as the parameter,
containing :action. You can specify as many arguments as you want,
and as long as the hash parameters are the last ones, it all Just
Works, with the last parameter of the method receiving the hash.

- Jamis
 
B

Brian Schröder

En r=E9ponse =E0 Warren Seltzer :

Basically, those are hash literals too. They look a bit like keyword
arguments because of the syntactic sugar that Ruby allows:
- If the only argument of a method is a hash, you can lose the {}:
"mymethod({:foo =3D> "bar"})" can be written "mymethod:)foo =3D> "bar")"
- Parentheses around the parameter list of a method are optional:
"mymethod(foo)" can be written "mymethod foo"
Add both rules, and you get exactly the syntax of your example.
"redirect_to" and "render" are actually just methods that take hash
arguments ('redirect_to :action =3D> "elsewhere"' is just another way to
write 'redirect_to({:action =3D> "elsewhere"})' in a clearer and key-hit
saving way ;) ), and the two syntactic sugar rules allows one to use
them in a keyword+keyword argument fashion. Neat isn't it? :)

As for why the online Pickaxe doesn't have it, it may be because the
hash syntactic sugar is only present since Ruby 1.8, while the online
Pickaxe covers Ruby 1.6. But I could be wrong.
--
Christophe Grandsire.

http://rainbow.conlang.free.fr

You need a straight mind to invent a twisted conlang.

It works not only when the method has only one argument, but always
with the last argument.

$ irb
irb(main):001:0> def show(*args) p args end
=3D> nil
irb(main):002:0> show 1, 2, 3, 5 =3D> 6
[1, 2, 3, {5=3D>6}]
=3D> nil

regards,
brian
 
M

Martin DeMello

Brian Schröder said:
It works not only when the method has only one argument, but always
with the last argument.

$ irb
irb(main):001:0> def show(*args) p args end
=> nil
irb(main):002:0> show 1, 2, 3, 5 => 6
[1, 2, 3, {5=>6}]
=> nil

And (since none of the examples have made that explicit), the hash can
have more than one element in it.

irb(main):002:0> show 1, 2, 3, 4 => 5, 6 => 7
[1, 2, 3, {6=>7, 4=>5}]
=> nil

martin
 
C

Christophe Grandsire

En r=E9ponse =E0 Brian Schr=F6der :
=20
It works not only when the method has only one argument, but always
with the last argument.
=20
$ irb
irb(main):001:0> def show(*args) p args end
=3D> nil
irb(main):002:0> show 1, 2, 3, 5 =3D> 6
[1, 2, 3, {5=3D>6}]
=3D> nil
=20

Thanks for pointing that out. I've only ever seen this with methods that=20
have only the hash as argument (mainly rails examples), so I didn't know=20
normal parameters are allowed as long as they preceed the hash.
--=20
Christophe Grandsire.

http://rainbow.conlang.free.fr

You need a straight mind to invent a twisted conlang.
 
J

James Edward Gray II

Thanks for pointing that out. I've only ever seen this with methods
that have only the hash as argument (mainly rails examples), so I
didn't know normal parameters are allowed as long as they preceed
the hash.

Rails has lots of the latter too. For example:

find:)all, :conditions => "whatever...") # first arg not part of hash

James Edward Gray II
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top