Sha256: 5879a8223fb02e884e8a0d6e3a6e89b3e65bfb3a90814d1d0cd76ffe5fda23dc

Contents?: true

Size: 1.55 KB

Versions: 5

Compression:

Stored size: 1.55 KB

Contents

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

describe Remarkable::Matchers do
  it 'should include matchers in a specified target' do
    klass = Class.new

    module Foo
      module Matchers
      end
    end

    Remarkable.include_matchers!(Foo, klass)
    klass.ancestors.should include(Foo::Matchers)

    meta = (class << klass; self; end)
    meta.ancestors.should include(Remarkable::Macros)
    meta.ancestors.should include(Remarkable::Pending)
  end

  it 'should include matchers in Remarkable::Matchers' do
    klass = Class.new

    module Foo
      module Matchers
      end
    end

    Remarkable.include_matchers!(Foo, klass)
    Remarkable::Matchers.ancestors.should include(Foo::Matchers)
    (class << Remarkable::Matchers; self; end).ancestors.should include(Foo::Matchers)
  end

  it 'should raise an error if include matchers is called without target and rspec is not loaded' do
    Remarkable.stub!(:rspec_defined?).and_return(false)
    lambda {
      Remarkable.include_matchers!(String)
    }.should raise_error(ArgumentError, "You haven't supplied the target to include_matchers! and RSpec is not loaded, so we cannot infer one.")
  end

  it 'should not include modules twice' do
    klass = Class.new
    meta = (class << klass; self; end)

    meta.should_receive(:ancestors).twice.and_return([Remarkable::Pending, Remarkable::Macros])
    klass.should_not_receive(:extend).with(Remarkable::Pending)
    klass.should_not_receive(:extend).with(Remarkable::Macros)

    Remarkable.include_matchers!(Module.new, klass)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
remarkable-3.1.7 spec/matchers_spec.rb
remarkable-3.1.8 spec/matchers_spec.rb
remarkable-3.1.5 spec/matchers_spec.rb
remarkable-3.1.4 spec/matchers_spec.rb
remarkable-3.1.6 spec/matchers_spec.rb