Sha256: 17fbbec75d309872b3e80182d43a07469ac9b8a6d99b222ecc1cc193109ed84c

Contents?: true

Size: 695 Bytes

Versions: 14

Compression:

Stored size: 695 Bytes

Contents

module RSpec
  module Rails
    module Matchers
      # @private
      class BeANewRecord < RSpec::Matchers::BuiltIn::BaseMatcher
        def matches?(actual)
          !actual.persisted?
        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

      # 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
  end
end

Version data entries

14 entries across 13 versions & 3 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.3.3/lib/rspec/rails/matchers/be_new_record.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/matchers/be_new_record.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.3.3 lib/rspec/rails/matchers/be_new_record.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/matchers/be_new_record.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rspec-rails-3.1.0/lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.3.2 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.3.1 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.3.0 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.2.3 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.2.2 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.2.1 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.2.0 lib/rspec/rails/matchers/be_new_record.rb
rspec-rails-3.1.0 lib/rspec/rails/matchers/be_new_record.rb