Sha256: 9850796764496b71bd8e391173055a61718ac6ee6fc3b836c40b9bbcc6d9e5b3

Contents?: true

Size: 715 Bytes

Versions: 9

Compression:

Stored size: 715 Bytes

Contents

module RSpec
  module Rails
    module Matchers
      # @private
      class BeANewRecord < RSpec::Matchers::BuiltIn::BaseMatcher
        def matches?(actual)
          actual.new_record?
        end

        def failure_message
          "expected #{actual.inspect} to be a new record, but was persisted"
        end

        def failure_message_when_negated
          "expected #{actual.inspect} to be persisted, but was a new record"
        end
      end

      # @api public
      # Passes if actual returns `true` for `new_record?`.
      #
      # @example
      #     get :new
      #     expect(assigns(:thing)).to be_new_record
      def be_new_record
        BeANewRecord.new
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rspec-rails-3.8.3 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.8.2 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.8.1 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.8.0 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.7.2 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.7.1 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.7.0 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.6.1 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.6.0 lib/rspec/rails/matchers/be_new_record.rb