Sha256: 3c5c93d16a98a27936d8b5c6cef98b65a453151d63fe94c08cb55e0c1c02e351

Contents?: true

Size: 931 Bytes

Versions: 6

Compression:

Stored size: 931 Bytes

Contents

module Spec
  module Rails
    module Matchers

      class Observe
        def initialize(expected_model_class)
          @expected_model_class = expected_model_class
        end
    
        def matches?(observer)
          @observer = observer
          if @observer.is_a?(ActiveRecord::Observer)
            @observer = @observer.class
          end
          @observed_classes = observer.observed_classes.flatten
          @observed_classes.include?(@expected_model_class)
        end
    
        def failure_message
          return "expected #{@observer.name} to observe #{@expected_model_class.name}, but it was not included in [#{@observed_classes.map(&:name).join(', ')}]"
        end
    
        def description
          "observer to be observing #{@expected_model_class.name}"
        end
      end

      def observe(expected_model_class)
        Observe.new(expected_model_class)
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec-on-rails-matchers/lib/spec/rails/matchers/observers.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec-on-rails-matchers/lib/spec/rails/matchers/observers.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec-on-rails-matchers/lib/spec/rails/matchers/observers.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec-on-rails-matchers/lib/spec/rails/matchers/observers.rb
saturnflyer-rspec-rails-matchers-1.0.0 lib/spec/rails/matchers/observers.rb
saturnflyer-rspec-rails-matchers-1.0.1 lib/spec/rails/matchers/observers.rb