Sha256: e1510a1f8b93fb99b16ba24c5fe2a56772b10d1d39c2a0d2cce3f387d5a88f76

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

require 'spec_helper'

feature "Definition" do
  class Foo
    def say
      "Hey!"
    end
  end

  class FooDecorator < RDecorator::Base
    def say
      origin.say * 3
    end
  end
  
  class This
    def say
      "Yeah!"
    end
  end
  
  class ThatDecorator < RDecorator::Base
    decorate_for :this
    def say
      origin.say * 3
    end
  end
  
  module NoClass
  end

  class NoClassDecorator < RDecorator::Base
  end

  scenario "Auto decoration by class-name" do
    foo = Foo.new
    foo.decorated.say.should eq "Hey!Hey!Hey!"
  end
  
  scenario "using 'decorate_for'" do
    this = This.new
    this.decorated.say.should eq "Yeah!Yeah!Yeah!"
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
r_decorator-0.0.6 spec/decorators/definition_spec.rb
r_decorator-0.0.5 spec/decorators/definition_spec.rb
r_decorator-0.0.4 spec/decorators/definition_spec.rb