before I hack up a patch for it. Would a patch to change "expected Fixnum to be a kind of Fixnum" to "expected Fixnum to be a kind of Fixnum (is a Class)" or possibly "expected Fixnum to be a kind of Fixnum (is a Class, Module, Object, Kernel, BasicObject)" have any chance of being accepted? Thanks. -r
On Wed, Dec 30, 2009 at 1:33 PM, rogerdpack <rogerpack2005 at gmail.com> wrote:> before I hack up a patch for it. Would a patch to change > > "expected Fixnum to be a kind of Fixnum" > > to > > "expected Fixnum to be a kind of Fixnum (is a Class)" > > or possibly > > "expected Fixnum to be a kind of Fixnum (is a Class, Module, Object, > Kernel, BasicObject)" > > > have any chance of being accepted? >Probably not with that exact wording, but if you feel the message is not telling you what you need to know, I''m open to other ideas. What about something like: expected #<Class:2158174640> => Fixnum to be a kind of Fixnum That is more aligned with other failure messages. WDYT?> Thanks. > -r >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20091230/4ce1acc0/attachment.html>
On 30 Dec 2009, at 20:19, David Chelimsky wrote:> What about something like: > > expected #<Class:2158174640> => Fixnum to be a kind of Fixnum > > That is more aligned with other failure messages. WDYT?I like that. You have to read the current message _very_ carefully to see what it''s actually saying. Thinking about it though, isn''t the current format wrong anyway? "Fixnum is the kind of 1" sounds (torturously) correct. For want of ability to say what I mean in terms of types, here are examples instead: Integer is a kind of Object* Object.new is an (instance of) Object Integer is a(n instance of) Class Fixnum is a kind of Integer 1 is a(n instance of) Fixnum Gets a bit harder with modules though: [] is an (instance of) a Class that includes Enumerable [] is Enumerable (second one only works if the module name is an adjective) * Actually, this satisfies both definitions, as Integer is an instance Class, which is an Object... And just out of curiosity, Roger, what''s your use case? I can''t remember ever using be_a/be_an, at least not in any code that has survived. Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran
> What about something like: > > ? expected #<Class:2158174640> => Fixnum to be a kind of Fixnum > > That is more aligned with other failure messages. WDYT?I quite like it. In this instance it was 3.class.should be_a Fixnum # fails I suppose it would be something like expected #<Class:Fixnum> => Class to be a kind of Fixnum ?> And just out of curiosity, Roger, what''s your use case? I can''t remember ever using be_a/be_an, at least not in any code that has survived.The very first test I thought up was "this method should return an integer" so kind of a basic test for a not yet existent method. -r
2009/12/30 rogerdpack <rogerpack2005 at gmail.com>> > What about something like: > > > > expected #<Class:2158174640> => Fixnum to be a kind of Fixnum > > > > That is more aligned with other failure messages. WDYT? > > I quite like it. > In this instance it was > > 3.class.should be_a Fixnum # fails > > I suppose it would be something like > expected #<Class:Fixnum> => Class to be a kind of Fixnum > > ? > > > And just out of curiosity, Roger, what''s your use case? I can''t remember > ever using be_a/be_an, at least not in any code that has survived. > > The very first test I thought up was "this method should return an > integer" so kind of a basic test for a not yet existent method. > >Isn''t this a bit anti-ruby though. Surely the things we should be testing is that the object exists, responds to certain messages and gives certain values back for those messages. Thinking about types is so Java, C++ :-) all best Andrew> -r > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100102/2eb6f52b/attachment.html>
On Sat, Jan 2, 2010 at 3:23 PM, Andrew Premdas <apremdas at gmail.com> wrote:> 2009/12/30 rogerdpack <rogerpack2005 at gmail.com> > > > What about something like: >> > >> > expected #<Class:2158174640> => Fixnum to be a kind of Fixnum >> > >> > That is more aligned with other failure messages. WDYT? >> >> I quite like it. >> In this instance it was >> >> 3.class.should be_a Fixnum # fails >> >> I suppose it would be something like >> expected #<Class:Fixnum> => Class to be a kind of Fixnum >> >> ? >> >> > And just out of curiosity, Roger, what''s your use case? I can''t >> remember ever using be_a/be_an, at least not in any code that has survived. >> >> The very first test I thought up was "this method should return an >> integer" so kind of a basic test for a not yet existent method. >> >> > Isn''t this a bit anti-ruby though. Surely the things we should be testing > is that the object exists, responds to certain messages and gives certain > values back for those messages. Thinking about types is so Java, C++ :-) >Generally speaking, you''re correct, but there are cases where this is valuable - like if you''re spec''ing a factory in a lib for others to use, etc.> > > all best > > Andrew > >> -r >> _______________________________________________ >> 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100102/407cb1c7/attachment-0001.html>
On Sat, Jan 2, 2010 at 4:35 PM, David Chelimsky <dchelimsky at gmail.com> wrote:> > > On Sat, Jan 2, 2010 at 3:23 PM, Andrew Premdas <apremdas at gmail.com> wrote: >> >> 2009/12/30 rogerdpack <rogerpack2005 at gmail.com> >>> >>> > What about something like: >>> > >>> > ? expected #<Class:2158174640> => Fixnum to be a kind of Fixnum >>> > >>> > That is more aligned with other failure messages. WDYT? >>> >>> I quite like it. >>> In this instance it was >>> >>> 3.class.should be_a Fixnum # fails >>> >>> I suppose it would be something like >>> expected #<Class:Fixnum> => Class to be a kind of Fixnum >>> >>> ? >>> >>> > And just out of curiosity, Roger, what''s your use case? ?I can''t >>> > remember ever using be_a/be_an, at least not in any code that has survived. >>> >>> The very first test I thought up was "this method should return an >>> integer" so kind of a basic test for a not yet existent method. >>> >> >> Isn''t this a bit anti-ruby though. Surely the things we should be testing >> is that the object exists, responds to certain messages and gives certain >> values back for those messages. Thinking about types is so Java, C++ :-) > > Generally speaking, you''re correct, but there are cases where this is > valuable - like if you''re spec''ing a factory in a lib for others to use, > etc.However, I need to point out that although 1.should be_a Fixnum that 1.class.should_not be_a Fixnum because 1.class == Fixnum which is after all a Class, and not a Fixnum itself. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale
On Sat, Jan 2, 2010 at 4:50 PM, Rick DeNatale <rick.denatale at gmail.com>wrote:> On Sat, Jan 2, 2010 at 4:35 PM, David Chelimsky <dchelimsky at gmail.com> > wrote: > > > > > > On Sat, Jan 2, 2010 at 3:23 PM, Andrew Premdas <apremdas at gmail.com> > wrote: > >> > >> 2009/12/30 rogerdpack <rogerpack2005 at gmail.com> > >>> > >>> > What about something like: > >>> > > >>> > expected #<Class:2158174640> => Fixnum to be a kind of Fixnum > >>> > > >>> > That is more aligned with other failure messages. WDYT? > >>> > >>> I quite like it. > >>> In this instance it was > >>> > >>> 3.class.should be_a Fixnum # fails > >>> > >>> I suppose it would be something like > >>> expected #<Class:Fixnum> => Class to be a kind of Fixnum > >>> > >>> ? > >>> > >>> > And just out of curiosity, Roger, what''s your use case? I can''t > >>> > remember ever using be_a/be_an, at least not in any code that has > survived. > >>> > >>> The very first test I thought up was "this method should return an > >>> integer" so kind of a basic test for a not yet existent method. > >>> > >> > >> Isn''t this a bit anti-ruby though. Surely the things we should be > testing > >> is that the object exists, responds to certain messages and gives > certain > >> values back for those messages. Thinking about types is so Java, C++ :-) > > > > Generally speaking, you''re correct, but there are cases where this is > > valuable - like if you''re spec''ing a factory in a lib for others to use, > > etc. > > However, I need to point out that > > although > > 1.should be_a Fixnum > > that > > 1.class.should_not be_a Fixnum > > because > > 1.class == Fixnum which is after all a Class, and not a Fixnum itself. >Right - the initial problem that Roger was reporting was that "1.class.should be_a(Fixnum)" produced a failure message wasn''t that helpful, not that it failed to fail :) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100102/82359dd9/attachment.html>
> > The very first test I thought up was "this method should return an > > integer" so kind of a basic test for a not yet existent method. > > Isn''t this a bit anti-ruby though. Surely the things we should be testing is > that the object exists, responds to certain messages and gives certain > values back for those messages. Thinking about types is so Java, C++ :-)Yeah, though it''s a bit hard when it''s supposed to return the pid of some external process :) -r
2010/1/3 rogerdpack <rogerdpack at gmail.com>> > > The very first test I thought up was "this method should return an > > > integer" so kind of a basic test for a not yet existent method. > > > > Isn''t this a bit anti-ruby though. Surely the things we should be testing > is > > that the object exists, responds to certain messages and gives certain > > values back for those messages. Thinking about types is so Java, C++ :-) > > Yeah, though it''s a bit hard when it''s supposed to return the pid of > some external process :) > >Well your pid could be a string or an integer, or even some a bizarre proprietary un-docomented PID construct from planet foo . But as far as Ruby is concerned you''ll be getting back an object thats for sure, and anything else is completely up in the air. However as soon as you start specifying that a Fixnum should be returned, then you''ve removed the possibility of receiving a string or a bizarre proprietary un-docomented PID construct from planet foo. This is very anti-ruby (its a dynamic language). And it means that your method will have to do all sorts of type conversion rubbish to go from String, ''construct to Fixnum to pass your test. In ruby all your interested in is that you get something that responds to to_s (to_i) and gives you a suitable value -r> _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100103/4c3fb91a/attachment.html>
2010/1/2 David Chelimsky <dchelimsky at gmail.com>> > > On Sat, Jan 2, 2010 at 3:23 PM, Andrew Premdas <apremdas at gmail.com> wrote: > >> 2009/12/30 rogerdpack <rogerpack2005 at gmail.com> >> >> > What about something like: >>> > >>> > expected #<Class:2158174640> => Fixnum to be a kind of Fixnum >>> > >>> > That is more aligned with other failure messages. WDYT? >>> >>> I quite like it. >>> In this instance it was >>> >>> 3.class.should be_a Fixnum # fails >>> >>> I suppose it would be something like >>> expected #<Class:Fixnum> => Class to be a kind of Fixnum >>> >>> ? >>> >>> > And just out of curiosity, Roger, what''s your use case? I can''t >>> remember ever using be_a/be_an, at least not in any code that has survived. >>> >>> The very first test I thought up was "this method should return an >>> integer" so kind of a basic test for a not yet existent method. >>> >>> >> Isn''t this a bit anti-ruby though. Surely the things we should be testing >> is that the object exists, responds to certain messages and gives certain >> values back for those messages. Thinking about types is so Java, C++ :-) >> > > Generally speaking, you''re correct, but there are cases where this is > valuable - like if you''re spec''ing a factory in a lib for others to use, > etc. > >I don''t think those cases apply to this thread (judging from its context), but I can see benefits from the improved error message that may result from this discussion. Andrew> >> >> all best >> >> Andrew >> >>> -r >>> _______________________________________________ >>> 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 >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100103/dc72d456/attachment-0001.html>
> What about something like: > > ? expected #<Class:2158174640> => Fixnum to be a kind of FixnumStill in favor of something like this... :) -rp
On Sat, Jan 9, 2010 at 1:33 PM, rogerdpack <rogerpack2005 at gmail.com> wrote:> >> What about something like: >> >> ? expected #<Class:2158174640> => Fixnum to be a kind of FixnumTruthfully, I find this much less clear than the original message. I''ve got no idea what #<Class:2158174640> => Fixnum means. Expected Fixnum to be kind of Fixnum makes a lot of sense to me because I know that x.kind_of? Y means that x is an INSTANCE of Y or one of it''s subclasses, and Fixnum is not a Fixnum but a class. Pondering this if you don''t know that should lead to doing a little reading and then realizing that you probably wanted 1.should be_a FixNum instead of 1.class.should be_a Fixnum -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale