spec/strategy_spec.rb in motion_bindable-0.1.1 vs spec/strategy_spec.rb in motion_bindable-0.2.0
- old
+ new
@@ -30,10 +30,12 @@
before do
@object = ObjectOne.new
@bound = Object.new
@strategy = Strategy.new(@object, :attribute)
+ @strategy.stub!(:watch_bound)
+ @strategy.stub!(:watch_object)
end
describe '#bind' do
it 'should respond' do
@strategy.respond_to?(:bind).should.equal true
@@ -45,21 +47,27 @@
end
it 'should return self' do
@strategy.bind(@bound).should.equal @strategy
end
- end
- describe '#refresh' do
- it 'should respond' do
- @strategy.respond_to?(:refresh).should.equal true
+ it 'should call on_object_change if the attribute is not nil' do
+ @object.attribute = 'Test'
+ @strategy.should.receive(:on_object_change).and_return(true)
+ @strategy.bind(@bound)
end
+
+ it 'should call on_bound_change if the attribute is nil' do
+ @object.attribute = nil
+ @strategy.should.receive(:on_bound_change).and_return(true)
+ @strategy.bind(@bound)
+ end
end
describe '#attribute=' do
it 'should be a proxy to set the attribute on the bound object' do
- @strategy.attribute = 'test'
- @object.attribute.should.equal 'test'
+ @strategy.send(:attribute=, 'test')
+ @object.send(:attribute).should.equal 'test'
end
end
describe '#unbind' do
it 'should respond' do