spec/economic/entity_spec.rb in rconomic-0.2.1 vs spec/economic/entity_spec.rb in rconomic-0.3

- old
+ new

@@ -169,10 +169,36 @@ savon.expects(:spec_entity_update_from_data).returns(:success) subject.save end end + describe "destroy" do + subject { (e = SpecEntity.new).tap { |e| e.id = 42; e.persisted = true; e.partial = false; e.session = session } } + + it "sends data to the API" do + savon.expects(:spec_entity_delete).returns(:success) + subject.destroy + end + + it "should request with the correct model and id" do + savon.expects(:spec_entity_delete).with('specEntityHandle' => {'Id' => 42}).returns(:success) + subject.destroy + end + + it "should mark the entity as not persisted and partial" do + savon.expects(:spec_entity_delete).returns(:success) + subject.destroy + subject.should_not be_persisted + subject.should be_partial + end + + it "should return the response" do + session.expects(:request).returns({ :response => true }) + subject.destroy.should == { :response => true } + end + end + describe "update_properties" do subject { SpecEntity.new } it "sets the properties to the given values" do subject.class.has_properties :foo, :baz @@ -183,30 +209,8 @@ it "only sets known properties" do subject.class.has_properties :foo, :bar subject.expects(:foo=).with('bar') subject.update_properties(:foo => 'bar', 'baz' => 'qux') - end - end -end - -describe Economic::Entity::Handle do - - describe "equality" do - let(:handle_a) { Economic::Entity::Handle.new(:id => 1, :number => 2) } - let(:handle_b) { Economic::Entity::Handle.new(:id => 1, :number => 2) } - let(:handle_c) { Economic::Entity::Handle.new(:id => 1) } - let(:handle_d) { Economic::Entity::Handle.new(:id => 1, :number => 3) } - - it "should be equal when both id and number are equal" do - handle_a.should == handle_b - end - - it "should not be equal when id or number is missing" do - handle_a.should_not == handle_c - end - - it "should not be equal when id or number is equal and the other isn't" do - handle_a.should_not == handle_d end end end