Sha256: 53eee33c11d6713bf0b881d136152001c924c8ceef13f62b5b2ef74437c02884

Contents?: true

Size: 1.07 KB

Versions: 59

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe "a matcher defined using the matcher DSL" do
  def question?
    :answer
  end

  it "has access to methods available in the scope of the example" do
    RSpec::Matchers::define(:ignore) {}
    ignore.question?.should eq(:answer)
  end

  it "raises when method is missing from local scope as well as matcher" do
    RSpec::Matchers::define(:ignore) {}
    expect { ignore.i_dont_exist }.to raise_error(NameError)
  end

  it "clears user instance variables between invocations" do
    RSpec::Matchers::define(:be_just_like) do |expected|
      match do |actual|
        @foo ||= expected
        @foo == actual
      end
    end

    3.should be_just_like(3)
    4.should be_just_like(4)
  end

  describe "#respond_to?" do
    it "returns true for methods in example scope" do
      RSpec::Matchers::define(:ignore) {}
      ignore.should respond_to(:question?)
    end

    it "returns false for methods not defined in matcher or example scope" do
      RSpec::Matchers::define(:ignore) {}
      ignore.should_not respond_to(:i_dont_exist)
    end
  end
end

Version data entries

59 entries across 59 versions & 5 rubygems

Version Path
classiccms-0.3.4 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classiccms-0.3.3 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classiccms-0.3.2 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classiccms-0.3.1 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classiccms-0.3.0 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classiccms-0.2.4.pre vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classicCMS-0.2.3 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classicCMS-0.2.2 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classicCMS-0.2.1 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classicCMS-0.2.0 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
classicCMS-0.1.2 vendor/bundle/gems/rspec-expectations-2.9.0/spec/rspec/matchers/dsl_spec.rb
rspec-expectations-2.9.0 spec/rspec/matchers/dsl_spec.rb
rspec-expectations-2.9.0.rc2 spec/rspec/matchers/dsl_spec.rb