Sha256: f1b8f6ad49b6544b65b2b8733d3645d072eaa4102caee648268139637c3438d0

Contents?: true

Size: 904 Bytes

Versions: 4

Compression:

Stored size: 904 Bytes

Contents

require "spec_helper"

describe RSpec::Matchers, "delegate" do
  subject { Comment.new }

  describe '#delegate' do
    it 'handles general delegate' do
      subject.should delegate(:blog_name).to(:blog)
    end

    it 'handles general delegate with prefix' do
      subject.should delegate(:blog_size).to(:blog).via(:size)
    end

    it 'handles missing method on delegated from object' do
      lambda {
        subject.should delegate(:obviously_missing).to(:blog)
      }.should(
        raise_error(
          NameError,
          /undefined method `obviously_missing'/
        )
      )
    end

    it 'handles missing method on delegated to object' do
      lambda {
        subject.should delegate(:parent).to(:blog)
      }.should(
        raise_error(
          RSpec::Expectations::ExpectationNotMetError,
          /delegate #parent to #blog#parent/
        )
      )
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ndlib-on-rspec-0.0.4 spec/ndlib-on-rspec/delegate_matcher_spec.rb
ndlib-on-rspec-0.0.3 spec/ndlib-on-rspec/delegate_matcher_spec.rb
ndlib-on-rspec-0.0.2 spec/ndlib-on-rspec/delegate_matcher_spec.rb
ndlib-on-rspec-0.0.1 spec/ndlib-on-rspec/delegate_matcher_spec.rb