Sha256: 22b435e286d1cfab8eeb344e3aa7d3d96e813510d83b968fac9b72e961514162

Contents?: true

Size: 1.62 KB

Versions: 24

Compression:

Stored size: 1.62 KB

Contents

module Locomotive
  module RSpec
    module Matchers

      class IncludeInstanceMethod #:nodoc:

        def initialize(meth)
          @meth = meth
        end

        def matches?(klass)
          @klass = klass
          if RUBY_VERSION =~ /1\.9/
            klass.instance_methods.include?(@meth.to_sym) == true
          else
            klass.instance_methods.include?(@meth.to_s) == true
          end
        end

        def failure_message
          "#{@klass} expected to include the instance method #{@meth}"
        end

        def negative_failure_message
          "#{@klass} expected to not include the instance method #{@meth} but included it.\n"
        end

        def description
          "include instance method #{@meth}"
        end

      end

      def include_instance_method(meth)
        IncludeInstanceMethod.new(meth)
      end

      class IncludeClassMethod #:nodoc:

        def initialize(meth)
          @meth = meth
        end

        def matches?(klass)
          @klass = klass
          if RUBY_VERSION =~ /1\.9/
            klass.methods.include?(@meth.to_sym) == true
          else
            klass.methods.include?(@meth.to_s) == true
          end
        end

        def failure_message
          "#{@klass} expected to include the class method #{@meth}"
        end

        def negative_failure_message
          "#{@klass} expected to not include the class method #{@meth} but included it.\n"
        end

        def description
          "include class method #{@meth}"
        end

      end

      def include_class_method(meth)
        IncludeClassMethod.new(meth)
      end

    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 spec/support/matchers.rb
locomotivecms-3.3.0.rc3 spec/support/matchers.rb
locomotivecms-3.3.0.rc2 spec/support/matchers.rb
locomotivecms-3.1.2 spec/support/matchers.rb
locomotivecms-3.2.1 spec/support/matchers.rb
locomotivecms-3.3.0.rc1 spec/support/matchers.rb
locomotivecms-3.2.0 spec/support/matchers.rb
locomotivecms-3.2.0.rc2 spec/support/matchers.rb
locomotivecms-3.2.0.rc1 spec/support/matchers.rb
locomotivecms-3.1.1 spec/support/matchers.rb
locomotivecms-3.1.0 spec/support/matchers.rb
locomotivecms-3.1.0.rc3 spec/support/matchers.rb
locomotivecms-3.1.0.rc2 spec/support/matchers.rb
locomotivecms-3.1.0.rc1 spec/support/matchers.rb
locomotivecms-3.0.1 spec/support/matchers.rb
locomotivecms-3.0.0 spec/support/matchers.rb
locomotivecms-3.0.0.rc7 spec/support/matchers.rb
locomotivecms-3.0.0.rc6 spec/support/matchers.rb
locomotivecms-3.0.0.rc5 spec/support/matchers.rb
locomotivecms-3.0.0.rc4 spec/support/matchers.rb