John Kolokotronis
2009-Aug-11 12:51 UTC
[rspec-users] How do you get example full description in Rspec 1.2.x?
Hi All, I''ve been using Rspec 1.1.8 for some time now and even though I am not sure I''m doing this the best way possible, it allowed to get a full description block of a nested example but Rspec 1.2.8 does not seem to have the method I was using (__full_description). My example groups would look like this: describe "My test suite" do after(:each) puts self.__full description end describe "00001: My first test" do it "should do something" do # some code goes here end end end With Rspec 1.1.8 (or lower), the __full_description method will give me something like "My test suite 00001: My first test should do something" which is exactly what I want. However, with Rspec 1.2.8, there is no such method. If I use self.description, I only get what is in the it block, as expected. How can I access a full description string of a nested example like __full_description used to do? Can I also access an example description in the after(:each) block without referring to the self object? Thanks in advance. Regards, John
David Chelimsky
2009-Aug-11 14:04 UTC
[rspec-users] How do you get example full description in Rspec 1.2.x?
On Tue, Aug 11, 2009 at 8:51 AM, John Kolokotronis<johnjkle at gmail.com> wrote:> Hi All, > > I''ve been using Rspec 1.1.8 for some time now and even though I am not > sure I''m doing this the best way possible, it allowed to get a full > description block of a nested example but Rspec 1.2.8 does not seem to > have the method I was using (__full_description).By convention, anything prefixed with a "_" is not part of the public API and subject to change.> My example groups > would look like this: > > describe "My test suite" do > ?after(:each) > ? ?puts self.__full description > ?end > > ?describe "00001: My first test" do > ? ?it "should do something" do > ? ? ?# some code goes here > ? ?end > ?end > end > > With Rspec 1.1.8 (or lower), the __full_description method will give > me something like "My test suite 00001: My first test should do > something" which is exactly what I want. > > However, with Rspec 1.2.8, there is no such method. If I use > self.description, I only get what is in the it block, as expected. > > How can I access a full description string of a nested example like > __full_description used to do? Can I also access an example > description in the after(:each) block without referring to the self > object? Thanks in advance.There is no full_description method right now, but it''s dead simple: def full_description "#{self.class.description} #{description}" end Feel free to file a ticket for this at http://rspec.lighthouseapp.com Cheers, David> Regards, > > John > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
John Kolokotronis
2009-Aug-13 14:07 UTC
[rspec-users] How do you get example full description in Rspec 1.2.x?
Thanks David, I didn''t realize it was so easy to add the method back in (class.description never occurred to me) so including it in my spec_helper file sorts my problem for now and I can use Rspec 1.2.8. I''ve logged a ticket as requested: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/873-rspec-12x-does-not-contain-__full_description-method Thanks again for the quick reply. Regards, John