osc_ruby 0.7.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +25 -25
- data/.gitignore +15 -15
- data/.rspec +1 -1
- data/.rubocop.yml +1156 -1156
- data/.travis.yml +9 -9
- data/Gemfile +3 -3
- data/License.txt +21 -0
- data/README.md +95 -242
- data/Rakefile +2 -2
- data/lib/ext/string.rb +18 -18
- data/lib/osc_ruby/classes/query_results.rb +40 -60
- data/lib/osc_ruby/client.rb +40 -40
- data/lib/osc_ruby/configuration.rb +14 -13
- data/lib/osc_ruby/connect.rb +218 -209
- data/lib/osc_ruby/modules/normalize_module.rb +121 -121
- data/lib/osc_ruby/modules/query_module.rb +69 -69
- data/lib/osc_ruby/modules/validations_module.rb +168 -168
- data/lib/osc_ruby/version.rb +2 -2
- data/lib/osc_ruby.rb +4 -10
- data/osc_ruby.gemspec +28 -29
- data/spec/core/client_spec.rb +96 -96
- data/spec/core/configuration_spec.rb +4 -4
- data/spec/core/connect_spec.rb +366 -364
- data/spec/core/query_results_spec.rb +107 -133
- data/spec/core/spec_helper.rb +25 -25
- data/tasks/rspec.rake +2 -2
- metadata +23 -22
- data/LICENSE.txt +0 -22
- data/lib/osc_ruby/classes/account.rb +0 -75
- data/lib/osc_ruby/classes/answer.rb +0 -117
- data/lib/osc_ruby/classes/incident.rb +0 -13
- data/lib/osc_ruby/classes/product_category_shared.rb +0 -118
- data/lib/osc_ruby/classes/service_category.rb +0 -6
- data/lib/osc_ruby/classes/service_class.rb +0 -66
- data/lib/osc_ruby/classes/service_product.rb +0 -6
- data/lib/osc_ruby/modules/class_factory_module.rb +0 -165
- data/lib/osc_ruby/modules/nested_resource_module.rb +0 -10
- data/spec/core/account_spec.rb +0 -497
- data/spec/core/answer_spec.rb +0 -545
- data/spec/core/service_category_spec.rb +0 -445
- data/spec/core/service_product_spec.rb +0 -443
data/spec/core/answer_spec.rb
DELETED
@@ -1,545 +0,0 @@
|
|
1
|
-
require 'core/spec_helper'
|
2
|
-
require 'json'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
describe OSCRuby::Answer do
|
6
|
-
|
7
|
-
let(:answer){
|
8
|
-
|
9
|
-
OSCRuby::Answer.new
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
context '#initialize' do
|
14
|
-
|
15
|
-
it 'should not throw an error when initialized' do
|
16
|
-
|
17
|
-
expect{answer}.not_to raise_error
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should initialize with answerType as a hash, language as a hash, and summary as a string' do
|
22
|
-
|
23
|
-
expect(answer.answerType).to eq({})
|
24
|
-
|
25
|
-
expect(answer.language).to eq({})
|
26
|
-
|
27
|
-
expect(answer.summary).to eq('Answer summary text')
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
# let(:attributes){
|
34
|
-
# {
|
35
|
-
# "id"=> 2222,
|
36
|
-
# "lookupName"=> 2222,
|
37
|
-
# "createdTime"=> "2014-02-05T23:42:28Z",
|
38
|
-
# "updatedTime"=> "2016-12-13T09:55:45Z",
|
39
|
-
# "accessLevels"=> 3,
|
40
|
-
# "adminLastAccessTime"=> "2016-11-23T22:54:26Z",
|
41
|
-
# "answerType"=> 1,
|
42
|
-
# "expiresDate"=> nil,
|
43
|
-
# "guidedAssistance"=> nil,
|
44
|
-
# "keywords"=> "AbCbEbAb",
|
45
|
-
# "language"=> 1,
|
46
|
-
# "lastAccessTime"=> "2016-12-10T07:27:37Z",
|
47
|
-
# "lastNotificationTime"=> nil,
|
48
|
-
# "name"=> 2222,
|
49
|
-
# "nextNotificationTime"=> nil,
|
50
|
-
# "originalReferenceNumber"=> nil,
|
51
|
-
# "positionInList"=> 1,
|
52
|
-
# "publishOnDate"=> nil,
|
53
|
-
# "question"=> nil,
|
54
|
-
# "solution"=> "<p ></iframe></p>\n<ol>\n<li>\n<div class=\"MsoNormal\" >The following video will show you how to view your DVR using the QT view app or through a Browser using the Q-See Scan n View P2P technology.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step1.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >P2P equals Peer to Peer. This concept has been around for a long time.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step2.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >P2P equals Peer to Peer. In a peer to peer network, tasks (such as searching for files or streaming audio/video) are shared amongst multiple interconnected peers who each make a portion of their resources (such as processing power, Disk Storage or network bandwidth) directly available to other Network participants, without the need for centralized coordination by servers.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step3.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Q-See's application is to take the Port Forwarding process out of the hands of the End User.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step4.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Next, you will need to install your QT View app via the Apple App Store or the Google Play Store.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step5.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Once the DVR is connected and is powered up, you will go through the wizard.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6a.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6b.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6c.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >While going through the wizard you will need to select your device to fit the the QR Code.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6d.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6e.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then go to your QT View and tap on the QR code image.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step7.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Now, your scanner will come up, then scan the QR code.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step8.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >The MAC address will appear, then enter the DVR's user name and password.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step9.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then Tap Login.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step10.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >After a few moments you will then be able to see the cameras without having to access the router.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step11.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >How to access it for PC/MAC.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step12.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Open Browser. Enter qtview.com, Push enter. NOTE: YOU WILL STILL NEED TO ADD IN THE ACTIVE X OR IE PLUG IN FOR YOUR BROWSER.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step13.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Enter the MAC address, User name, and Password, then click LOGIN.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step14.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then you will be able to see your system.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step15.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Q-See Scan n View.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step16.png\" /></p>\n</li>\n</ol>",
|
55
|
-
# "summary"=> "QT Series: (VIDEO) Scan 'N View Setup",
|
56
|
-
# "updatedByAccount"=> 47,
|
57
|
-
# "uRL"=> nil
|
58
|
-
# }
|
59
|
-
# }
|
60
|
-
|
61
|
-
# context '#new_from_fetch' do
|
62
|
-
|
63
|
-
# it 'should accept an attributes as a hash' do
|
64
|
-
|
65
|
-
# expect do
|
66
|
-
|
67
|
-
# attributes = []
|
68
|
-
|
69
|
-
# OSCRuby::Answer.new_from_fetch(attributes)
|
70
|
-
|
71
|
-
# end.to raise_error("Attributes must be a hash; please use the appropriate data structure")
|
72
|
-
|
73
|
-
# expect do
|
74
|
-
|
75
|
-
# OSCRuby::Answer.new_from_fetch(attributes)
|
76
|
-
|
77
|
-
# end.not_to raise_error
|
78
|
-
|
79
|
-
# end
|
80
|
-
|
81
|
-
# it 'should instantiate an id, lookupName, createdTime, updatedTime, accessLevels, adminLastAccessTime, answerType, expiresDate, guidedAssistance, keywords, language, lastAccessTime, lastNotificationTime, name, nextNotificationTime, originalReferenceNumber, positionInList, publishOnDate, question, solution, summary, updatedByAccount, uRL with the correct values' do
|
82
|
-
|
83
|
-
# test = OSCRuby::Answer.new_from_fetch(attributes)
|
84
|
-
|
85
|
-
# expect(test.id).to eq(2222)
|
86
|
-
# expect(test.lookupName).to eq(2222)
|
87
|
-
# expect(test.createdTime).to eq("2014-02-05T23:42:28Z")
|
88
|
-
# expect(test.updatedTime).to eq("2016-12-13T09:55:45Z")
|
89
|
-
# expect(test.accessLevels).to eq(3)
|
90
|
-
# expect(test.adminLastAccessTime).to eq("2016-11-23T22:54:26Z")
|
91
|
-
# expect(test.answerType).to eq(1)
|
92
|
-
# expect(test.expiresDate).to eq(nil)
|
93
|
-
# expect(test.guidedAssistance).to eq(nil)
|
94
|
-
# expect(test.keywords).to eq("AbCbEbAb")
|
95
|
-
# expect(test.language).to eq(1)
|
96
|
-
# expect(test.lastAccessTime).to eq("2016-12-10T07:27:37Z")
|
97
|
-
# expect(test.lastNotificationTime).to eq(nil)
|
98
|
-
# expect(test.name).to eq(2222)
|
99
|
-
# expect(test.nextNotificationTime).to eq(nil)
|
100
|
-
# expect(test.originalReferenceNumber).to eq(nil)
|
101
|
-
# expect(test.positionInList).to eq(1)
|
102
|
-
# expect(test.publishOnDate).to eq(nil)
|
103
|
-
# expect(test.question).to eq(nil)
|
104
|
-
# expect(test.solution).to eq("<p ></iframe></p>\n<ol>\n<li>\n<div class=\"MsoNormal\" >The following video will show you how to view your DVR using the QT view app or through a Browser using the Q-See Scan n View P2P technology.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step1.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >P2P equals Peer to Peer. This concept has been around for a long time.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step2.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >P2P equals Peer to Peer. In a peer to peer network, tasks (such as searching for files or streaming audio/video) are shared amongst multiple interconnected peers who each make a portion of their resources (such as processing power, Disk Storage or network bandwidth) directly available to other Network participants, without the need for centralized coordination by servers.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step3.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Q-See's application is to take the Port Forwarding process out of the hands of the End User.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step4.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Next, you will need to install your QT View app via the Apple App Store or the Google Play Store.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step5.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Once the DVR is connected and is powered up, you will go through the wizard.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6a.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6b.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6c.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >While going through the wizard you will need to select your device to fit the the QR Code.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6d.png\" /></p>\n<div class=\"MsoNormal\" ></div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step6e.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then go to your QT View and tap on the QR code image.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step7.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Now, your scanner will come up, then scan the QR code.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step8.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >The MAC address will appear, then enter the DVR's user name and password.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step9.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then Tap Login.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step10.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >After a few moments you will then be able to see the cameras without having to access the router.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step11.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >How to access it for PC/MAC.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step12.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Open Browser. Enter qtview.com, Push enter. NOTE: YOU WILL STILL NEED TO ADD IN THE ACTIVE X OR IE PLUG IN FOR YOUR BROWSER.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step13.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Enter the MAC address, User name, and Password, then click LOGIN.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step14.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Then you will be able to see your system.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step15.png\" /></p>\n</li>\n<li>\n<div class=\"MsoNormal\" >Q-See Scan n View.</div>\n<p align=\"center\"><img border=\"0\" alt=\"Image\" src=\"//q-see.s3.amazonaws.com/content/files/HowToFiles/p2pimages/Step16.png\" /></p>\n</li>\n</ol>")
|
105
|
-
# expect(test.summary).to eq("QT Series: (VIDEO) Scan 'N View Setup")
|
106
|
-
# expect(test.updatedByAccount).to eq(47)
|
107
|
-
# expect(test.uRL).to eq(nil)
|
108
|
-
|
109
|
-
# end
|
110
|
-
|
111
|
-
# end
|
112
|
-
|
113
|
-
let(:client) {
|
114
|
-
|
115
|
-
OSCRuby::Client.new do |config|
|
116
|
-
|
117
|
-
config.interface = ENV['OSC_TEST1_SITE']
|
118
|
-
|
119
|
-
config.username = ENV['OSC_ADMIN']
|
120
|
-
|
121
|
-
config.password = ENV['OSC_PASSWORD']
|
122
|
-
|
123
|
-
end
|
124
|
-
}
|
125
|
-
|
126
|
-
let(:new_answer){
|
127
|
-
OSCRuby::Answer.new
|
128
|
-
}
|
129
|
-
|
130
|
-
context '#create' do
|
131
|
-
|
132
|
-
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
|
133
|
-
|
134
|
-
expect(client).to be_an(OSCRuby::Client)
|
135
|
-
|
136
|
-
client = nil
|
137
|
-
|
138
|
-
expect{new_answer.create(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'should check the object and make sure that it at least has a language, answerType, and summary set', :vcr do
|
143
|
-
|
144
|
-
expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
|
145
|
-
|
146
|
-
new_answer.language['id'] = 1
|
147
|
-
|
148
|
-
expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
|
149
|
-
|
150
|
-
new_answer.answerType['id'] = 1
|
151
|
-
|
152
|
-
# the Answer summary is defaulted to "Answer summary text" so it should pass here
|
153
|
-
|
154
|
-
expect{new_answer.create(client)}.to_not raise_error
|
155
|
-
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'should expect the language as a hash with an id as a key with a value of a number' do
|
159
|
-
|
160
|
-
new_answer.language['id'] = "new answer name"
|
161
|
-
new_answer.answerType['id'] = 1
|
162
|
-
|
163
|
-
expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'should expect the answerType as a hash with an id as a key with a value of a number' do
|
168
|
-
|
169
|
-
new_answer.language['id'] = 1
|
170
|
-
new_answer.answerType['id'] = "new answer name"
|
171
|
-
|
172
|
-
expect{new_answer.create(client)}.to raise_error('Answer should at least the language, answerType, and summary set (new_answer.language = {"id" => 1}; new_answer.answerType = {"id" => 1}}; new_answer.summary = "This is the Answer Title")')
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'should expect the answerType as a hash with an lookupName as a key with a value of "HTML","URL", or "File Attachment"', :vcr do
|
177
|
-
|
178
|
-
new_answer.language['id'] = 1
|
179
|
-
new_answer.answerType['lookupName'] = "HTML"
|
180
|
-
|
181
|
-
expect{new_answer.create(client)}.not_to raise_error
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
it 'should expect the categories to be an array' do
|
186
|
-
|
187
|
-
expect(new_answer.categories).to be_an(Array)
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
|
-
it 'should expect that a hash with an id key for categories should create an answer without issue', :vcr do
|
192
|
-
|
193
|
-
new_answer.language['id'] = 1
|
194
|
-
new_answer.answerType['lookupName'] = "HTML"
|
195
|
-
|
196
|
-
new_answer.categories[0] = {'id' => 6}
|
197
|
-
|
198
|
-
new_answer.create(client)
|
199
|
-
|
200
|
-
expect(new_answer).to be_a(OSCRuby::Answer)
|
201
|
-
|
202
|
-
end
|
203
|
-
|
204
|
-
it 'should return an instance of an OSCRuby::Answer if the json_response param is set to false (which it is by default)', :vcr do
|
205
|
-
|
206
|
-
new_answer.language['id'] = 1
|
207
|
-
new_answer.answerType['lookupName'] = "HTML"
|
208
|
-
|
209
|
-
10.times do |test|
|
210
|
-
new_answer.create(client)
|
211
|
-
end
|
212
|
-
|
213
|
-
expect(new_answer).to be_a(OSCRuby::Answer)
|
214
|
-
|
215
|
-
expect(new_answer.summary).to eq("Answer summary text")
|
216
|
-
|
217
|
-
expect(new_answer.language).to eq({"id"=>1})
|
218
|
-
|
219
|
-
end
|
220
|
-
|
221
|
-
# it 'should be able to set the status of an answer', do
|
222
|
-
|
223
|
-
# new_answer.language['id'] = 1
|
224
|
-
# new_answer.answerType['lookupName'] = "HTML"
|
225
|
-
|
226
|
-
# new_answer.create(client)
|
227
|
-
|
228
|
-
# expect(new_answer).to be_a(OSCRuby::Answer)
|
229
|
-
|
230
|
-
# end
|
231
|
-
|
232
|
-
|
233
|
-
it 'should print the body object if the json_response param is set to true', :vcr do
|
234
|
-
|
235
|
-
new_answer.language['id'] = 1
|
236
|
-
new_answer.answerType['lookupName'] = "HTML"
|
237
|
-
|
238
|
-
expect(new_answer.create(client,true)).to be_a(OSCRuby::Answer)
|
239
|
-
|
240
|
-
10.times do |test|
|
241
|
-
new_answer.create(client,true)
|
242
|
-
end
|
243
|
-
|
244
|
-
end
|
245
|
-
|
246
|
-
|
247
|
-
it 'should return the answer attrs and assign them to the answer object', :vcr do
|
248
|
-
|
249
|
-
new_answer.language['id'] = 1
|
250
|
-
new_answer.answerType['lookupName'] = "HTML"
|
251
|
-
|
252
|
-
new_answer.create(client,true)
|
253
|
-
|
254
|
-
expect(new_answer.id).to_not be(nil)
|
255
|
-
|
256
|
-
end
|
257
|
-
|
258
|
-
end
|
259
|
-
|
260
|
-
context '#find' do
|
261
|
-
|
262
|
-
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
|
263
|
-
|
264
|
-
expect(client).to be_an(OSCRuby::Client)
|
265
|
-
|
266
|
-
client = nil
|
267
|
-
|
268
|
-
expect{OSCRuby::Answer.find(client,100)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
269
|
-
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'should raise an error if ID is undefined' do
|
273
|
-
|
274
|
-
expect{OSCRuby::Answer.find(client)}.to raise_error('ID cannot be nil')
|
275
|
-
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'should raise an error if ID is not an integer' do
|
279
|
-
|
280
|
-
expect{OSCRuby::Answer.find(client, 'a')}.to raise_error('ID must be an integer')
|
281
|
-
|
282
|
-
end
|
283
|
-
|
284
|
-
it 'should return a warning if empty/no instances of the object can be found', :vcr do
|
285
|
-
|
286
|
-
expect{OSCRuby::Answer.find(client, 100)}.to raise_error('There were no objects matching your query; please try again.')
|
287
|
-
|
288
|
-
end
|
289
|
-
|
290
|
-
|
291
|
-
it 'should return an instance of a new OSCRuby::Answer object with at least a name and displayOrder', :vcr do
|
292
|
-
|
293
|
-
known_working_answer = OSCRuby::Answer.find(client, 2222)
|
294
|
-
|
295
|
-
expect(known_working_answer).to be_an(OSCRuby::Answer)
|
296
|
-
expect(known_working_answer.id).to eq(2222)
|
297
|
-
expect(known_working_answer.lookupName).to eq(2222)
|
298
|
-
expect(known_working_answer.createdTime).to eq("2014-02-05T23:42:28Z")
|
299
|
-
expect(known_working_answer.accessLevels).to eq(3)
|
300
|
-
expect(known_working_answer.answerType).to eq(1)
|
301
|
-
expect(known_working_answer.expiresDate).to eq(nil)
|
302
|
-
expect(known_working_answer.guidedAssistance).to eq(nil)
|
303
|
-
expect(known_working_answer.keywords).to eq("AbCbEbAb")
|
304
|
-
expect(known_working_answer.language).to eq(1)
|
305
|
-
expect(known_working_answer.lastNotificationTime).to eq(nil)
|
306
|
-
expect(known_working_answer.name).to eq(2222)
|
307
|
-
expect(known_working_answer.nextNotificationTime).to eq(nil)
|
308
|
-
expect(known_working_answer.originalReferenceNumber).to eq(nil)
|
309
|
-
expect(known_working_answer.positionInList).to eq(1)
|
310
|
-
expect(known_working_answer.publishOnDate).to eq(nil)
|
311
|
-
expect(known_working_answer.question).to eq(nil)
|
312
|
-
expect(known_working_answer.summary).to eq("QT Series: (VIDEO) Scan 'N View Setup")
|
313
|
-
expect(known_working_answer.uRL).to eq(nil)
|
314
|
-
|
315
|
-
# not a very reliable metrics.....
|
316
|
-
# expect(known_working_answer.updatedByAccount).to eq(47)
|
317
|
-
# expect(known_working_answer.updatedTime).to eq("2016-12-13T09:55:45Z")
|
318
|
-
# expect(known_working_answer.adminLastAccessTime).to eq("2016-11-23T22:54:26Z")
|
319
|
-
# expect(known_working_answer.lastAccessTime).to eq("2016-12-10T07:27:37Z")
|
320
|
-
|
321
|
-
end
|
322
|
-
|
323
|
-
it 'should return the raw json response if the return_json parameter is set to true', :vcr do
|
324
|
-
|
325
|
-
known_working_answer_in_json = OSCRuby::Answer.find(client, 2222, true)
|
326
|
-
|
327
|
-
expect(known_working_answer_in_json).to be_an(String)
|
328
|
-
|
329
|
-
end
|
330
|
-
|
331
|
-
end
|
332
|
-
|
333
|
-
context '#all' do
|
334
|
-
|
335
|
-
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
|
336
|
-
|
337
|
-
expect(client).to be_an(OSCRuby::Client)
|
338
|
-
|
339
|
-
client = nil
|
340
|
-
|
341
|
-
expect{OSCRuby::Answer.all(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
342
|
-
|
343
|
-
end
|
344
|
-
|
345
|
-
it 'should return multiple instances of OSCRuby::Answer', :vcr do
|
346
|
-
|
347
|
-
answers = OSCRuby::Answer.all(client)
|
348
|
-
|
349
|
-
expect(answers.size).to be > 0
|
350
|
-
|
351
|
-
# puts "Checking if OSCRuby::Answer.all produces multiple instances of answers"
|
352
|
-
|
353
|
-
answers.each_with_index do |p,i|
|
354
|
-
|
355
|
-
if i < 10
|
356
|
-
|
357
|
-
expect(p).to be_an(OSCRuby::Answer)
|
358
|
-
|
359
|
-
# puts p.name
|
360
|
-
|
361
|
-
end
|
362
|
-
|
363
|
-
end
|
364
|
-
|
365
|
-
end
|
366
|
-
|
367
|
-
it 'should just return JSON if the return_json parameter is set to true', :vcr do
|
368
|
-
|
369
|
-
expect(OSCRuby::Answer.all(client,true)).to be_a(String)
|
370
|
-
|
371
|
-
end
|
372
|
-
|
373
|
-
end
|
374
|
-
|
375
|
-
context '#where' do
|
376
|
-
|
377
|
-
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not' do
|
378
|
-
|
379
|
-
expect(client).to be_an(OSCRuby::Client)
|
380
|
-
|
381
|
-
client = nil
|
382
|
-
|
383
|
-
expect{OSCRuby::Answer.where(client,'query')}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
384
|
-
|
385
|
-
end
|
386
|
-
|
387
|
-
it 'should raise an error if there is no query' do
|
388
|
-
|
389
|
-
expect{OSCRuby::Answer.where(client)}.to raise_error("A query must be specified when using the 'where' method")
|
390
|
-
|
391
|
-
end
|
392
|
-
|
393
|
-
it 'should take a query and return results', :vcr do
|
394
|
-
|
395
|
-
answers_lvl_1 = OSCRuby::Answer.where(client,"language.id = 11")
|
396
|
-
|
397
|
-
expect(answers_lvl_1.count).to be > 0
|
398
|
-
|
399
|
-
answers_lvl_1.each_with_index do |p,i|
|
400
|
-
|
401
|
-
if i < 10
|
402
|
-
|
403
|
-
expect(p).to be_an(OSCRuby::Answer)
|
404
|
-
|
405
|
-
# puts p.name
|
406
|
-
|
407
|
-
end
|
408
|
-
|
409
|
-
end
|
410
|
-
|
411
|
-
end
|
412
|
-
|
413
|
-
it 'should raise an error if the query returns 0 results', :vcr do
|
414
|
-
|
415
|
-
expect{OSCRuby::Answer.where(client,"id = 6546546546546")}.to raise_error('There were no objects matching your query; please try again.')
|
416
|
-
|
417
|
-
end
|
418
|
-
|
419
|
-
it 'should just return JSON if the return_json parameter is set to true', :vcr do
|
420
|
-
|
421
|
-
parents = OSCRuby::Answer.where(client,"parent is null and lookupname not like 'Unsure'",true)
|
422
|
-
|
423
|
-
expect(parents).to be_a(String)
|
424
|
-
|
425
|
-
# puts parents
|
426
|
-
|
427
|
-
end
|
428
|
-
|
429
|
-
end
|
430
|
-
|
431
|
-
context '#update' do
|
432
|
-
|
433
|
-
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not', :vcr do
|
434
|
-
|
435
|
-
known_working_answer = OSCRuby::Answer.find(client, 2222)
|
436
|
-
|
437
|
-
expect(client).to be_an(OSCRuby::Client)
|
438
|
-
|
439
|
-
client = nil
|
440
|
-
|
441
|
-
expect{known_working_answer.update(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
442
|
-
|
443
|
-
end
|
444
|
-
|
445
|
-
it 'should expect that the Answer is an instance of a OSCRuby::Answer', :vcr do
|
446
|
-
|
447
|
-
known_working_answer = OSCRuby::Answer.find(client, 2222)
|
448
|
-
|
449
|
-
expect(known_working_answer).to be_an(OSCRuby::Answer)
|
450
|
-
|
451
|
-
end
|
452
|
-
|
453
|
-
it 'should expect that the answer has an ID and spit out an error if it does not', :vcr do
|
454
|
-
|
455
|
-
known_working_answer = OSCRuby::Answer.find(client, 2222)
|
456
|
-
|
457
|
-
known_working_answer.id = nil
|
458
|
-
|
459
|
-
expect{known_working_answer.update(client)}.to raise_error('OSCRuby::Answer must have a valid ID set')
|
460
|
-
|
461
|
-
end
|
462
|
-
|
463
|
-
# it 'should update name when the names is updated', :vcr do
|
464
|
-
|
465
|
-
# test_answers = OSCRuby::Answer.where(client,"language.id = 11")
|
466
|
-
# first_prod = test_answers[0]
|
467
|
-
|
468
|
-
# first_prod.names[0] = {"labelText" => "TEST-answer-UPDATED", "language" => {"id" => 1}}
|
469
|
-
|
470
|
-
# first_prod.update(client)
|
471
|
-
|
472
|
-
# expect(first_prod.name).to eq('TEST-answer-UPDATED')
|
473
|
-
|
474
|
-
# end
|
475
|
-
|
476
|
-
it 'should just return JSON if the return_json parameter is set to true', :vcr do
|
477
|
-
|
478
|
-
known_working_answer = OSCRuby::Answer.find(client, 2222)
|
479
|
-
|
480
|
-
test = known_working_answer.update(client,true)
|
481
|
-
|
482
|
-
expect(test).to be_a(String)
|
483
|
-
|
484
|
-
end
|
485
|
-
|
486
|
-
end
|
487
|
-
|
488
|
-
context '#destroy' do
|
489
|
-
|
490
|
-
it 'should expect client is an instance of OSCRuby::Client class and raise an error if does not', :vcr do
|
491
|
-
|
492
|
-
test_answers = OSCRuby::Answer.where(client,"summary like '%Answer summary text%'")
|
493
|
-
answer_to_delete = test_answers[0]
|
494
|
-
|
495
|
-
expect(client).to be_an(OSCRuby::Client)
|
496
|
-
|
497
|
-
client = nil
|
498
|
-
|
499
|
-
expect{answer_to_delete.destroy(client)}.to raise_error('Client must have some configuration set; please create an instance of OSCRuby::Client with configuration settings')
|
500
|
-
|
501
|
-
end
|
502
|
-
|
503
|
-
it 'should expect that the Service answer is an instance of a OSCRuby::Answer', :vcr do
|
504
|
-
|
505
|
-
test_answers = OSCRuby::Answer.where(client,"summary like '%Answer summary text%'")
|
506
|
-
answer_to_delete = test_answers[0]
|
507
|
-
|
508
|
-
expect(answer_to_delete).to be_an(OSCRuby::Answer)
|
509
|
-
|
510
|
-
end
|
511
|
-
|
512
|
-
it 'should expect that the answer has an ID and spit out an error if it does not', :vcr do
|
513
|
-
|
514
|
-
test_answers = OSCRuby::Answer.where(client,"summary like '%Answer summary text%'")
|
515
|
-
answer_to_delete = test_answers[0]
|
516
|
-
|
517
|
-
answer_to_delete.id = nil
|
518
|
-
|
519
|
-
expect{answer_to_delete.destroy(client)}.to raise_error('OSCRuby::Answer must have a valid ID set')
|
520
|
-
|
521
|
-
end
|
522
|
-
|
523
|
-
it 'should delete the answer', :vcr do
|
524
|
-
|
525
|
-
test_answers = OSCRuby::Answer.where(client,"summary like '%Answer summary text%'")
|
526
|
-
|
527
|
-
answer_to_delete = test_answers[0]
|
528
|
-
|
529
|
-
id_to_find = answer_to_delete.id
|
530
|
-
|
531
|
-
test_answers.each do |answer|
|
532
|
-
|
533
|
-
puts answer.id
|
534
|
-
|
535
|
-
answer.destroy(client)
|
536
|
-
|
537
|
-
end
|
538
|
-
|
539
|
-
expect{OSCRuby::Answer.find(client, id_to_find)}.to raise_error('There were no objects matching your query; please try again.')
|
540
|
-
|
541
|
-
end
|
542
|
-
|
543
|
-
end
|
544
|
-
|
545
|
-
end
|