Sha256: 32f45605133eb72856a80241263bdf5002ee4657d58d745e3b60b865d0638415

Contents?: true

Size: 1013 Bytes

Versions: 40

Compression:

Stored size: 1013 Bytes

Contents

#
# render(tag) might compare two very large strings, with lots of whitespace
# differences which would be hard to diagnose. So use the Comparison module to
# zero in on the bug.
#
module Spec::Rails::Matchers
  class RenderTags

    # Guard against double definitions
    unless method_defined?(:_old_matches?)
      alias_method :_old_matches?, :matches?
      alias_method :_old_failure_message, :failure_message

      # If comparison was just a straight '==' then redo the comparison
      # using the comparison class, and save an error message
      def matches?(page)
        result = _old_matches? page
        return result if result || !@expected || !@actual

        comparison = Comparison.new(@expected, @actual)
        @error_message = comparison.message
        comparison.same?
      end

      # Return the error message from Comparison if it was saved
      def failure_message
        return @error_message unless @error_message.nil?
        _old_failure_message
      end
    end

  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
radiant-shop-extension-0.94.8 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.7 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.6 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.5 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.4 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.3 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.2 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.1 spec/matchers/render_matcher.rb
radiant-shop-extension-0.94.0 spec/matchers/render_matcher.rb
radiant-shop-extension-0.93.3 spec/matchers/render_matcher.rb
radiant-shop-extension-0.93.2 spec/matchers/render_matcher.rb
radiant-shop-extension-0.93.1 spec/matchers/render_matcher.rb
radiant-shop-extension-0.93.0 spec/matchers/render_matcher.rb
radiant-shop-extension-0.92.11 spec/matchers/render_matcher.rb
radiant-shop-extension-0.92.10 spec/matchers/render_matcher.rb
radiant-shop-extension-0.92.9 spec/matchers/render_matcher.rb
radiant-shop-extension-0.92.8 spec/matchers/render_matcher.rb
radiant-shop-extension-0.92.7 spec/matchers/render_matcher.rb
radiant-shop-extension-0.92.6 spec/matchers/render_matcher.rb
radiant-shop-extension-0.92.3 spec/matchers/render_matcher.rb