Hello! I''m just a caveman with some caveman questions. I''ve been parsing Rspec for quite a while, and I''m writing my first series of specs. My initial impressions are "Verbose, but understandable. Helpful and intuitive, but so much to digest." I want to congratulate the folks who are dedicating a chunk of their lives to writing this, and ask 2 caveman questions My first is "Why lambda in rpsec"? It doesn''t strike me as "reads like english" or "easily understandable." I understand it''s place in ruby (um, kind of :), but my thinking is: lambda { do_something_risky }.should raise_error would be more understandable (and fun!) written as: running { something_risky }.should raise_error My second question is: For those folks who are getting up to speed with ruby and rails AND digesting rspec along the way, there is a lot of incoming DSL. As I started with rails before rspec, I found myself using script/console to check my code, poking at different ways of expressing myself with ruby. Is there a way to "poke at my specs"? I can load up my test environment, but can I spec things "live" so that I can find out what works and what doesn''t? I find I''m wasting a chunk of time (as I don''t have the DSL even 60% down) writing specs and getting it wrong. Am I missing a trick, or I.should_have dsl_down_before_trying.else_return(crying)? um, thanks for any potential caveman responses - the more caveman (pragmatic) the better. sudara -- View this message in context: http://www.nabble.com/Rspec-Caveman-questions.-tf4387721.html#a12509678 Sent from the rspec-users mailing list archive at Nabble.com.
On Sep 5, 2007, at 3:49 PM, sudara wrote:> > Hello! > > I''m just a caveman with some caveman questions. > > I''ve been parsing Rspec for quite a while, and I''m writing my first > series > of specs. My initial impressions are "Verbose, but understandable. > Helpful > and intuitive, but so much to digest." I want to congratulate the > folks who > are dedicating a chunk of their lives to writing this, and ask 2 > caveman > questions > > My first is "Why lambda in rpsec"? It doesn''t strike me as "reads like > english" or "easily understandable." I understand it''s place in > ruby (um, > kind of :), but my thinking is: > > lambda { do_something_risky }.should raise_error > > would be more understandable (and fun!) written as: > > running { something_risky }.should raise_errorIt''s not too hard to understand is it? Lambda/Procs are used for delayed evaluation. If you did something like this: do_something_risky.should raise_error, then an error would be raised even before the should method could be called to check for an error. The beauty of ruby is that if you really wanted "running", it would be rather easy to add it yourself: alias :running :lambda> > My second question is: For those folks who are getting up to speed > with ruby > and rails AND digesting rspec along the way, there is a lot of > incoming DSL. > As I started with rails before rspec, I found myself using script/ > console to > check my code, poking at different ways of expressing myself with > ruby. > > Is there a way to "poke at my specs"? I can load up my test > environment, but > can I spec things "live" so that I can find out what works and what > doesn''t? > I find I''m wasting a chunk of time (as I don''t have the DSL even > 60% down) > writing specs and getting it wrong. Am I missing a trick, or > I.should_have > dsl_down_before_trying.else_return(crying)? >Honestly, If you are used to Test::Unit, the difference is mainly how you assert: Test::Unit: assert_equal obj, value RSpec: obj.should == value You might also want to look at my last email about custom matchers + ruby-debug. Regards Scott
Thanks David and Scott for your comments. @David: Your irb example worked great for exploring matchers. I was looking for a way to be able to literally write my specs in the script/server console, but I think at this point I''m almost good to go on DSL. @Scott: Yes, thanks for the tips. I''m aware that I can alias lambda - the point was more "it would be helpful for incoming users digesting DSL / it is more english-like" -I''ll throw a patch in as David suggested - as soon as I figure out why my rails fixtures are not loading due to the last svn up ;) Regarding the DSL being similar to Test::Unit - I''m sure it would be easier to pick up Speccing coming from Test::Unit, but coming from nothing to a ruby/rails/rspec, even when done slowly, requires a fair bit of trial and error. Playing in the console is the most effective way (for me) to learn a DSL inside and out. Thanks both for your time! sudara -- View this message in context: http://www.nabble.com/Rspec-Caveman-questions.-tf4387721.html#a12597802 Sent from the rspec-users mailing list archive at Nabble.com.
On 9/10/07, sudara <sudara at modernthings.net> wrote:> > Thanks David and Scott for your comments. > > @David: Your irb example worked great for exploring matchers. I was looking > for a way to be able to literally write my specs in the script/server > console, but I think at this point I''m almost good to go on DSL. > > @Scott: Yes, thanks for the tips. I''m aware that I can alias lambda - the > point was more "it would be helpful for incoming users digesting DSL / it is > more english-like" -I''ll throw a patch in as David suggested - as soon as I > figure out why my rails fixtures are not loading due to the last svn up ;)svn up again - I just fixed that> > Regarding the DSL being similar to Test::Unit - I''m sure it would be easier > to pick up Speccing coming from Test::Unit, but coming from nothing to a > ruby/rails/rspec, even when done slowly, requires a fair bit of trial and > error. Playing in the console is the most effective way (for me) to learn a > DSL inside and out. > > Thanks both for your time! > > sudara > -- > View this message in context: http://www.nabble.com/Rspec-Caveman-questions.-tf4387721.html#a12597802 > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >