2012-02-28

rspec2にあげたらundefined method `include_text'と言われたよ

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク
Railsを2.3から3.0にあげました。

なのでrspecも1.3から2.0にあげました。

そして
rake spec
としたら
------------------
NoMethodError:
undefined method `include_text' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_3:0xb71a09e8>
# ./spec/controllers/xxx_controller_spec.rb:19
------------------
とか言われちゃいました。

前はあったinclude_textがなくなった模様です。

なので以下のように対応しました。
vi spec/support/include_text.rb
module RSpec::Rails
  module Matchers
    RSpec::Matchers.define :include_text do |text|
      match do |response_or_text|
        @content = response_or_text.respond_to?(:body) ? response_or_text.body : response_or_text
        @content.include?(text)
      end
    end
  end
end

0 件のコメント: