Sha256: 79134ccbc9d7d1757b48d17f16246936ecdb8aef07dc77a3dd89c6dafb38c260

Contents?: true

Size: 726 Bytes

Versions: 15

Compression:

Stored size: 726 Bytes

Contents

module Mongoid
  module Matchers
    module Validations
      module WithMessage
        def with_message(message)
          @expected_message = message
          self
        end

        private

        def check_expected_message
          actual_message = @validator.options[:message]
          if actual_message.nil?
            @negative_result_message << " with no custom message"
            @result = false
          elsif actual_message == @expected_message
            @positive_result_message << " with custom message '#{@expected_message}'"
          else
            @negative_result_message << " got message '#{actual_message}'"
            @result = false
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
mongoid-spec-4.0.1 lib/matchers/validations/with_message.rb
mongoid-rspec-3.0.0 lib/matchers/validations/with_message.rb
mongoid-rspec-2.2.0 lib/matchers/validations/with_message.rb
mongoid-rspec-2.1.0 lib/matchers/validations/with_message.rb
mongoid-rspec-1.13.0 lib/matchers/validations/with_message.rb
mongoid-rspec-2.0.0 lib/matchers/validations/with_message.rb
mongoid-rspec-2.0.0.rc1 lib/matchers/validations/with_message.rb
glebtv-mongoid-rspec-3.0.0 lib/matchers/validations/with_message.rb
mongoid4-rspec-1.11.0 lib/matchers/validations/with_message.rb
glebtv-mongoid-rspec-1.12.0 lib/matchers/validations/with_message.rb
mongoid-rspec-1.11.0 lib/matchers/validations/with_message.rb
mongoid-rspec-1.10.0 lib/matchers/validations/with_message.rb
mongoid-rspec-1.9.0 lib/matchers/validations/with_message.rb
mongoid-rspec-1.8.2 lib/matchers/validations/with_message.rb
mongoid-rspec-1.8.1 lib/matchers/validations/with_message.rb