I''ve come across an interesting blog post showing how to inherit tests: http://benbiddington.wordpress.com/2010/11/06/rspec-common-base-specs/ How does it stack against the usual mixing/shared_examples_for, beautifully described in http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shared-example-groups-in-rspec-2/ I.e., what are the cases where you''d do inheritance vs shared_examples_for? Cheers, Alexy
On Sat, Aug 20, 2011 at 7:53 PM, braver <deliverable at gmail.com> wrote:> I''ve come across an interesting blog post showing how to inherit > tests: > > http://benbiddington.wordpress.com/2010/11/06/rspec-common-base-specs/ > > How does it stack against the usual mixing/shared_examples_for, > beautifully described in > > > http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shared-example-groups-in-rspec-2/ > > I.e., what are the cases where you''d do inheritance vs > shared_examples_for? > > Cheers, > Alexy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >I see no use case for class inheritance in RSpec. If you need to include some methods in a spec, use the `include` config option: module MySpecMethods def foo end end RSpec.configure do |config| config.include MySpecMethods # to restrict to controllers, for example config.include MySpecMethods, :type => :controller end -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110822/a9ebe151/attachment.html>
Alexy Khrabrov
2011-Aug-23 01:33 UTC
[rspec-users] inheriting test cases vs. mixing them in
I''ve come across an interesting blog post showing how to inherit tests: http://benbiddington.wordpress.com/2010/11/06/rspec-common-base-specs/ How does it stack against the usual mixing/shared_examples_for, beautifully described in http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shared-example-groups-in-rspec-2/ I.e., what are the cases where you''d do inheritance vs. the usual shared_examples_for? Cheers, Alexy