Sha256: f487fd4c2823382369dbe465d155b181f2101bf1aabd1294891569543518666d

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

class FakeBound
  attr_accessor :attribute
end

describe 'MotionBindable::Strategies::Proc' do

  context 'nested model' do

    before do
      @bound = FakeBound.new
      @bound.attribute = 'Testing.'
      @object = FakeModel.new
      @object.nested = FakeModel.new
    end

    context 'is bound' do

      before do
        @object.bind_attributes({
          attribute: proc { @bound.attribute },
          nested: {
            attribute: proc { @bound.attribute }
          }
        })
      end

      it 'should refresh upon bind' do
        @object.attribute.should.equal 'Testing.'
        @object.nested.attribute.should.equal 'Testing.'
      end

      it 'attribute is updated when the bound object is updated' do
        @bound.attribute = 'updated'
        wait(0.5) do
          @object.attribute.should.equal 'updated'
        end
      end

    end

  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion_bindable-0.2.4 spec/strategies/proc_spec.rb