Forum: RSpec undefined method `inherit' for Merb::Test::ExampleGroup

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-01 19:26
(Received via mailing list)
RSpeckers:

I'm trying to install this into a Merb-generated RSpec rig:

   http://code.jeremyevans.net/doc/fixture_dependencies/

It requires inserting their test case into RSpec. This is the documented
way to
do it:

describe 'Post' do
   inherit FixtureDependencies::SequelTestCase

And that leads to the syntax error in the subject line. (No stack trace
is
available - ask the Merb spec runner why!)

Has anyone seen that one before?

--
   Phlip
978ed7ca309d5495078702096f9add03?d=identicon&s=25 Thomas r. Koll (tomk32)
on 2009-02-01 20:09
(Received via mailing list)
Hi Phlip,

Are you sure it's inherit and not extend?
Second, I guess the missing trace is cuz you should
put a 'before' block into the describe.
Took me some time to figure that out last month...

so try this and let us know the results:

describe 'Post' do
   before do
     extend FixtureDependencies::SequelTestCase
   end
end

ciao, tom


Am 01.02.2009 um 16:50 schrieb Phlip:

>  inherit FixtureDependencies::SequelTestCase
>
> And that leads to the syntax error in the subject line. (No stack
> trace is available - ask the Merb spec runner why!)
>
> Has anyone seen that one before?


--
Thomas R. "TomK32" Koll <> http://ananasblau.com
just a geek trying to change the world
http://github.com/TomK32
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-01 22:11
(Received via mailing list)
Thomas R. Koll wrote:

> Are you sure it's inherit and not extend?

Per the blogs, inherit() got invented to install Test::Unit::TestCase,
to get
its extra goodies. That's a class, so you can't extend or import it!

Were those blog entries since redacted?

> Second, I guess the missing trace is cuz you should
> put a 'before' block into the describe.

Huh? The trace is just missing; test runners should propagate it.

> describe 'Post' do
>   before do
>     extend FixtureDependencies::SequelTestCase
>   end
> end

Here's the relevant bits that don't work. (I changed the goal library to
the
'assert2' patched into Test::Unit::Assertions.)

require File.join( File.dirname(__FILE__), '..', "spec_helper" )
require 'test/unit'
require 'assert2'


describe 'Post' do

   before do
     include Test::Unit::TestCase
      # inherit Test::Unit::TestCase # does not compile
      # include Test::Unit::Assertions # does not import assert{}
   end

   it 'should have fixtures' do
     posts = posts(:Joan_Crawford_Has_Risen, :Jammin, :Sardonicus,
:Lithium)
     posts[0].body.should == 'From the Grave'
     posts[0].tags.should include(tags(:progressive))

  # this line never compiles
     assert{ posts[0].tags.include? tags(:rocksteady) }
   end

end

The rspec-rails plugin sure has me spoiled, huh? I formerly thought
Test::Unit::Assertions would be automatically available, even without
Rails
around...

--
   Phlip
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-03 03:56
(Received via mailing list)
I have to bump this one because it looks like it's on RSpec's core
feature list,
and I reeally need a fix for it.

Feel free to blame Merb, if they munged the inherit() method somehow!
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2009-02-03 05:17
(Received via mailing list)
I'll blame Merb on the basis that there is no "inherit" in RSpec.  I'm
guessing it's some kind of merb extension.

Pat
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-03 05:43
(Received via mailing list)
Pat Maddox wrote:

> I'll blame Merb on the basis that there is no "inherit" in RSpec.  I'm
> guessing it's some kind of merb extension.

http://blog.davidchelimsky.net/2007/4/1/rspec-play...

I know I know - time flies!

If it has been superseded, then how do you inject a batch of assertions
defined
in someone else's class into RSpec?

For example, how does RSpec on Rails import its ActiveSupport::TestCase
assertions?
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2009-02-03 06:36
(Received via mailing list)
On Mon, Feb 2, 2009 at 8:36 PM, Phlip <phlip2005@gmail.com> wrote:
> defined in someone else's class into RSpec?
>
> For example, how does RSpec on Rails import its ActiveSupport::TestCase
> assertions?

rspec-rails defines Spec::Rails::Example::RailsExampleGroup that
inherits from ActiveSupport::TestCase.  All other example groups are
subclasses of REG.

What you want to do is something along the lines of:

class SequelExampleGroup < FixtureDependencies::SequelTestCase
  extend Spec::Example::ExampleGroupMethods
  include Spec::Example::ExampleMethods
  # also any other modules that contain merb-specific expectations
  Spec::Example::ExampleGroupFactory.register :sequel, self
end

describe 'Post', :type => :sequel do
  ...
end

(I don't know that that's exactly it, but it should get you going)

I think that forcing you to inherit from
FixtureDependencies::SequelTestCase is pretty sucky and I'm not sure
why they don't just have some modules that you could mix in in the
Spec::Runner.configure block.

Pat
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-02-03 06:38
(Received via mailing list)
On Mon, Feb 2, 2009 at 10:36 PM, Phlip <phlip2005@gmail.com> wrote:
> defined in someone else's class into RSpec?
module MyMethods
  # define matchers
end

Spec::Runner.configure do |c|
  c.include MyMethods
end

That will include the module in every example group, regardless of the
base class.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-03 15:26
(Received via mailing list)
David Chelimsky wrote:

> Spec::Runner.configure do |c|
>   c.include MyMethods
> end

Tx that was it!
This topic is locked and can not be replied to.