Sha256: 8649072489b17d1de1f594fb19191c02f2961e09ec6fb17f610502533ae7e19e

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Shoulda # :nodoc:
  module Matchers
    class RailsShim # :nodoc:
      def self.layouts_ivar
        if action_pack_major_version >= 4
          '@_layouts'
        else
          '@layouts'
        end
      end

      def self.flashes_ivar
        if action_pack_major_version >= 4
          :@flashes
        else
          :@used
        end
      end

      def self.clean_scope(klass)
        if active_record_major_version == 4
          klass.all
        else
          klass.scoped
        end
      end

      def self.validates_confirmation_of_error_attribute(matcher)
        if active_model_major_version == 4
          matcher.confirmation_attribute
        else
          matcher.attribute
        end
      end

      def self.active_record_major_version
        ::ActiveRecord::VERSION::MAJOR
      end

      def self.active_model_major_version
        ::ActiveModel::VERSION::MAJOR
      end

      def self.action_pack_major_version
        ::ActionPack::VERSION::MAJOR
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shoulda-matchers-2.6.0 lib/shoulda/matchers/rails_shim.rb
shoulda-matchers-2.5.0 lib/shoulda/matchers/rails_shim.rb