Undefined method `inherit' for Merb::Test::ExampleGroup

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

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
TomK32 (Thomas R. Koll) · GitHub

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!

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

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

Pat M. 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-plays-nice-with-others

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?

On Mon, Feb 2, 2009 at 8:36 PM, Phlip [email protected] 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

On Mon, Feb 2, 2009 at 10:36 PM, Phlip [email protected] 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.

David C. wrote:

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

Tx that was it!