Sha256: 6026a1a48adc44db4442f076fecd3e043c22cd5d5d13dcd8a58907b6fb292051

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

Spec::Matchers.define :have_public_instance_method do |method|
  match do |klass|
    klass.public_instance_methods.any? {|m| [method, method.to_sym].include?(m)}
  end
end

(Spec::Matchers.constants.sort).each do |c|
  if (Class === (klass = Spec::Matchers.const_get(c)))
    describe klass do
      if klass.public_instance_methods.any? {|m| ['failure_message_for_should',:failure_message_for_should].include?(m)}
        describe "called with should" do
          subject { klass }
          it { should have_public_instance_method('failure_message_for_should')}
          it { should have_public_instance_method('failure_message')}
        end
      end
      if klass.public_instance_methods.any? {|m| ['failure_message_for_should_not',:failure_message_for_should_not].include?(m)}
        describe "called with should not" do
          subject { klass }
          it { should have_public_instance_method('failure_message_for_should_not')}
          it { should have_public_instance_method('negative_failure_message')}
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-1.2.7 spec/spec/matchers/compatibility_spec.rb
rspec-1.2.8 spec/spec/matchers/compatibility_spec.rb
rspec-1.2.5 spec/spec/matchers/compatibility_spec.rb
rspec-1.2.6 spec/spec/matchers/compatibility_spec.rb