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/Caveman-Questions-tf4384357.html#a12498949 Sent from the rspec-users mailing list archive at Nabble.com.
On 9/5/07, sudara <sudara at modernthings.net> 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_errorThat''s a great idea. Why don''t you add it to the tracker: http://rubyforge.org/tracker/index.php?group_id=797> > 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)?irb(main):001:0> require ''rubygems'' => true irb(main):002:0> require ''spec'' => true irb(main):003:0> include Spec::Matchers => Object irb(main):004:0> 5.should == 5 => nil irb(main):005:0> 5.should be < 4 Spec::Expectations::ExpectationNotMetError: expected < 4, got 5 Cheers, David> > um, thanks for any potential caveman responses - the more caveman > (pragmatic) the better. > > sudara > > > -- > View this message in context: http://www.nabble.com/Caveman-Questions-tf4384357.html#a12498949 > 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 >
On 9/5/07, David Chelimsky <dchelimsky at gmail.com> wrote:> > irb(main):001:0> require ''rubygems'' > => true > irb(main):002:0> require ''spec'' > => true > irb(main):003:0> include Spec::Matchers > => Object > irb(main):004:0> 5.should == 5 > => nil > irb(main):005:0> 5.should be < 4 > Spec::Expectations::ExpectationNotMetError: expected < 4, got 5 >$ script/console Loading development environment.>> require ''rubygems''=> []>> require ''spec''NameError: undefined method `failure_message'' for class `Spec::Matchers::Have'' from /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4:in `alias_method'' from /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'' -- Geoffrey Wiseman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070911/10992e51/attachment-0001.html
Scott Taylor
2007-Oct-05 16:43 UTC
[rspec-users] Caveman Questions - how to use mock_model in script/console?
On Sep 11, 2007, at 2:37 PM, Geoffrey Wiseman wrote:> On 9/5/07, David Chelimsky <dchelimsky at gmail.com> wrote: > irb(main):001:0> require ''rubygems'' > => true > irb(main):002:0> require ''spec'' > => true > irb(main):003:0> include Spec::Matchers > => Object > irb(main):004:0> 5.should == 5 > => nil > irb(main):005:0> 5.should be < 4 > Spec::Expectations::ExpectationNotMetError: expected < 4, got 5 > > $ script/console > Loading development environment. > >> require ''rubygems'' > => [] > >> require ''spec'' > NameError: undefined method `failure_message'' for class > `Spec::Matchers::Have'' > from /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/ > spec/matchers/have.rb:4:in `alias_method'' > from /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/ > spec/matchers/have.rb:4 > from /usr/local/lib/site_ruby/1.8/rubygems/ > custom_require.rb:27:in `gem_original_require'' >David - I haven''t seen a follow up to this post. Could you guide me on the right direction? I see that in irb I can include Spec::Mocks::SpecMethods, which allows me mock ''something''. How would I get access to mock_model? Scott -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071005/5b209a61/attachment.html
David Chelimsky
2007-Oct-05 16:46 UTC
[rspec-users] Caveman Questions - how to use mock_model in script/console?
On 10/5/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> > > On Sep 11, 2007, at 2:37 PM, Geoffrey Wiseman wrote: > On 9/5/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > irb(main):001:0> require ''rubygems'' > > => true > > irb(main):002:0> require ''spec'' > > => true > > irb(main):003:0> include Spec::Matchers > > => Object > > irb(main):004:0> 5.should == 5 > > => nil > > irb(main):005:0> 5.should be < 4 > > Spec::Expectations::ExpectationNotMetError: expected < 4, > got 5 > > > > $ script/console > Loading development environment. > >> require ''rubygems'' > => [] > >> require ''spec'' > NameError: undefined method `failure_message'' for class > `Spec::Matchers::Have'' > from > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4:in > `alias_method'' > from > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4 > from > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require'' > > > David - I haven''t seen a follow up to this post. Could you guide me on the > right direction? > > I see that in irb I can include Spec::Mocks::SpecMethods, which allows me > mock ''something''. How would I get access to mock_model?huh? I don''t see how the except you quoted relates to mock model> > Scott > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Oct-05 16:46 UTC
[rspec-users] Caveman Questions - how to use mock_model in script/console?
On 10/5/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 10/5/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: > > > > > > On Sep 11, 2007, at 2:37 PM, Geoffrey Wiseman wrote: > > On 9/5/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > > irb(main):001:0> require ''rubygems'' > > > => true > > > irb(main):002:0> require ''spec'' > > > => true > > > irb(main):003:0> include Spec::Matchers > > > => Object > > > irb(main):004:0> 5.should == 5 > > > => nil > > > irb(main):005:0> 5.should be < 4 > > > Spec::Expectations::ExpectationNotMetError: expected < 4, > > got 5 > > > > > > > $ script/console > > Loading development environment. > > >> require ''rubygems'' > > => [] > > >> require ''spec'' > > NameError: undefined method `failure_message'' for class > > `Spec::Matchers::Have'' > > from > > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4:in > > `alias_method'' > > from > > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4 > > from > > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_require'' > > > > > > David - I haven''t seen a follow up to this post. Could you guide me on the > > right direction? > > > > I see that in irb I can include Spec::Mocks::SpecMethods, which allows me > > mock ''something''. How would I get access to mock_model? > > huh? I don''t see how the except you quoted relates to mock modelnever mind gimme a few> > > > > Scott > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > >
David Chelimsky
2007-Oct-05 17:10 UTC
[rspec-users] Caveman Questions - how to use mock_model in script/console?
On 10/5/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 10/5/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > On 10/5/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: > > > > > > > > > On Sep 11, 2007, at 2:37 PM, Geoffrey Wiseman wrote: > > > On 9/5/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > > > irb(main):001:0> require ''rubygems'' > > > > => true > > > > irb(main):002:0> require ''spec'' > > > > => true > > > > irb(main):003:0> include Spec::Matchers > > > > => Object > > > > irb(main):004:0> 5.should == 5 > > > > => nil > > > > irb(main):005:0> 5.should be < 4 > > > > Spec::Expectations::ExpectationNotMetError: expected < 4, > > > got 5 > > > > > > > > > > $ script/console > > > Loading development environment. > > > >> require ''rubygems'' > > > => [] > > > >> require ''spec'' > > > NameError: undefined method `failure_message'' for class > > > `Spec::Matchers::Have'' > > > from > > > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4:in > > > `alias_method'' > > > from > > > /work/workspace/ng/vendor/plugins/rspec_on_rails/lib/spec/matchers/have.rb:4 > > > from > > > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > > > `gem_original_require'' > > > > > > > > > David - I haven''t seen a follow up to this post. Could you guide me on the > > > right direction? > > > > > > I see that in irb I can include Spec::Mocks::SpecMethods, which allows me > > > mock ''something''. How would I get access to mock_model? > > > > huh? I don''t see how the except you quoted relates to mock model > > never mind > > gimme a fewWell - I see what the error is coming from. When you say require ''spec'' in script/console it''s loading up files in vendor/rspec_on_rails before vendor/rspec. In this case, that''s causing an alias_method call to choke because there''s no method to alias. So the trick is going to be to coerce script/console into loading things in the right order.> > > > > > > > > Scott > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > >