spec/groupdocs/document/annotation_spec.rb in groupdocs-1.1.0 vs spec/groupdocs/document/annotation_spec.rb in groupdocs-1.2.0

- old
+ new

@@ -9,50 +9,32 @@ file = GroupDocs::Storage::File.new document = GroupDocs::Document.new(file: file) described_class.new(document: document) end - it { should respond_to(:document) } - it { should respond_to(:document=) } - it { should respond_to(:id) } - it { should respond_to(:id=) } - it { should respond_to(:guid) } - it { should respond_to(:guid=) } - it { should respond_to(:sessionGuid) } - it { should respond_to(:sessionGuid=) } - it { should respond_to(:documentGuid) } - it { should respond_to(:documentGuid=) } - it { should respond_to(:creatorGuid) } - it { should respond_to(:creatorGuid=) } - it { should respond_to(:replyGuid) } - it { should respond_to(:replyGuid=) } - it { should respond_to(:createdOn) } - it { should respond_to(:createdOn=) } - it { should respond_to(:type) } - it { should respond_to(:type=) } - it { should respond_to(:access) } - it { should respond_to(:access=) } - it { should respond_to(:box) } - it { should respond_to(:box=) } - it { should respond_to(:replies) } - it { should respond_to(:replies=) } - it { should respond_to(:annotationPosition) } - it { should respond_to(:annotationPosition=) } + it { should have_accessor(:document) } + it { should have_accessor(:id) } + it { should have_accessor(:guid) } + it { should have_accessor(:sessionGuid) } + it { should have_accessor(:documentGuid) } + it { should have_accessor(:creatorGuid) } + it { should have_accessor(:replyGuid) } + it { should have_accessor(:createdOn) } + it { should have_accessor(:type) } + it { should have_accessor(:access) } + it { should have_accessor(:box) } + it { should have_accessor(:replies) } + it { should have_accessor(:annotationPosition) } - it { should have_alias(:session_guid, :sessionGuid) } - it { should have_alias(:session_guid=, :sessionGuid=) } - it { should have_alias(:document_guid, :documentGuid) } - it { should have_alias(:document_guid=, :documentGuid=) } - it { should have_alias(:creator_guid, :creatorGuid) } - it { should have_alias(:creator_guid=, :creatorGuid=) } - it { should have_alias(:reply_guid, :replyGuid) } - it { should have_alias(:reply_guid=, :replyGuid=) } + it { should alias_accessor(:session_guid, :sessionGuid) } + it { should alias_accessor(:document_guid, :documentGuid) } + it { should alias_accessor(:creator_guid, :creatorGuid) } + it { should alias_accessor(:reply_guid, :replyGuid) } # Annotation#created_on is overwritten - it { should have_alias(:created_on=, :createdOn=) } - it { should have_alias(:annotation_position, :annotationPosition) } - it { should have_alias(:annotation_position=, :annotationPosition=) } - it { should have_alias(:position, :annotation_position) } + it { should have_alias(:created_on=, :createdOn=) } + it { should alias_accessor(:annotation_position, :annotationPosition) } + it { should alias_accessor(:position, :annotationPosition) } it { should have_alias(:annotationGuid=, :guid=) } describe '#initialize' do it 'raises error if document is not specified' do @@ -106,11 +88,11 @@ end end describe '#box=' do it 'converts passed hash to GroupDocs::Document::Rectangle object' do - subject.box = { X: 0.90, Y: 0.05, Width: 0.06745, Height: 0.005967 } + subject.box = { x: 0.90, y: 0.05, width: 0.06745, height: 0.005967 } subject.box.should be_a(GroupDocs::Document::Rectangle) subject.box.x.should == 0.90 subject.box.y.should == 0.05 subject.box.w.should == 0.06745 subject.box.h.should == 0.005967 @@ -228,9 +210,22 @@ it 'accepts access credentials hash' do lambda do subject.move_marker!(10, 10, client_id: 'client_id', private_key: 'private_key') end.should_not raise_error(ArgumentError) + end + + it 'updates box coordinates if it is set' do + subject.box = { x: 1, y: 2 } + subject.move_marker! 10, 10 + subject.box.x.should == 10 + subject.box.y.should == 10 + end + + it 'creates box coordinates if it is not set' do + subject.move_marker! 10, 10 + subject.box.x.should == 10 + subject.box.y.should == 10 end end describe '#set_access!' do before(:each) do