[rspec-devel] [ rspec-Bugs-15638 ] When naming a protected method, if it begins with 'should_' it causes it to be treated as an example.
noreply at rubyforge.org
noreply at rubyforge.org
Thu Nov 15 02:44:16 EST 2007
Bugs item #15638, was opened at 2007-11-15 07:32
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797
Category: runner module
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Nathan Sutton (fowlduck)
Assigned to: Nobody (None)
Summary: When naming a protected method, if it begins with 'should_' it causes it to be treated as an example.
Initial Comment:
starting a protected method with should_ causes it to be treated as an example.
edge rails revision: 8146
edge rspec revision: 2889
edge rspec_on_rails revision: 2889
describe SessionsController do
# a bunch of examples, some that call should_be_logged_in
protected
def should_be_logged_in
response.session.should_not be_nil
session[:user].should_not be_nil
end
end
When running the spec:
SessionsController should_be_logged_in' FAILED
expected not nil, got nil
./spec/controllers/sessions_controller_spec.rb:111:in `should_be_logged_in'
script/spec:4:
Renamed the method to 'be_logged_in' and all specs then pass. Line 111, in this case, is 'session[:user].should_not be_nil'.
----------------------------------------------------------------------
>Comment By: David Chelimsky (dchelimsky)
Date: 2007-11-15 07:44
Message:
That's actually by design. In an effort to play well with others, we're working towards a world in which people who prefer to use classes and methods can do this:
class FooSpec < Spec::ExampleGroup
def should_bar
...
end
end
This works just like Test::Unit except it looks for methods that start with "should" instead of "test". This means that you can not have helper methods that start with "should".
I'm going to leave this ticket open and would welcome opinions on this.
----------------------------------------------------------------------
You can respond by visiting:
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=15638&group_id=797
More information about the rspec-devel
mailing list