Sha256: 8e9332c3f634e9c5d443aed421a248e63dafeca6f70d4d45862cd64ef347a4ac

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 Bytes

Contents

module RSpec::Rails::Matchers
  class BeANewRecord < RSpec::Matchers::BuiltIn::BaseMatcher

    # @api private
    def matches?(actual)
      !actual.persisted?
    end

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-rails-3.0.0.beta1 lib/rspec/rails/matchers/be_new_record.rb