Sha256: 16a90b4ee2c4d904549854bcf8874b045d792cd257fb23c6dcfe956b716b807c

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require File.join(File.dirname(__FILE__), 'spec_helper.rb')


describe 'a volute' do

  before(:each) do

    Volute.clear!

    @invoice = Invoice.new

    volute do
      object.comment = [ attribute, previous_value, value ]
    end
  end

  it 'should not be applied when #instance_variable_set is used' do

    @invoice.instance_variable_set(:@paid, true)

    @invoice.paid.should == true
    @invoice.comment.should == nil
  end

  it 'should not be applied when #vset is used' do

    @invoice.vset(:paid, true)

    @invoice.comment.should == nil
  end

  describe 'with no arguments' do

    it 'should be applied for any change' do

      @invoice.paid = true

      @invoice.paid.should == true
      @invoice.comment.should == [ 'paid', nil, true ]
    end
  end
end

describe 'a class without a volute' do

  before(:each) do

    Volute.clear!

    @invoice = Invoice.new
  end

  it 'should get as usual' do

    @invoice.paid.should == nil
  end

  it 'should set as usual' do

    (@invoice.paid = false).should == false
    @invoice.paid.should == false
  end
end

describe 'a volute with an over' do

  before(:each) do

    Volute.clear!

    @package = Package.new

    volute Package do
      volute do
        over if object.delivered
      end
      volute :location do
        (object.comment ||= []) << value
      end
    end
  end

  it 'should prevent evaluation of further volutes' do

    @package.location = 'ZRH'
    @package.location = 'CDG'

    @package.comment.should == %w[ ZRH CDG ]

    @package.delivered = true
    @package.location = 'FCO'

    @package.comment.should == %w[ ZRH CDG ]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
volute-0.1.0 spec/volute_spec.rb