On May 26, 2008, at 6:54 PM, Tim Glen wrote:

On 23-May-08, at 6:23 PM, Pat Maddox wrote:

RSpec currently includes the described module so that you can call
methods directly. It will no longerdo that automatically, so you'll
have to manually include the module if you want these direct calls.

Rails helpers are defined in modules, so that's why this is showing up.

So I find myself wondering - is this the case for just helper modules or all modules? For instance, I have a module which gets included into some controllers, but I'd like to spec against it directly so I don't have in those other controllers... I'm not sure how to set this up. What's the best practice?

First of all, don't ever believe anybody when they tell you something is a best practice.

That said - here's what I *usually* do:

describe WhizBangModule do
  it "should do something" do
    whiz_banger = Object.new
    whiz_banger.extend WhizBangModule
    whiz_banger.whiz.should == "bang"
  end
end

or something like that. Make sense?





I'm on Rails 2.0.2 and just updated to the fresh Rspec 1.1.4

thanks,
tim
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to