Sha256: 68eadef095085128aa5076a0cf32a1b8c895135d060cc9435e91a15765e426fd

Contents?: true

Size: 876 Bytes

Versions: 4

Compression:

Stored size: 876 Bytes

Contents

require_relative '../model_creators'
require 'forwardable'

module UnitTests
  module ModelCreators
    class ActiveRecord
      def self.call(args)
        new(args).call
      end

      extend Forwardable

      def_delegators(
        :arguments,
        :attribute_default_values_by_name,
        :attribute_name,
        :customize_model,
        :model_name,
      )

      def_delegators :model_creator, :customize_model

      def initialize(args)
        @arguments = CreateModelArguments::Basic.wrap(
          args.merge(
            model_creation_strategy: UnitTests::ModelCreationStrategies::ActiveRecord
          )
        )
        @model_creator = Basic.new(arguments)
      end

      def call
        model_creator.call
      end

      protected

      attr_reader :arguments, :model_creator
    end

    register(:active_record, ActiveRecord)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shoulda-matchers-3.1.3 spec/support/unit/model_creators/active_record.rb
shoulda-matchers-3.1.2 spec/support/unit/model_creators/active_record.rb
shoulda-matchers-3.1.1 spec/support/unit/model_creators/active_record.rb
shoulda-matchers-3.1.0 spec/support/unit/model_creators/active_record.rb