[rspec-users] Running specs for a plugin - undefined method 'define' for object

Jeff Dean jeff at jefdean.com
Wed Apr 25 11:24:50 EDT 2007


Thanks - I'll check my code more thoroughly next time before posting.

It still blows up with the fixtures declaration, though (even when using
context/specify) - am I missing an include file?

 ruby vendor/plugins/rspec/bin/spec
vendor/plugins/audit_fu/spec/audit_fu_spec.rb

/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in
`method_missing': undefined method `fixtures' for
#<Spec::DSL::EvalModule:0x215f8a4> (NoMethodError)
        from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in
`class_eval'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in
`initialize'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in
`new'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in
`create'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in
`context'
        from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in
`load'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in
`load_specs'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in
`each'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in
`load_specs'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in
`run'
        from
/Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in
`run'
        from vendor/plugins/rspec/bin/spec:3


On 4/25/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:
>
> It's describe, not define.
>
> Aslak
>
> On 4/25/07, Jeff Dean <jeff at jefdean.com> wrote:
> > I'm trying to write specs for a plugin I'm developing named audit_fu,
> and
> > I'm running into a problem which I can't get past it.   I've got the
> same
> > specs setup in the main rails app, and everything works fine there, it's
> > just running the plugin specs that I'm having a problem with.  My setup
> is:
> >
> >    - edge rails
> >    - edge rspec (in vendor/plugins/rspec)
> >    - edge rspec_on_rails (in vendor/plugins/rspec_on_rails)
> >    - I ran script/generate rspec
> >    - plugin created with rspec_plugin (using script/generate
> rspec_plugin
> >    audit_fu)
> >
> > File contents of:  vendor/plugins/audit_fu/spec/audit_fu_spec.rb
> >
> > require File.dirname(__FILE__) + '/spec_helper'
> > define "Widget" do
> >   fixtures :widgets
> >   it "should find all records" do
> >     Widget.count.should==4
> >   end
> > end
> >
> > File contents of: vendor/plugins/audit_fu/spec/spec_helper.rb
> >
> > require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
> > plugin_spec_dir = File.dirname(__FILE__)
> > ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log")
> > databases = YAML::load(IO.read(plugin_spec_dir + "/db/database.yml"))
> > ActiveRecord::Base.establish_connection(databases[ENV["DB"] ||
> "sqlite3"])
> > load(File.join(plugin_spec_dir, "db", "schema.rb"))
> >
> > The failing command:
> >
> > ruby vendor/plugins/rspec/bin/spec
> > vendor/plugins/audit_fu/spec/audit_fu_spec.rb
> > -- create_table(:widgets, {:force=>true})
> >    -> 0.0553s
> > -- create_table(:gears, {:force=>true})
> >    -> 0.0073s
> > -- initialize_schema_information()
> >    -> 0.0006s
> > -- columns("schema_info")
> >    -> 0.0005s
> > ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3: undefined method
> `define'
> > for #<Object:0x1f69f4> (NoMethodError)
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in
> > `load'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in
> > `load_specs'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in
> > `each'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in
> > `load_specs'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in
> > `run'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in
> > `run'
> >         from vendor/plugins/rspec/bin/spec:3
> >
> > If I change define/it to context/specify, it gets a little further, but
> > blows up when it hits the fixtures definition:
> >
> >  ruby vendor/plugins/rspec/bin/spec
> > vendor/plugins/audit_fu/spec/audit_fu_spec.rb
> > -- create_table(:widgets, {:force=>true})
> >    -> 0.0407s
> > -- create_table(:gears, {:force=>true})
> >    -> 0.0074s
> > -- initialize_schema_information()
> >    -> 0.0005s
> > -- columns("schema_info")
> >    -> 0.0005s
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:62:in
> > `method_missing': undefined method `fixtures' for
> > #<Spec::DSL::EvalModule:0x215f8a4> (NoMethodError)
> >         from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:4
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in
> > `class_eval'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:26:in
> > `initialize'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in
> > `new'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour_factory.rb:38:in
> > `create'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/kernel.rb:4:in
> > `context'
> >         from ./vendor/plugins/audit_fu/spec/audit_fu_spec.rb:3
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in
> > `load'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:85:in
> > `load_specs'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in
> > `each'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:84:in
> > `load_specs'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:22:in
> > `run'
> >         from
> >
> /Users/jeff/Sites/niche/audit_fu/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in
> > `run'
> >         from vendor/plugins/rspec/bin/spec:3
> >
> > I think I'm missing an include or require somewhere - can anyone see
> what
> > I'm missing or what I've done wrong?  Thanks for your help - Jeff
> >
> _______________________________________________
> 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/20070425/2892a16d/attachment-0001.html 


More information about the rspec-users mailing list