Jeff Dean
2007-Apr-25 07:16 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070425/1fc7e610/attachment-0001.html
aslak hellesoy
2007-Apr-25 08:34 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
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 >
Matthijs Langenberg
2007-Apr-25 10:05 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
Is it actually possible to run the specifications written for a plugin without having much hassle in setting up a rails application? The one thing holding me back writing specs for plugins (with generators) is the fact that I need to 1) make a change in my generated spec, 2) change the code to let the spec pass, 3) Change the generator so they generate the new spec / code, 4) Use the generator in a new rails application, 5) Run all specs. This is so much hassle that It''s really tempting to just let the tests be. (which is ofcourse very wrong). 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 >
aslak hellesoy
2007-Apr-25 10:50 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
On 4/25/07, Matthijs Langenberg <mlangenberg at gmail.com> wrote:> Is it actually possible to run the specifications written for a plugin > without having much hassle in setting up a rails application? >It depends on how well decoupled your own code is from Rails. If you decouple it completely you don''t need Rails.> The one thing holding me back writing specs for plugins (with > generators) is the fact that I need to 1) make a change in my > generated spec, 2) change the code to let the spec pass, 3) Change the > generator so they generate the new spec / code, 4) Use the generator > in a new rails application, 5) Run all specs. > > This is so much hassle that It''s really tempting to just let the tests > be. (which is ofcourse very wrong). >If you''re thinking specifically about writing specs for generators, then I agree this is hard. If you dig in the Spec::Rails code you can see how we did it for the rspec generator. P.S. Your post seems unrelated to the original post. Please create a new mail (instead of replying to an existing thread) unless your mail is relevant to the one you''re replying to. Aslak> 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 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Jeff Dean
2007-Apr-25 15:24 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
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
aslak hellesoy
2007-Apr-25 21:06 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
I don''t know if this is the source of your problem - I haven''t investigated it, but I see that your spec is not in a sub folder (spec/models, spec/controllers etc.) what happens if you move your spec down to say, spec/models (and adjust your require to spec_helper.rb - does it still behave the same? A second thing - have you run ruby script/generate rspec lately? There might be some recent changes in the generated spec_helper.rb that your current copy (which was generated - perhaps a while ago) is out of date with. Aslak On 4/25/07, Jeff Dean <jeff at jefdean.com> wrote:> 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 > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Jeff Dean
2007-Apr-26 01:20 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
aslak - you rock. I put the spec in a models directory and it worked like a charm. Thanks again. On 4/25/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:> > I don''t know if this is the source of your problem - I haven''t > investigated it, but I see that your spec is not in a sub folder > (spec/models, spec/controllers etc.) > > what happens if you move your spec down to say, spec/models (and > adjust your require to spec_helper.rb - does it still behave the same? > > A second thing - have you run ruby script/generate rspec lately? There > might be some recent changes in the generated spec_helper.rb that your > current copy (which was generated - perhaps a while ago) is out of > date with. > > Aslak > > On 4/25/07, Jeff Dean <jeff at jefdean.com> wrote: > > 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 > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > 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/2a176520/attachment-0001.html
David Chelimsky
2007-Apr-26 02:16 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
On 4/25/07, Jeff Dean <jeff at jefdean.com> wrote:> aslak - you rock. > > I put the spec in a models directory and it worked like a charm. Thanks > again.You could also do this (as of rev 1810): describe MyPlugin, :rails_component_type => :model do ... end Then you can put it in any directory at all. Cheers, David> On 4/25/07, aslak hellesoy < aslak.hellesoy at gmail.com> wrote: > > I don''t know if this is the source of your problem - I haven''t > > investigated it, but I see that your spec is not in a sub folder > > (spec/models, spec/controllers etc.) > > > > what happens if you move your spec down to say, spec/models (and > > adjust your require to spec_helper.rb - does it still behave the same? > > > > A second thing - have you run ruby script/generate rspec lately? There > > might be some recent changes in the generated spec_helper.rb that your > > current copy (which was generated - perhaps a while ago) is out of > > date with. > > > > Aslak > > > > On 4/25/07, Jeff Dean <jeff at jefdean.com> wrote: > > > 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 > > > > > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
aslak hellesoy
2007-Apr-26 05:32 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
On 4/26/07, Jeff Dean <jeff at jefdean.com> wrote:> aslak - you rock. >Oh please ;-)> I put the spec in a models directory and it worked like a charm. Thanks > again. >David, why does it have to be in a sub dir? Is that what triggers the weaving in of the fixtures etc. methods? Is there a simple way to make fixtures work even if a spec is not in a sub dir? Aslak> > On 4/25/07, aslak hellesoy < aslak.hellesoy at gmail.com> wrote: > > I don''t know if this is the source of your problem - I haven''t > > investigated it, but I see that your spec is not in a sub folder > > (spec/models, spec/controllers etc.) > > > > what happens if you move your spec down to say, spec/models (and > > adjust your require to spec_helper.rb - does it still behave the same? > > > > A second thing - have you run ruby script/generate rspec lately? There > > might be some recent changes in the generated spec_helper.rb that your > > current copy (which was generated - perhaps a while ago) is out of > > date with. > > > > Aslak > > > > On 4/25/07, Jeff Dean <jeff at jefdean.com> wrote: > > > 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 > > > > > > > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
David Chelimsky
2007-Apr-26 10:38 UTC
[rspec-users] Running specs for a plugin - undefined method ''define'' for object
On 4/26/07, aslak hellesoy <aslak.hellesoy at gmail.com> wrote:> On 4/26/07, Jeff Dean <jeff at jefdean.com> wrote: > > aslak - you rock. > > > > Oh please ;-) > > > I put the spec in a models directory and it worked like a charm. Thanks > > again. > > > > David, why does it have to be in a sub dir? Is that what triggers the > weaving in of the fixtures etc. methods? Is there a simple way to make > fixtures work even if a spec is not in a sub dir?Our email must be overlapping somehow. I followed yours up w/ an explanation of that 4 hours before this one was sent. Anyhow - yes, there is. You can do this: describe MyPlugin, :rails_component_type => :model do ... end Take a look at behaviour_factory.rb (in Spec::Rails).> > Aslak > > > > > On 4/25/07, aslak hellesoy < aslak.hellesoy at gmail.com> wrote: > > > I don''t know if this is the source of your problem - I haven''t > > > investigated it, but I see that your spec is not in a sub folder > > > (spec/models, spec/controllers etc.) > > > > > > what happens if you move your spec down to say, spec/models (and > > > adjust your require to spec_helper.rb - does it still behave the same? > > > > > > A second thing - have you run ruby script/generate rspec lately? There > > > might be some recent changes in the generated spec_helper.rb that your > > > current copy (which was generated - perhaps a while ago) is out of > > > date with. > > > > > > Aslak > > > > > > On 4/25/07, Jeff Dean <jeff at jefdean.com> wrote: > > > > 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 > > > > > > > > > > > > > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-users at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-users at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >