Hi!
I recently updated my rspec and rspec_on_rails plugins to the tip of
the trunk and ran into an issue with helper methods with names
starting with should_ in my describe blocks. Fictive example to show
what I’m talking about:
describe Order do
it “Can be paid for” do
…
should_have_paid(user)
end
def should_have_paid(user)
end
end
I know in some places I should (ah, there is that word again…) be
using custom matchers when I’m being lazy and instead just defining
methods. Anyway, it seems RSpec picks up methods starting with
should_ as examples. Here is some debug output that I generated for a
method called should_have_emailed:
Is this itentional behaviour by RSpec or some weird side effect?
That’s actually by design. There are many projects that would like to
move to rspec but don’t because the transition cost is too high. There
are also a number of people who have said the lack of a clear
class/method structure keeps them away.
Supporting methods that start with should_ is part of an effort to
resolve these conflicts. As things stand in trunk today, you can more
or less use your choices from the following
class FooTest < Test::Unit::TestCase
class FooExamples < Spec::ExampleGroup
describe Foo do
def test_should_bar
def should_bar
it “should bar” do