Sha256: a3652098ff8a02de93dbad8f0f16261eec11929bbc5913ae3944698fc5d9cf91

Contents?: true

Size: 725 Bytes

Versions: 7

Compression:

Stored size: 725 Bytes

Contents

module ElabsMatchers
  module Helpers
    module ReloadRecord
      rspec

      ##
      #
      # Finds the record from the database and return a new instance for that record.
      #
      # @param [Object] record      An instance of an ORM record
      #
      # Example:
      # reload(post)

      def reload(record)
        record.class.find(record.id)
      end

      ##
      #
      # Saves the record and fetches it from the database and return a new instance for that record.
      #
      # @param [Object] record      An instance of an ORM record
      #
      # Example:
      # save_and_reload(post)

      def save_and_reload(record)
        record.save!
        reload(record)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
elabs_matchers-2.0.1 lib/elabs_matchers/helpers/reload_record.rb
elabs_matchers-2.0.0 lib/elabs_matchers/helpers/reload_record.rb
elabs_matchers-1.0.1 lib/elabs_matchers/helpers/reload_record.rb
elabs_matchers-1.0.0 lib/elabs_matchers/helpers/reload_record.rb
elabs_matchers-0.0.7 lib/elabs_matchers/helpers/reload_record.rb
elabs_matchers-0.0.6 lib/elabs_matchers/helpers/reload_record.rb
elabs_matchers-0.0.5 lib/elabs_matchers/helpers/reload_record.rb