Rspec is all about using natural language to define behavior. In this context, I feel that lambda is sorely out of place. I was chatting on #irc and a pal of mine (wycats) proposed an interesting alternative: alias_method :doing, :lambda so instead of something like lambda {post :create, {:title => nil}}.should raise_error(ActiveRecord::RecordInvalid) we get doing {post :create, {:title => nil}}.should raise_error(ActiveRecord::RecordInvalid) Now it reads like a sentence..much cleaner and less abstract to those of us who are not Ruby wizards (yet) Chatting with other folks and they are hyped on the idea. What do you guys think? Any chance we could get something like this into trunk? -- Posted via http://www.ruby-forum.com/.
On Nov 18, 2007 12:40 AM, Steven Garcia <lists at ruby-forum.com> wrote:> Rspec is all about using natural language to define behavior. In this > context, I feel that lambda is sorely out of place. I was chatting on > #irc and a pal of mine (wycats) proposed an interesting alternative: > > alias_method :doing, :lambda > > so instead of something like > > lambda {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > we get > > doing {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > Now it reads like a sentence..much cleaner and less abstract to those of > us who are not Ruby wizards (yet) > > Chatting with other folks and they are hyped on the idea. > > What do you guys think? > > Any chance we could get something like this into trunk?Probably not. There was a longer discussion of it here: http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 As you point out, creating an alias is a one-liner. The main reason I don''t want to add it is that lambda is a common idiom, and I don''t want to set precedence of aliasing core Ruby idioms just because some people don''t like the ones in Ruby. Aslak> -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Nov 17, 2007 5:40 PM, Steven Garcia <lists at ruby-forum.com> wrote:> Rspec is all about using natural language to define behavior. In this > context, I feel that lambda is sorely out of place. I was chatting on > #irc and a pal of mine (wycats) proposed an interesting alternative: > > alias_method :doing, :lambda > > so instead of something like > > lambda {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > we get > > doing {post :create, {:title => nil}}.should > raise_error(ActiveRecord::RecordInvalid) > > Now it reads like a sentence..much cleaner and less abstract to those of > us who are not Ruby wizards (yet) > > Chatting with other folks and they are hyped on the idea. > > What do you guys think? > > Any chance we could get something like this into trunk?We''ve been through this a few times on this list. There''s a fundamental difference between replacing "assert_equal" with "should equal" and replacing lambda with anything at all. assert_equal is a method that a Ruby programmer wrote into a library. lambda is part of the Ruby language. We''re still writing Ruby here, aren''t we? Of course, you''re free to alias whatever you like in your own projects. We''re still writing Ruby here, aren''t we!!! Cheers, David> -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Nov 17, 2007 5:59 PM, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:> On Nov 18, 2007 12:40 AM, Steven Garcia <lists at ruby-forum.com> wrote: > > Rspec is all about using natural language to define behavior. In this > > context, I feel that lambda is sorely out of place. I was chatting on > > #irc and a pal of mine (wycats) proposed an interesting alternative: > > > > alias_method :doing, :lambda > > > > so instead of something like > > > > lambda {post :create, {:title => nil}}.should > > raise_error(ActiveRecord::RecordInvalid) > > > > we get > > > > doing {post :create, {:title => nil}}.should > > raise_error(ActiveRecord::RecordInvalid) > > > > Now it reads like a sentence..much cleaner and less abstract to those of > > us who are not Ruby wizards (yet) > > > > Chatting with other folks and they are hyped on the idea. > > > > What do you guys think? > > > > Any chance we could get something like this into trunk? > > Probably not. There was a longer discussion of it here: > http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 > > As you point out, creating an alias is a one-liner. > The main reason I don''t want to add it is that lambda is a common > idiom, and I don''t want to set precedence of aliasing core Ruby idioms > just because some people don''t like the ones in Ruby.+1 David> > Aslak > > > -- > > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Nov 17, 2007, at 6:59 PM, aslak hellesoy wrote:> On Nov 18, 2007 12:40 AM, Steven Garcia <lists at ruby-forum.com> wrote: >> Rspec is all about using natural language to define behavior. In this >> context, I feel that lambda is sorely out of place. I was chatting on >> #irc and a pal of mine (wycats) proposed an interesting alternative: >> >> alias_method :doing, :lambda >> >> so instead of something like >> >> lambda {post :create, {:title => nil}}.should >> raise_error(ActiveRecord::RecordInvalid) >> >> we get >> >> doing {post :create, {:title => nil}}.should >> raise_error(ActiveRecord::RecordInvalid) >> >> Now it reads like a sentence..much cleaner and less abstract to >> those of >> us who are not Ruby wizards (yet) >> >> Chatting with other folks and they are hyped on the idea. >> >> What do you guys think? >> >> Any chance we could get something like this into trunk? > > Probably not. There was a longer discussion of it here: > http://rubyforge.org/tracker/index.php? > func=detail&aid=13837&group_id=797&atid=3152 > > As you point out, creating an alias is a one-liner. > The main reason I don''t want to add it is that lambda is a common > idiom, and I don''t want to set precedence of aliasing core Ruby idioms > just because some people don''t like the ones in Ruby. >Couldn''t agree more with the reasoning (as per the last time). One thing that has been circulating around my mind is an aliasing "it" with "he", which makes a lot of sense when you write specs from a User''s perspective: describe "A", User do he "should receiving an extra 2 dollars when he passes go" end Anyway - would it be reasonable for this to go into rspec core? It seems too specific to *my* needs, and not central enough to specs in general. Plus, if this were added, should "she" also be added? Just another thing - I''ve never understood why so many find lambda to be an unusual construction - a block *is* a lambda, and it *is* a Proc (more or less), and those are used everywhere in the language. Scott
On 18/11/2007, at 1:01 PM, David Chelimsky wrote:> We''re still writing Ruby here, aren''t we!!! > > Cheers, > David > >Wanted to share my initial reaction to your Ruby statement. Are we writing Ruby here? Or are we writing specifications? Are we not using the power of the Ruby language to construct a DSL that allows us to construct specifications about the behaviour of our code? Wouldn''t the ideal be that I could create Behaviour specifications using RSpec or JSpec or CSpec (or whatever) using language that is natural to writing specifications? So something like lambda ... which is a word I always have trouble typing ;-) ... would not seem natural to the domain of BDD? These were just my initial thoughts :-) On the actual implementation side ... if I really wanted doing in my specs I would add the one line and not really care too much that this is what I need to do. Cheers Shane
El 18/11/2007, a las 0:59, aslak.hellesoy at gmail.com escribi?:> Probably not. There was a longer discussion of it here: > http://rubyforge.org/tracker/index.php?func=detail&aid=13837&group_id=797&atid=3152 > > As you point out, creating an alias is a one-liner. > The main reason I don''t want to add it is that lambda is a common > idiom, and I don''t want to set precedence of aliasing core Ruby idioms > just because some people don''t like the ones in Ruby.<devil''s advocate> But it could be argued that RSpec is a Domain Specific Language of its own, and it''s not Ruby; it just happens to be implemented in Ruby. </devil''s advocate> Having said that, I''m fine with using "lambda" and even if I wasn''t adding an alias to my spec_helper.rb would be no problem if I felt strongly about it. Cheers, Wincent
# for readability alias :running :lambda Q.E.D. On Nov 18, 2007, at 2:07 PM, Shane Mingins wrote:> > On 18/11/2007, at 1:01 PM, David Chelimsky wrote: >> We''re still writing Ruby here, aren''t we!!! >> >> Cheers, >> David >> >> > > > Wanted to share my initial reaction to your Ruby statement. > > Are we writing Ruby here? Or are we writing specifications? Are we > not using the power of the Ruby language to construct a DSL that > allows us to construct specifications about the behaviour of our code? > > Wouldn''t the ideal be that I could create Behaviour specifications > using RSpec or JSpec or CSpec (or whatever) using language that is > natural to writing specifications? So something like lambda ... > which is a word I always have trouble typing ;-) ... would not seem > natural to the domain of BDD? > > These were just my initial thoughts :-) > > On the actual implementation side ... if I really wanted doing in my > specs I would add the one line and not really care too much that this > is what I need to do. > > Cheers > Shane > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users