groupdocs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.travis.yml +5 -0
  2. data/Gemfile +3 -0
  3. data/README.md +141 -0
  4. data/Rakefile +9 -0
  5. data/groupdocs.gemspec +28 -0
  6. data/lib/groupdocs.rb +53 -0
  7. data/lib/groupdocs/api.rb +3 -0
  8. data/lib/groupdocs/api/entity.rb +113 -0
  9. data/lib/groupdocs/api/helpers.rb +5 -0
  10. data/lib/groupdocs/api/helpers/access_helper.rb +56 -0
  11. data/lib/groupdocs/api/helpers/actions_helper.rb +48 -0
  12. data/lib/groupdocs/api/helpers/rest_helper.rb +89 -0
  13. data/lib/groupdocs/api/helpers/status_helper.rb +48 -0
  14. data/lib/groupdocs/api/helpers/url_helper.rb +89 -0
  15. data/lib/groupdocs/api/request.rb +73 -0
  16. data/lib/groupdocs/api/sugar/lookup.rb +48 -0
  17. data/lib/groupdocs/datasource.rb +162 -0
  18. data/lib/groupdocs/datasource/field.rb +44 -0
  19. data/lib/groupdocs/document.rb +513 -0
  20. data/lib/groupdocs/document/annotation.rb +215 -0
  21. data/lib/groupdocs/document/annotation/reply.rb +167 -0
  22. data/lib/groupdocs/document/change.rb +35 -0
  23. data/lib/groupdocs/document/field.rb +27 -0
  24. data/lib/groupdocs/document/metadata.rb +26 -0
  25. data/lib/groupdocs/document/rectangle.rb +24 -0
  26. data/lib/groupdocs/document/view.rb +36 -0
  27. data/lib/groupdocs/errors.rb +10 -0
  28. data/lib/groupdocs/job.rb +201 -0
  29. data/lib/groupdocs/questionnaire.rb +221 -0
  30. data/lib/groupdocs/questionnaire/execution.rb +120 -0
  31. data/lib/groupdocs/questionnaire/page.rb +43 -0
  32. data/lib/groupdocs/questionnaire/question.rb +75 -0
  33. data/lib/groupdocs/questionnaire/question/answer.rb +10 -0
  34. data/lib/groupdocs/storage.rb +37 -0
  35. data/lib/groupdocs/storage/file.rb +248 -0
  36. data/lib/groupdocs/storage/folder.rb +314 -0
  37. data/lib/groupdocs/storage/package.rb +42 -0
  38. data/lib/groupdocs/user.rb +50 -0
  39. data/lib/groupdocs/version.rb +3 -0
  40. data/spec/groupdocs/api/entity_spec.rb +54 -0
  41. data/spec/groupdocs/api/helpers/access_helper_spec.rb +89 -0
  42. data/spec/groupdocs/api/helpers/actions_helper_spec.rb +51 -0
  43. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +187 -0
  44. data/spec/groupdocs/api/helpers/status_helper_spec.rb +85 -0
  45. data/spec/groupdocs/api/helpers/url_helper_spec.rb +93 -0
  46. data/spec/groupdocs/api/request_spec.rb +85 -0
  47. data/spec/groupdocs/datasource/field_spec.rb +50 -0
  48. data/spec/groupdocs/datasource_spec.rb +156 -0
  49. data/spec/groupdocs/document/annotation/reply_spec.rb +179 -0
  50. data/spec/groupdocs/document/annotation_spec.rb +226 -0
  51. data/spec/groupdocs/document/change_spec.rb +35 -0
  52. data/spec/groupdocs/document/field_spec.rb +31 -0
  53. data/spec/groupdocs/document/metadata_spec.rb +26 -0
  54. data/spec/groupdocs/document/rectangle_spec.rb +34 -0
  55. data/spec/groupdocs/document/view_spec.rb +36 -0
  56. data/spec/groupdocs/document_spec.rb +509 -0
  57. data/spec/groupdocs/errors_spec.rb +7 -0
  58. data/spec/groupdocs/job_spec.rb +196 -0
  59. data/spec/groupdocs/questionnaire/execution_spec.rb +136 -0
  60. data/spec/groupdocs/questionnaire/page_spec.rb +50 -0
  61. data/spec/groupdocs/questionnaire/question/answer_spec.rb +11 -0
  62. data/spec/groupdocs/questionnaire/question_spec.rb +84 -0
  63. data/spec/groupdocs/questionnaire_spec.rb +217 -0
  64. data/spec/groupdocs/storage/file_spec.rb +242 -0
  65. data/spec/groupdocs/storage/folder_spec.rb +310 -0
  66. data/spec/groupdocs/storage/package_spec.rb +41 -0
  67. data/spec/groupdocs/storage_spec.rb +27 -0
  68. data/spec/groupdocs/user_spec.rb +53 -0
  69. data/spec/groupdocs_spec.rb +56 -0
  70. data/spec/spec_helper.rb +46 -0
  71. data/spec/support/files/resume.pdf +0 -0
  72. data/spec/support/json/annotation_collaborators_set.json +16 -0
  73. data/spec/support/json/annotation_create.json +12 -0
  74. data/spec/support/json/annotation_list.json +32 -0
  75. data/spec/support/json/annotation_remove.json +9 -0
  76. data/spec/support/json/annotation_replies_create.json +9 -0
  77. data/spec/support/json/annotation_replies_get.json +25 -0
  78. data/spec/support/json/comparison_changes.json +46 -0
  79. data/spec/support/json/comparison_compare.json +8 -0
  80. data/spec/support/json/comparison_document.json +10 -0
  81. data/spec/support/json/datasource_add.json +8 -0
  82. data/spec/support/json/datasource_get.json +22 -0
  83. data/spec/support/json/datasource_remove.json +8 -0
  84. data/spec/support/json/datasource_update.json +8 -0
  85. data/spec/support/json/document_access_info_get.json +14 -0
  86. data/spec/support/json/document_convert.json +8 -0
  87. data/spec/support/json/document_datasource.json +10 -0
  88. data/spec/support/json/document_fields.json +34 -0
  89. data/spec/support/json/document_formats.json +8 -0
  90. data/spec/support/json/document_metadata.json +15 -0
  91. data/spec/support/json/document_questionnaire_create.json +9 -0
  92. data/spec/support/json/document_questionnaires.json +23 -0
  93. data/spec/support/json/document_sharers_remove.json +8 -0
  94. data/spec/support/json/document_sharers_set.json +16 -0
  95. data/spec/support/json/document_views.json +32 -0
  96. data/spec/support/json/file_compress.json +8 -0
  97. data/spec/support/json/file_copy.json +14 -0
  98. data/spec/support/json/file_delete.json +5 -0
  99. data/spec/support/json/file_move.json +14 -0
  100. data/spec/support/json/file_upload.json +8 -0
  101. data/spec/support/json/folder_create.json +8 -0
  102. data/spec/support/json/folder_delete.json +5 -0
  103. data/spec/support/json/folder_list.json +21 -0
  104. data/spec/support/json/folder_move.json +8 -0
  105. data/spec/support/json/folder_sharers_get.json +16 -0
  106. data/spec/support/json/folder_sharers_remove.json +8 -0
  107. data/spec/support/json/folder_sharers_set.json +16 -0
  108. data/spec/support/json/job_add_url.json +8 -0
  109. data/spec/support/json/job_create.json +8 -0
  110. data/spec/support/json/job_documents.json +39 -0
  111. data/spec/support/json/job_file_add.json +8 -0
  112. data/spec/support/json/job_update.json +7 -0
  113. data/spec/support/json/jobs_get.json +52 -0
  114. data/spec/support/json/package_create.json +7 -0
  115. data/spec/support/json/questionnaire_create.json +8 -0
  116. data/spec/support/json/questionnaire_datasources.json +26 -0
  117. data/spec/support/json/questionnaire_execution_create.json +9 -0
  118. data/spec/support/json/questionnaire_execution_status_set.json +8 -0
  119. data/spec/support/json/questionnaire_execution_update.json +8 -0
  120. data/spec/support/json/questionnaire_executions.json +24 -0
  121. data/spec/support/json/questionnaire_get.json +14 -0
  122. data/spec/support/json/questionnaire_remove.json +8 -0
  123. data/spec/support/json/questionnaire_update.json +8 -0
  124. data/spec/support/json/questionnaires_get.json +22 -0
  125. data/spec/support/json/storage_info.json +10 -0
  126. data/spec/support/shared_examples/api/entity.rb +37 -0
  127. data/spec/support/shared_examples/api/helpers/status_helper.rb +12 -0
  128. data/spec/support/shared_examples/api/sugar/lookup.rb +57 -0
  129. metadata +356 -0
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Api::Request do
4
+
5
+ subject { described_class.new(method: :GET, path: '/folders') }
6
+
7
+ it { should respond_to(:resource) }
8
+ it { should respond_to(:response) }
9
+ it { should respond_to(:response=) }
10
+ it { should respond_to(:options) }
11
+ it { should respond_to(:options=) }
12
+
13
+ describe '#initialize' do
14
+ it 'allows passing options' do
15
+ options = { method: :GET, path: '/folders' }
16
+ request = described_class.new(options)
17
+ request.options.should == options
18
+ end
19
+
20
+ it 'allows passing block to configure options' do
21
+ described_class.new do |request|
22
+ request[:access] = { client_id: 'client_id', private_key: 'private_key' }
23
+ request[:method] = :GET
24
+ request[:path] = '/folders'
25
+ end.options.should == { method: :GET, path: '/folders', access: { client_id: 'client_id', private_key: 'private_key' }}
26
+ end
27
+
28
+ it 'sets access hash to empty if it was not passed' do
29
+ access = subject.options[:access]
30
+ access.should be_a(Hash)
31
+ access.should be_empty
32
+ end
33
+
34
+ it 'creates resource as API server' do
35
+ GroupDocs.stub(api_server: 'https://dev-api.groupdocs.com')
36
+ subject.resource.should be_a(RestClient::Resource)
37
+ end
38
+ end
39
+
40
+ describe '#execute!' do
41
+ before(:each) do
42
+ GroupDocs.stub(private_key: 'private_key')
43
+ subject.options[:method] = :get
44
+ subject.options[:path] = '/folders'
45
+ subject.options[:headers] = {}
46
+ mock_api_server('{"status":"Ok"}')
47
+ end
48
+
49
+ it 'parses path' do
50
+ subject.should_receive(:parse_path)
51
+ subject.execute!
52
+ end
53
+
54
+ it 'prepends path with version' do
55
+ subject.should_receive(:prepend_version)
56
+ subject.execute!
57
+ end
58
+
59
+ it 'URL encodes path' do
60
+ subject.should_receive(:url_encode_path)
61
+ subject.execute!
62
+ end
63
+
64
+ it 'signs url' do
65
+ subject.should_receive(:sign_url)
66
+ subject.execute!
67
+ end
68
+
69
+ it 'prepares request' do
70
+ subject.should_receive(:prepare_request)
71
+ subject.execute!
72
+ end
73
+
74
+ it 'sends request' do
75
+ subject.should_receive(:send_request)
76
+ mock_response('{"status": "Ok"}')
77
+ subject.execute!
78
+ end
79
+
80
+ it 'parses response' do
81
+ subject.should_receive(:parse_response)
82
+ subject.execute!
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::DataSource::Field do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ describe 'TYPES' do
8
+ it 'contains hash of field types' do
9
+ described_class::TYPES.should == {
10
+ text: 0,
11
+ binary: 1,
12
+ }
13
+ end
14
+ end
15
+
16
+ it { should respond_to(:field) }
17
+ it { should respond_to(:field=) }
18
+ it { should respond_to(:type) }
19
+ it { should respond_to(:type=) }
20
+ it { should respond_to(:values) }
21
+ it { should respond_to(:values=) }
22
+
23
+ it 'is compatible with response JSON' do
24
+ subject.should respond_to(:name=)
25
+ subject.method(:name=).should == subject.method(:field=)
26
+ end
27
+
28
+ describe '#type=' do
29
+ it 'saves type in machine readable format if symbol is passed' do
30
+ subject.type = :binary
31
+ subject.instance_variable_get(:@type).should == 1
32
+ end
33
+
34
+ it 'does nothing if parameter is not symbol' do
35
+ subject.type = 1
36
+ subject.instance_variable_get(:@type).should == 1
37
+ end
38
+
39
+ it 'raises error if type is unknown' do
40
+ -> { subject.type = :unknown }.should raise_error(ArgumentError)
41
+ end
42
+ end
43
+
44
+ describe '#type' do
45
+ it 'returns type in human-readable format' do
46
+ subject.type = 1
47
+ subject.type.should == :binary
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,156 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::DataSource do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ describe '.get!' do
8
+ before(:each) do
9
+ mock_api_server(load_json('datasource_get'))
10
+ end
11
+
12
+ it 'accepts access credentials hash' do
13
+ lambda do
14
+ described_class.get!(1, {}, client_id: 'client_id', private_key: 'private_key')
15
+ end.should_not raise_error(ArgumentError)
16
+ end
17
+
18
+ it 'accepts options hash' do
19
+ lambda do
20
+ described_class.get!(1, fields: %w(field1 field2))
21
+ end.should_not raise_error(ArgumentError)
22
+ end
23
+
24
+ it 'returns GroupDocs::DataSource object if datasource is found' do
25
+ described_class.get!(1).should be_a(GroupDocs::DataSource)
26
+ end
27
+
28
+ it 'returns nil if datasource was not found' do
29
+ mock_api_server('{"result": {"datasource": null}, "status": "Failed"}')
30
+ described_class.get!(99).should be_nil
31
+ end
32
+ end
33
+
34
+ it { should respond_to(:id) }
35
+ it { should respond_to(:id=) }
36
+ it { should respond_to(:descr) }
37
+ it { should respond_to(:descr=) }
38
+ it { should respond_to(:questionnaire_id) }
39
+ it { should respond_to(:questionnaire_id=) }
40
+ it { should respond_to(:created_on) }
41
+ it { should respond_to(:created_on=) }
42
+ it { should respond_to(:modified_on) }
43
+ it { should respond_to(:modified_on=) }
44
+ it { should respond_to(:fields) }
45
+ it { should respond_to(:fields=) }
46
+
47
+ it 'has human-readable accessors' do
48
+ subject.should respond_to(:description)
49
+ subject.should respond_to(:description=)
50
+ subject.method(:description).should == subject.method(:descr)
51
+ subject.method(:description=).should == subject.method(:descr=)
52
+ end
53
+
54
+ describe '#created_on' do
55
+ it 'returns converted to Time object Unix timestamp' do
56
+ subject.created_on = 1332950825
57
+ subject.created_on.should be_a(Time)
58
+ end
59
+ end
60
+
61
+ describe '#modified_on' do
62
+ it 'returns converted to Time object Unix timestamp' do
63
+ subject.modified_on = 1332950825
64
+ subject.modified_on.should be_a(Time)
65
+ end
66
+ end
67
+
68
+ describe '#fields=' do
69
+ it 'converts each field to GroupDocs::DataSource::Field object if hash is passed' do
70
+ subject.fields = [{ name: 'field1', values: %w(value1 value2), type: 1 }]
71
+ fields = subject.fields
72
+ fields.should be_an(Array)
73
+ fields.each do |field|
74
+ field.should be_a(GroupDocs::DataSource::Field)
75
+ end
76
+ end
77
+
78
+ it 'saves each field if it is GroupDocs::DataSource::Field object' do
79
+ field1 = GroupDocs::DataSource::Field.new(name: 'field1')
80
+ field2 = GroupDocs::DataSource::Field.new(name: 'field2')
81
+ subject.fields = [field1, field2]
82
+ subject.fields.should include(field1)
83
+ subject.fields.should include(field2)
84
+ end
85
+
86
+ it 'does nothing if nil is passed' do
87
+ lambda do
88
+ subject.fields = nil
89
+ end.should_not change(subject, :fields)
90
+ end
91
+ end
92
+
93
+ describe '#add_field' do
94
+ it 'raises error if field is not GroupDocs::DataSource::Field object' do
95
+ -> { subject.add_field('Field') }.should raise_error(ArgumentError)
96
+ end
97
+
98
+ it 'saves field' do
99
+ field = GroupDocs::DataSource::Field.new
100
+ subject.add_field(field)
101
+ subject.fields.should == [field]
102
+ end
103
+ end
104
+
105
+ describe '#add!' do
106
+ before(:each) do
107
+ mock_api_server(load_json('datasource_add'))
108
+ end
109
+
110
+ it 'accepts access credentials hash' do
111
+ lambda do
112
+ subject.add!(client_id: 'client_id', private_key: 'private_key')
113
+ end.should_not raise_error(ArgumentError)
114
+ end
115
+
116
+ it 'uses hashed version of self as request body' do
117
+ subject.should_receive(:to_hash)
118
+ subject.add!
119
+ end
120
+
121
+ it 'adds ID of datasource from response to self' do
122
+ lambda do
123
+ subject.add!
124
+ end.should change(subject, :id)
125
+ end
126
+ end
127
+
128
+ describe '#update!' do
129
+ before(:each) do
130
+ mock_api_server(load_json('datasource_update'))
131
+ end
132
+
133
+ it 'accepts access credentials hash' do
134
+ lambda do
135
+ subject.update!(client_id: 'client_id', private_key: 'private_key')
136
+ end.should_not raise_error(ArgumentError)
137
+ end
138
+
139
+ it 'uses hashed version of self as request body' do
140
+ subject.should_receive(:to_hash)
141
+ subject.add!
142
+ end
143
+ end
144
+
145
+ describe '#remove!' do
146
+ before(:each) do
147
+ mock_api_server(load_json('datasource_remove'))
148
+ end
149
+
150
+ it 'accepts access credentials hash' do
151
+ lambda do
152
+ subject.remove!(client_id: 'client_id', private_key: 'private_key')
153
+ end.should_not raise_error(ArgumentError)
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,179 @@
1
+ require 'spec_helper'
2
+
3
+ describe GroupDocs::Document::Annotation::Reply do
4
+
5
+ it_behaves_like GroupDocs::Api::Entity
6
+
7
+ subject do
8
+ file = GroupDocs::Storage::File.new
9
+ document = GroupDocs::Document.new(file: file)
10
+ annotation = GroupDocs::Document::Annotation.new(document: document)
11
+ described_class.new(annotation: annotation)
12
+ end
13
+
14
+ describe '.get!' do
15
+ before(:each) do
16
+ mock_api_server(load_json('annotation_replies_get'))
17
+ end
18
+
19
+ let(:annotation) do
20
+ document = GroupDocs::Document.new(file: GroupDocs::Storage::File.new)
21
+ GroupDocs::Document::Annotation.new(document: document)
22
+ end
23
+
24
+ it 'accepts access credentials hash' do
25
+ lambda do
26
+ described_class.get!(annotation, {}, client_id: 'client_id', private_key: 'private_key')
27
+ end.should_not raise_error(ArgumentError)
28
+ end
29
+
30
+ it 'accepts options hash' do
31
+ lambda do
32
+ described_class.get!(annotation, after: Time.now)
33
+ end.should_not raise_error(ArgumentError)
34
+ end
35
+
36
+ it 'raises error if annotation is not an instance of GroupDocs::Document::Annotation' do
37
+ -> { described_class.get!('Annotation') }.should raise_error(ArgumentError)
38
+ end
39
+
40
+ it 'raises error if option :after is not an instance of Time' do
41
+ -> { described_class.get!(annotation, after: 'Yesterday') }.should raise_error(ArgumentError)
42
+ end
43
+
44
+ it 'converts option :after to Unix timestamp' do
45
+ time = Time.now
46
+ time.should_receive(:to_i).and_return(1334125808)
47
+ described_class.get!(annotation, after: time)
48
+ end
49
+
50
+ it 'returns an array of GroupDocs::Document::Annotation::Reply objects' do
51
+ replies = described_class.get!(annotation)
52
+ replies.should be_an(Array)
53
+ replies.each do |reply|
54
+ reply.should be_a(GroupDocs::Document::Annotation::Reply)
55
+ end
56
+ end
57
+ end
58
+
59
+ it { should respond_to(:annotation) }
60
+ it { should respond_to(:annotation=) }
61
+ it { should respond_to(:text) }
62
+ it { should respond_to(:text=) }
63
+ it { should respond_to(:guid) }
64
+ it { should respond_to(:guid=) }
65
+ it { should respond_to(:annotationGuid) }
66
+ it { should respond_to(:annotationGuid=) }
67
+ it { should respond_to(:userGuid) }
68
+ it { should respond_to(:userGuid=) }
69
+ it { should respond_to(:userName) }
70
+ it { should respond_to(:userName=) }
71
+ it { should respond_to(:text) }
72
+ it { should respond_to(:text=) }
73
+ it { should respond_to(:repliedOn) }
74
+ it { should respond_to(:repliedOn=) }
75
+
76
+ it 'has human-readable accessors' do
77
+ subject.should respond_to(:annotation_guid)
78
+ subject.should respond_to(:annotation_guid=)
79
+ subject.should respond_to(:user_guid)
80
+ subject.should respond_to(:user_guid=)
81
+ subject.should respond_to(:user_name)
82
+ subject.should respond_to(:user_name=)
83
+ subject.should respond_to(:replied_on)
84
+ subject.should respond_to(:replied_on=)
85
+ subject.method(:annotation_guid).should == subject.method(:annotationGuid)
86
+ subject.method(:annotation_guid=).should == subject.method(:annotationGuid=)
87
+ subject.method(:user_guid).should == subject.method(:userGuid)
88
+ subject.method(:user_guid=).should == subject.method(:userGuid=)
89
+ subject.method(:user_name).should == subject.method(:userName)
90
+ subject.method(:user_name=).should == subject.method(:userName=)
91
+ # Reply#replied_on is overwritten
92
+ subject.method(:replied_on=).should == subject.method(:repliedOn=)
93
+ end
94
+
95
+ describe '#initialize' do
96
+ it 'raises error if annotation is not specified' do
97
+ -> { described_class.new }.should raise_error(ArgumentError)
98
+ end
99
+
100
+ it 'raises error if annotation is not an instance of GroupDocs::Document::Annotation' do
101
+ -> { described_class.new(annotation: '') }.should raise_error(ArgumentError)
102
+ end
103
+ end
104
+
105
+ describe '#replied_on' do
106
+ it 'returns converted to Time object Unix timestamp' do
107
+ subject.replied_on = 1332950825
108
+ subject.replied_on.should be_a(Time)
109
+ end
110
+
111
+ it 'divides timestamp by 1000 because it is in milliseconds' do
112
+ subject.replied_on = 1332950825000
113
+ subject.replied_on.should == Time.at(1332950825)
114
+ end
115
+ end
116
+
117
+ describe '#create!' do
118
+ before(:each) do
119
+ mock_api_server(load_json('annotation_replies_create'))
120
+ end
121
+
122
+ it 'accepts access credentials hash' do
123
+ lambda do
124
+ subject.create!(client_id: 'client_id', private_key: 'private_key')
125
+ end.should_not raise_error(ArgumentError)
126
+ end
127
+
128
+ it 'gets annotation guid' do
129
+ subject.should_receive(:get_annotation_guid)
130
+ subject.create!
131
+ end
132
+
133
+ it 'updates guid and annotation_guid with response' do
134
+ lambda do
135
+ subject.create!
136
+ end.should change {
137
+ subject.guid
138
+ subject.annotation_guid
139
+ }
140
+ end
141
+ end
142
+
143
+ describe '#edit!' do
144
+ before(:each) do
145
+ mock_api_server('{"result": {}, "status": "Ok", "error_message": null}')
146
+ end
147
+
148
+ it 'accepts access credentials hash' do
149
+ lambda do
150
+ subject.edit!(client_id: 'client_id', private_key: 'private_key')
151
+ end.should_not raise_error(ArgumentError)
152
+ end
153
+ end
154
+
155
+ describe '#remove!' do
156
+ before(:each) do
157
+ mock_api_server('{"result": {}, "status": "Ok", "error_message": null}')
158
+ end
159
+
160
+ it 'accepts access credentials hash' do
161
+ lambda do
162
+ subject.remove!(client_id: 'client_id', private_key: 'private_key')
163
+ end.should_not raise_error(ArgumentError)
164
+ end
165
+ end
166
+
167
+ describe '#get_annotation_guid' do
168
+ it 'prefers annotation_guid over annotation.guid' do
169
+ subject.annotation_guid = 'abc'
170
+ subject.annotation.guid = 'def'
171
+ subject.send(:get_annotation_guid).should == 'abc'
172
+ end
173
+
174
+ it 'returns annotation.guid if annotation_guid is not set' do
175
+ subject.annotation.guid = 'def'
176
+ subject.send(:get_annotation_guid).should == 'def'
177
+ end
178
+ end
179
+ end