JDeville
2011-Jun-01 05:37 UTC
[rspec-users] including a module with ActiveSupport::Concern works in console/site, but not in specs
I have a simple module: module Buyer extend ActiveSupport::Concern module ClassMethods def delete_occasion(fb_id, recipient_fb_id, occasion_id) # blah clah end end end I include it like this: class User include Buyer end this works when running the server, and in the console, but my specs yield: undefined method `delete_occasion'' for #<Class:0x00000101623390> Is there something different I need to do for rspec here? *Env Details:* 1.9.2, rails 3.07, guard-rspec (0.3.1) rspec (2.6.0) rspec-core (2.6.3) rspec-expectations (2.6.0) rspec-given (1.3.1) rspec-instafail (0.1.7) rspec-mocks (2.6.0) rspec-rails (2.6.1) Thanks all. - jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110531/7258bcda/attachment.html>
David Chelimsky
2011-Jun-04 14:54 UTC
[rspec-users] including a module with ActiveSupport::Concern works in console/site, but not in specs
On Jun 1, 2011, at 12:37 AM, JDeville wrote:> I have a simple module: > > module Buyer > extend ActiveSupport::Concern > > module ClassMethods > def delete_occasion(fb_id, recipient_fb_id, occasion_id) > # blah clah > end > end > end > > I include it like this: > class User > include Buyer > endWhere does this ^^ code live?> > this works when running the server, and in the console, but my specs yield: > undefined method `delete_occasion'' for #<Class:0x00000101623390> > > Is there something different I need to do for rspec here? > > Env Details: > 1.9.2, rails 3.07, > guard-rspec (0.3.1) > rspec (2.6.0) > rspec-core (2.6.3) > rspec-expectations (2.6.0) > rspec-given (1.3.1) > rspec-instafail (0.1.7) > rspec-mocks (2.6.0) > rspec-rails (2.6.1) > > Thanks all. - jeffWhat does the spec look like? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110604/4641b603/attachment-0001.html>
Ramon Tayag
2011-Jun-04 17:11 UTC
[rspec-users] including a module with ActiveSupport::Concern works in console/site, but not in specs
Not sure why it works inconsistently, but I always thought you did the following to include class methods via activesupport::concern: class Buyer extend ActiveSupport::Concern included do # def a_class_method end def an_instance_method ... end Ramon Tayag On Jun 4, 2011, at 22:51, JDeville <jeffdeville at gmail.com> wrote: I have a simple module: module Buyer extend ActiveSupport::Concern module ClassMethods def delete_occasion(fb_id, recipient_fb_id, occasion_id) # blah clah end end end I include it like this: class User include Buyer end this works when running the server, and in the console, but my specs yield: undefined method `delete_occasion'' for #<Class:0x00000101623390> Is there something different I need to do for rspec here? *Env Details:* 1.9.2, rails 3.07, guard-rspec (0.3.1) rspec (2.6.0) rspec-core (2.6.3) rspec-expectations (2.6.0) rspec-given (1.3.1) rspec-instafail (0.1.7) rspec-mocks (2.6.0) rspec-rails (2.6.1) Thanks all. - 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/20110605/1da50d6c/attachment.html>