Describe, context, feature, scenario: what is the difference between the four and when do I use each one? thanks, mike -- Posted via http://www.ruby-forum.com/.
On 16 Jul 2012, at 02:28, Mike Glaz wrote:> Describe, context, feature, scenario: what is the difference between the > four and when do I use each one?Feature and Scenario are Cucumber keywords and AFAIK have nothing to do with RSpec. #describe and #context are both aliases for the same method which creates a new (anonymous) subclass of RSpec::ExampleGroup. This is essentially the same thing as sublcassing Test::Unit::TestCase as you would in a bog standard test-unit test. So #describe and #context do the same thing. I tend to use #describe on the top level (what is the thing I''m describing in this spec), then use #context inside that to explain the different hoops I''m making that thing jump through in my examples. cheers, Matt -- Freelance programmer & coach Author, http://pragprog.com/book/hwcuc/the-cucumber-book Founder, http://www.relishapp.com/ Twitter, https://twitter.com/mattwynne -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120716/ff76dd0b/attachment.html>
On Jul 15, 2012, at 7:28 PM, Mike Glaz wrote:> Describe, context, feature, scenario: what is the difference between the > four and when do I use each one? > > thanks, > mike > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users#feature & #scenario come from the "steak" gem or maybe the Capybara RSpec API (if it still exists). They do not exist in RSpec. I use #context to "setup" different paths/scenarios of what I''m _describing_. Here is an example: describe Dog do describe ''#beg'' do context ''presented with a slice of steak'' do it ''puts its chin on the floor'' do end end context ''presented with a carrot'' do it ''does nothing'' do end end end end Always start off (top level) with #describe
Feature and scenario are aliases defined by capybara. On Jul 16, 2012 5:50 AM, "Matt Wynne" <matt at mattwynne.net> wrote:> > On 16 Jul 2012, at 02:28, Mike Glaz wrote: > > Describe, context, feature, scenario: what is the difference between the > four and when do I use each one? > > > Feature and Scenario are Cucumber keywords and AFAIK have nothing to do > with RSpec. > > #describe and #context are both aliases for the same method which creates > a new (anonymous) subclass of RSpec::ExampleGroup. This is essentially the > same thing as sublcassing Test::Unit::TestCase as you would in a bog > standard test-unit test. > > So #describe and #context do the same thing. I tend to use #describe on > the top level (what is the thing I''m describing in this spec), then use > #context inside that to explain the different hoops I''m making that thing > jump through in my examples. > > cheers, > Matt > > -- > Freelance programmer & coach > Author, http://pragprog.com/book/hwcuc/the-cucumber-book > Founder, http://www.relishapp.com/ > Twitter, https://twitter.com/mattwynne > > > > _______________________________________________ > 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/20120716/a171da58/attachment.html>
On Sun, Jul 15, 2012 at 6:28 PM, Mike Glaz <lists at ruby-forum.com> wrote:> Describe, context, feature, scenario: what is the difference between the > four and when do I use each one? >Hi Mike, We''ve been writing tests a lot over the past year, and one of our devs wrote up some details about the now preferred RSpec DSL. It skims over the top of your question, and I hope it provides you with some high level concepts: http://twitchtv.github.com/blog/2012/07/04/rspec-tech-talk/> > thanks, > mike > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > 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/20120717/40449a86/attachment.html>