Sha256: 741b4bfbb55843044a3d94879aca301af78b31e285f7df080adbe9431ad8daf4

Contents?: true

Size: 1.35 KB

Versions: 31

Compression:

Stored size: 1.35 KB

Contents

require 'active_support/core_ext/module/aliasing'
require 'rspec/matchers/built_in/have'

module RSpec::Rails::Matchers
  module HaveExtensions
    extend ActiveSupport::Concern

    # @api private
    #
    # Enhances the failure message for `should have(n)` matchers
    def failure_message_for_should_with_errors_on_extensions
      return "expected #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}, got #{@actual}" if @collection_name == :errors_on
      return "expected #{relativities[@relativity]}#{@expected} error on :#{@args[0]}, got #{@actual}"  if @collection_name == :error_on
      return failure_message_for_should_without_errors_on_extensions
    end

    # @api private
    #
    # Enhances the description for `should have(n)` matchers
    def description_with_errors_on_extensions
      return "have #{relativities[@relativity]}#{@expected} errors on :#{@args[0]}" if @collection_name == :errors_on
      return "have #{relativities[@relativity]}#{@expected} error on :#{@args[0]}"  if @collection_name == :error_on
      return description_without_errors_on_extensions
    end

    included do
      alias_method_chain :failure_message_for_should, :errors_on_extensions
      alias_method_chain :description, :errors_on_extensions
    end
  end
end

RSpec::Matchers::BuiltIn::Have.class_eval do
  include RSpec::Rails::Matchers::HaveExtensions
end

Version data entries

31 entries across 26 versions & 5 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-rails-2.13.0/lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.14.1 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.99.0.beta1 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.14.0 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.14.0.rc1 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.13.2 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.13.1 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.13.0 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.12.2 lib/rspec/rails/matchers/have_extension.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.12.1 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.12.0 lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.11.4 lib/rspec/rails/matchers/have_extension.rb
gem_repackager-0.1.0 support/gems/rspec-rails-2.11.0/lib/rspec/rails/matchers/have_extension.rb
rspec-rails-2.11.0 lib/rspec/rails/matchers/have_extension.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/rspec/rails/matchers/have_extension.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/rspec/rails/matchers/have_extension.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/rspec/rails/matchers/have_extension.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/rspec/rails/matchers/have_extension.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/rspec/rails/matchers/have_extension.rb