cloudfactory 0.6.4 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -3
- data/lib/cf/badge.rb +122 -21
- data/lib/cf/cli.rb +42 -5
- data/lib/cf/cli/badge.rb +248 -0
- data/lib/cf/cli/badge_yaml_validator.rb +18 -0
- data/lib/cf/cli/line.rb +23 -42
- data/lib/cf/cli/production.rb +1 -1
- data/lib/cf/cli/templates/sample-line/badge.yml.erb +38 -0
- data/lib/cf/cli/templates/sample-line/form.html +1 -27
- data/lib/cf/cli/templates/sample-line/line.yml.erb +3 -1
- data/lib/cf/custom_task_form.rb +1 -1
- data/lib/cf/help.txt +27 -15
- data/lib/cf/human_worker.rb +13 -65
- data/lib/cf/station.rb +12 -58
- data/lib/cf/version.rb +1 -1
- data/spec/badges_spec.rb +237 -337
- data/spec/custom_task_form_spec.rb +3 -4
- data/spec/human_worker_spec.rb +131 -5
- data/spec/line_spec.rb +8 -6
- data/spec/run_spec.rb +1 -1
- data/spec/task_form_spec.rb +1 -18
- data/spec/text_appending_robot_spec.rb +4 -5
- metadata +55 -52
data/lib/cf/version.rb
CHANGED
data/spec/badges_spec.rb
CHANGED
@@ -1,342 +1,242 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CF::Badge do
|
4
|
-
context "
|
5
|
-
it "
|
4
|
+
context "#create" do
|
5
|
+
it " in block DSL way" do
|
6
6
|
WebMock.allow_net_connect!
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
:title => "Custom TestForm",
|
232
|
-
:instruction => "Look at the image of the tomb in the url given and answer the asked questions.",
|
233
|
-
:type => "CustomTaskForm",
|
234
|
-
:file =>"./spec/badges/station_1.html"
|
235
|
-
}
|
236
|
-
}
|
237
|
-
})
|
238
|
-
end
|
239
|
-
line.stations.first.badges.first.settings[:test_attributes][:form_attributes][:type].should eql("CustomTaskForm")
|
240
|
-
end
|
241
|
-
|
242
|
-
|
243
|
-
it "should add a badge with defined custom_task_form as a badge test form in plain ruby way " do
|
244
|
-
WebMock.allow_net_connect!
|
245
|
-
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
246
|
-
sleep 1
|
247
|
-
@line = CF::Line.create(title,"Digitization") do |l|
|
248
|
-
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
249
|
-
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
250
|
-
end
|
251
|
-
station = CF::Station.create({:line => @line, :type => "work"}) do |s|
|
252
|
-
CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
|
253
|
-
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
254
|
-
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
255
|
-
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
256
|
-
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
257
|
-
end
|
258
|
-
@gold_standard = CF::GoldStandard.new({ :line => @line,
|
259
|
-
:station => s,
|
260
|
-
:name => "easy",
|
261
|
-
:input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
|
262
|
-
:expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
|
263
|
-
})
|
264
|
-
end
|
265
|
-
badge = CF::Badge.new({
|
266
|
-
:name => "Tomb Digitizer#{Time.now}",
|
267
|
-
:description => "This badge qualifies you to work on tomb digitization tasks.",
|
268
|
-
:max_badges => 100,
|
269
|
-
:gold_standards => ["#{@gold_standard.settings[:name]}"],
|
270
|
-
:test_attributes =>
|
271
|
-
{
|
272
|
-
:type => "default",
|
273
|
-
:retries => 10,
|
274
|
-
:pass_percentage => 100,
|
275
|
-
:check_manually => false,
|
276
|
-
:form_attributes => {
|
277
|
-
:title => "Custom TestForm in plain ruby way",
|
278
|
-
:instruction => "Look at the image of the tomb in the url given and answer the asked questions.",
|
279
|
-
:type => "CustomTaskForm",
|
280
|
-
:file =>"./spec/badges/station_1.html"
|
281
|
-
}
|
282
|
-
}
|
283
|
-
})
|
284
|
-
@line.stations.first.badges badge
|
285
|
-
@line.stations.first.badges.first.settings["test"]["form"]["_type"].should eql("CustomTaskForm")
|
286
|
-
@line.stations.first.badges.first.settings["test"]["form"]["raw_html"].present?.should eql(true)
|
287
|
-
end
|
288
|
-
|
289
|
-
|
290
|
-
it "should add a badge with defined task_form as a badge test form in plain ruby way " do
|
291
|
-
WebMock.allow_net_connect!
|
292
|
-
title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
|
293
|
-
sleep 1
|
294
|
-
@line = CF::Line.create(title,"Digitization") do |l|
|
295
|
-
CF::InputFormat.new({:line => l, :name => "Company", :required => true, :valid_type => "general"})
|
296
|
-
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
|
297
|
-
end
|
298
|
-
station = CF::Station.create({:line => @line, :type => "work"}) do |s|
|
299
|
-
CF::HumanWorker.new({:station => s, :number => 1, :reward => 10})
|
300
|
-
CF::TaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"}) do |i|
|
301
|
-
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
|
302
|
-
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
|
303
|
-
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
|
304
|
-
end
|
305
|
-
@gold_standard = CF::GoldStandard.new({ :line => @line,
|
306
|
-
:station => s,
|
307
|
-
:name => "easy",
|
308
|
-
:input => {'image_url' => "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
|
309
|
-
:expected_output => {"first_name" => {"value" => "John"}, "last_name" => {"value" => "Lennon"}, "company" => {"value" => "Sprout"}}
|
310
|
-
})
|
311
|
-
end
|
312
|
-
badge = CF::Badge.new({
|
313
|
-
:name => "Tomb Digitizer#{Time.now}",
|
314
|
-
:description => "This badge qualifies you to work on tomb digitization tasks.",
|
315
|
-
:max_badges => 100,
|
316
|
-
:gold_standards => ["#{@gold_standard.settings[:name]}"],
|
317
|
-
:test_attributes =>
|
318
|
-
{
|
319
|
-
:type => "default",
|
320
|
-
:retries => 10,
|
321
|
-
:pass_percentage => 100,
|
322
|
-
:check_manually => false,
|
323
|
-
:form_attributes => {
|
324
|
-
:title => "Tombfinder Test plain ruby way",
|
325
|
-
:instruction => "Look at the image of the tomb in the url given and answer the asked questions.",
|
326
|
-
:type => "TaskForm",
|
327
|
-
:form_fields_attributes =>
|
328
|
-
[
|
329
|
-
{ "label" => "Last Name", "field_type" => "radio_button", 'option_values' => ["LEIGH", "IRVING", "GERTRUDE"] },
|
330
|
-
{ "label" => "Lizzie Year of Birth", "field_type" => "radio_button", 'option_values' => ["1873", "1933", "1896"] }
|
331
|
-
]
|
332
|
-
}
|
333
|
-
}
|
334
|
-
})
|
335
|
-
@line.stations.first.badges badge
|
336
|
-
@line.stations.first.badges.first.settings["test"]["form"]["_type"].should eql("TaskForm")
|
337
|
-
@line.stations.first.badges.first.settings["test"]["form"]["form_fields"].should eql([{"label"=>"Last Name", "field_type"=>"radio_button", "option_values"=>["LEIGH", "IRVING", "GERTRUDE"]}, {"label"=>"Lizzie Year of Birth", "field_type"=>"radio_button", "option_values"=>["1873", "1933", "1896"]}])
|
338
|
-
|
339
|
-
end
|
7
|
+
@badge = CF::Badge.create(
|
8
|
+
:name => "Bizcard Digitizer_dsl",
|
9
|
+
:description => "this badge qualifies the worker for bizcard digitization",
|
10
|
+
:max_badge_assignments => 100,
|
11
|
+
:retries_allowed => 5,
|
12
|
+
:pass_percentage => 80,
|
13
|
+
:assignment_duration => 3600,
|
14
|
+
:allow_retake_after => 5,
|
15
|
+
:check_manually =>false,
|
16
|
+
:form => "./lib/cf/cli/templates/sample-line/form.html",
|
17
|
+
:known_answers=>
|
18
|
+
[
|
19
|
+
{ "name" => "chandra",
|
20
|
+
"input"=> {"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
|
21
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"1"}}
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name" => "mohan",
|
25
|
+
"input"=>{"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg2"},
|
26
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"2"}}
|
27
|
+
}
|
28
|
+
]
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "in plain ruby way" do
|
33
|
+
WebMock.allow_net_connect!
|
34
|
+
@badge = CF::Badge.new(
|
35
|
+
:name => "Bizcard Digitizer_plain",
|
36
|
+
:description => "this badge qualifies the worker for bizcard digitization",
|
37
|
+
:max_badge_assignments => 100,
|
38
|
+
:retries_allowed => 5,
|
39
|
+
:pass_percentage => 80,
|
40
|
+
:assignment_duration => 3600,
|
41
|
+
:allow_retake_after => 5,
|
42
|
+
:check_manually =>false,
|
43
|
+
:form => "./lib/cf/cli/templates/sample-line/form.html",
|
44
|
+
:known_answers=>
|
45
|
+
[
|
46
|
+
{ "name" => "chandra",
|
47
|
+
"input"=> {"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
|
48
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"1"}}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name" => "mohan",
|
52
|
+
"input"=>{"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg2"},
|
53
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"2"}}
|
54
|
+
}
|
55
|
+
]
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
it " with standard task form" do
|
60
|
+
WebMock.allow_net_connect!
|
61
|
+
@badge = CF::Badge.create(
|
62
|
+
:name => "Bizcard Digitizer_standard_form",
|
63
|
+
:description => "this badge qualifies the worker for bizcard digitization",
|
64
|
+
:max_badge_assignments => 100,
|
65
|
+
:retries_allowed => 5,
|
66
|
+
:pass_percentage => 80,
|
67
|
+
:assignment_duration => 3600,
|
68
|
+
:allow_retake_after => 5,
|
69
|
+
:check_manually =>false,
|
70
|
+
:form => {:title => "standard task form", :instruction => "Describe me"},
|
71
|
+
:known_answers=>
|
72
|
+
[
|
73
|
+
{ "name" => "chandra",
|
74
|
+
"input"=> {"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
|
75
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"1"}}
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"name" => "mohan",
|
79
|
+
"input"=>{"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg2"},
|
80
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"2"}}
|
81
|
+
}
|
82
|
+
]
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
context "create a badge without" do
|
89
|
+
before(:each) do
|
90
|
+
WebMock.allow_net_connect!
|
91
|
+
@badge_hash = {
|
92
|
+
:name => "Bizcard Digitizer#{Time.new.strftime('%Y%b%d-%H%M%S')}",
|
93
|
+
:description => "this badge qualifies the worker for bizcard digitization",
|
94
|
+
:max_badge_assignments => 100,
|
95
|
+
:retries_allowed => 5,
|
96
|
+
:pass_percentage => 80,
|
97
|
+
:assignment_duration => 3600,
|
98
|
+
:allow_retake_after => 5,
|
99
|
+
:check_manually =>false,
|
100
|
+
:form => "./lib/cf/cli/templates/sample-line/form.html",
|
101
|
+
:known_answers=>
|
102
|
+
[
|
103
|
+
{ "name" => "chandra",
|
104
|
+
"input"=> {"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
|
105
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"1"}}
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"name" => "mohan",
|
109
|
+
"input"=>{"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg2"},
|
110
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"2"}}
|
111
|
+
}
|
112
|
+
]
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
it "name should give error 'Name can't be blank'" do
|
118
|
+
@badge_hash.delete(:name)
|
119
|
+
badge = CF::Badge.new(@badge_hash)
|
120
|
+
badge.errors.should eql(["Name can't be blank"])
|
121
|
+
end
|
122
|
+
|
123
|
+
it "form should raise error 'Test is invalid'" do
|
124
|
+
@badge_hash.delete(:form)
|
125
|
+
badge = CF::Badge.new(@badge_hash)
|
126
|
+
badge.errors.should eql(["Form can't be blank"])
|
127
|
+
end
|
128
|
+
|
129
|
+
it "known_answers should raise error 'You have not provided known answers for the badge'" do
|
130
|
+
@badge_hash.delete(:known_answers)
|
131
|
+
badge = CF::Badge.new(@badge_hash)
|
132
|
+
badge.errors.should eql("You have not provided known answers for the badge.")
|
133
|
+
end
|
134
|
+
|
135
|
+
it "form with different file type" do
|
136
|
+
@badge_hash[:form] = "./lib/cf/cli/templates/sample-line/badge.yml.erb"
|
137
|
+
badge = CF::Badge.new(@badge_hash)
|
138
|
+
badge.errors.should eql(["Wrong type of file for the badge form."])
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
context "#update" do
|
144
|
+
before(:each) do
|
145
|
+
WebMock.allow_net_connect!
|
146
|
+
@badge = CF::Badge.create(
|
147
|
+
:name => "Bizcard Digitizer",
|
148
|
+
:description => "this badge qualifies the worker for bizcard digitization",
|
149
|
+
:max_badge_assignments => 100,
|
150
|
+
:retries_allowed => 5,
|
151
|
+
:pass_percentage => 80,
|
152
|
+
:assignment_duration => 3600,
|
153
|
+
:allow_retake_after => 5,
|
154
|
+
:check_manually =>false,
|
155
|
+
:form => "./lib/cf/cli/templates/sample-line/form.html",
|
156
|
+
:known_answers=>
|
157
|
+
[
|
158
|
+
{ "name" => "chandra",
|
159
|
+
"input"=> {"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg"},
|
160
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"1"}}
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"name" => "mohan",
|
164
|
+
"input"=>{"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg2"},
|
165
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"2"}}
|
166
|
+
}
|
167
|
+
]
|
168
|
+
)
|
169
|
+
|
170
|
+
@badge_hash = {
|
171
|
+
:name => "Bizcard Digitizer_updated",
|
172
|
+
:description => "this badge qualifies the worker for bizcard digitization for next level",
|
173
|
+
:max_badge_assignments => 80,
|
174
|
+
:retries_allowed => 0,
|
175
|
+
:pass_percentage => 10,
|
176
|
+
:assignment_duration => 300,
|
177
|
+
:allow_retake_after => 2,
|
178
|
+
:check_manually => true,
|
179
|
+
:form => "./lib/cf/cli/templates/sample-line/form.html",
|
180
|
+
:known_answers=>
|
181
|
+
[
|
182
|
+
{
|
183
|
+
"name" => "updated",
|
184
|
+
"input"=>{"image_url"=> "http://onwired.com/images/portfolio/linda-stanley-business-card.jpg2"},
|
185
|
+
"expected_output"=>{"gender"=>{"value"=>"Male"}, "rich"=>{"value"=>"2"}}
|
186
|
+
}
|
187
|
+
]
|
188
|
+
}
|
189
|
+
end
|
190
|
+
|
191
|
+
it "in block DSl Way" do
|
192
|
+
badge = CF::Badge.update("Bizcard Digitizer", @badge_hash)
|
193
|
+
badge["name"].should eql("Bizcard Digitizer_updated")
|
194
|
+
badge["description"].should eql("this badge qualifies the worker for bizcard digitization for next level")
|
195
|
+
badge["max_badge_assignments"].should eql(80)
|
196
|
+
badge["test"]["retries"].should eql(0)
|
197
|
+
badge["test"]["check_manually"].should eql(true)
|
198
|
+
badge["test"]["pass_percentage"].should eql(10)
|
199
|
+
badge["test"]["known_answers"].should eql(1)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "in absence of form should raise error" do
|
203
|
+
@badge_hash.delete(:form)
|
204
|
+
badge = CF::Badge.update(@badge.name, @badge_hash)
|
205
|
+
badge["error"]["message"].should eql("Badge #{@badge.name} can not be updated beacuse {:test=>[\"is invalid\"]}")
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
context "#list" do
|
211
|
+
it "should list all badges" do
|
212
|
+
WebMock.allow_net_connect!
|
213
|
+
badge = CF::Badge.list
|
214
|
+
badge["code"].should eql(200)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should list specific badge" do
|
218
|
+
WebMock.allow_net_connect!
|
219
|
+
badge_list = CF::Badge.list("bizcard-digitizer_updated")
|
220
|
+
badge_list["badges"].first["name"].should eql("Bizcard Digitizer_updated")
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
context "#delete" do
|
225
|
+
it "a specific badge" do
|
226
|
+
WebMock.allow_net_connect!
|
227
|
+
badge = CF::Badge.destroy("bizcard-digitizer_updated")
|
228
|
+
badge["code"].should eql(200)
|
229
|
+
CF::Badge.list("bizcard-digitizer_updated")["error"]["message"].should eql("No badge to list")
|
230
|
+
end
|
340
231
|
|
341
|
-
|
342
|
-
|
232
|
+
it "delete all badges" do
|
233
|
+
WebMock.allow_net_connect!
|
234
|
+
badge2 = CF::Badge.destroy("bizcard-digitizer")
|
235
|
+
badge2 = CF::Badge.destroy("bizcard-digitizer_updated")
|
236
|
+
badge2 = CF::Badge.destroy("bizcard-digitizer_dsl")
|
237
|
+
badge3 = CF::Badge.destroy("bizcard-digitizer_plain")
|
238
|
+
badge4 = CF::Badge.destroy("Bizcard Digitizer_standard_form")
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
end
|