Sha256: e6a0d53bedf948eb01846b3e04ae75c1dbfcae118522d27c1bb3096f8cc5df3f

Contents?: true

Size: 674 Bytes

Versions: 32

Compression:

Stored size: 674 Bytes

Contents

module Shoulda
  module Matchers
    # @private
    class MatcherContext
      def initialize(context)
        @context = context
      end

      def subject_is_a_class?
        if inside_a_shoulda_context_project? && outside_a_should_block?
          assume_that_subject_is_not_a_class
        else
          context.subject.is_a?(Class)
        end
      end

      protected

      attr_reader :context

      private

      def inside_a_shoulda_context_project?
        defined?(Shoulda::Context)
      end

      def outside_a_should_block?
        context.is_a?(Class)
      end

      def assume_that_subject_is_not_a_class
        false
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.4.1 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.4.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.3.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/matcher_context.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/matcher_context.rb