cloudfactory 0.3.1 → 0.4.0

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.
data/spec/config_spec.rb CHANGED
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
  describe CF do
4
4
  context "configuration" do
5
5
  it "be able to configure the api key" do
6
- API_CONFIG = YAML.load_file(File.expand_path("../../fixtures/api_credentials.yml", __FILE__))
7
6
  CF.configure do |config|
8
7
  config.account_name = API_CONFIG['account_name']
9
8
  config.api_version = API_CONFIG['api_version']
@@ -5,53 +5,53 @@ module CF
5
5
  describe CF::RobotWorker do
6
6
  context "create a content scraping robot worker" do
7
7
  it "should create content_scraping_robot worker for first station in Block DSL way" do
8
- # WebMock.allow_net_connect!
9
- VCR.use_cassette "robot_worker/content_scraping_robot/block/create-worker-single-station", :record => :new_episodes do
10
- line = CF::Line.create("content_scraping_robot","Digitization") do |l|
11
- CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
12
- CF::Station.create({:line => l, :type => "work"}) do |s|
13
- CF::RobotWorker.create({:station => s, :type => "content_scraping_robot", :settings => {:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"}})
14
- end
8
+ WebMock.allow_net_connect!
9
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
10
+ sleep 1
11
+ line = CF::Line.create(title,"Digitization") do |l|
12
+ CF::InputFormat.new({:line => l, :name => "url", :valid_type => "url", :required => "true"})
13
+ CF::Station.create({:line => l, :type => "work"}) do |s|
14
+ CF::RobotWorker.create({:station => s, :type => "content_scraping_robot", :settings => {:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"}})
15
15
  end
16
- run = CF::Run.create(line, "content_scraping_robot_run", [{"url"=> "http://www.sprout-technology.com"}])
17
- # sleep 30
18
- output = run.final_output
19
- output.first['scraped_link_from_document'].should eql([""])
20
- output.first['scraped_text_from_document'].should eql([""])
21
-
22
- line.stations.first.worker.class.should eql(CF::RobotWorker)
23
- line.stations.first.worker.reward.should eql(0.5)
24
- line.stations.first.worker.number.should eql(1)
25
- line.stations.first.worker.settings.should eql({:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"})
26
- line.stations.first.worker.type.should eql("ContentScrapingRobot")
27
16
  end
17
+ run = CF::Run.create(line, "content_scraping_robot_run", [{"url"=> "http://www.sprout-technology.com"}])
18
+ sleep 10
19
+ output = run.final_output
20
+ output.first['scraped_link_from_document'].should eql([""])
21
+ output.first['scraped_text_from_document'].should eql([""])
22
+
23
+ line.stations.first.worker.class.should eql(CF::RobotWorker)
24
+ line.stations.first.worker.reward.should eql(0.5)
25
+ line.stations.first.worker.number.should eql(1)
26
+ line.stations.first.worker.settings.should eql({:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"})
27
+ line.stations.first.worker.type.should eql("ContentScrapingRobot")
28
28
  end
29
29
 
30
30
  it "should create content_scraping_robot worker for first station in a plain ruby way" do
31
- # WebMock.allow_net_connect!
32
- VCR.use_cassette "robot_worker/content_scraping_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
33
- line = CF::Line.new("content_scraping_robot_run_1","Digitization")
34
- input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
35
- line.input_formats input_format
31
+ WebMock.allow_net_connect!
32
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
33
+ sleep 1
34
+ line = CF::Line.new(title,"Digitization")
35
+ input_format = CF::InputFormat.new({:name => "url", :required => true, :valid_type => "url"})
36
+ line.input_formats input_format
36
37
 
37
- station = CF::Station.new({:type => "work"})
38
- line.stations station
38
+ station = CF::Station.new({:type => "work"})
39
+ line.stations station
39
40
 
40
- worker = CF::RobotWorker.create({:type => "content_scraping_robot", :settings => {:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"}})
41
- line.stations.first.worker = worker
41
+ worker = CF::RobotWorker.create({:type => "content_scraping_robot", :settings => {:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"}})
42
+ line.stations.first.worker = worker
42
43
 
43
- run = CF::Run.create(line, "content_scraping_robot_run_1", [{"url"=> "http://www.sprout-technology.com"}])
44
- # sleep 30
45
- output = run.final_output
46
- output.first['scraped_link_from_document'].should eql([""])
47
- output.first['scraped_text_from_document'].should eql([""])
44
+ run = CF::Run.create(line, "content_scraping_robot_run_1", [{"url"=> "http://www.sprout-technology.com"}])
45
+ sleep 10
46
+ output = run.final_output
47
+ output.first['scraped_link_from_document'].should eql([""])
48
+ output.first['scraped_text_from_document'].should eql([""])
48
49
 
49
- line.stations.first.worker.class.should eql(CF::RobotWorker)
50
- line.stations.first.worker.reward.should eql(0.5)
51
- line.stations.first.worker.number.should eql(1)
52
- line.stations.first.worker.settings.should eql({:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"})
53
- line.stations.first.worker.type.should eql("ContentScrapingRobot")
54
- end
50
+ line.stations.first.worker.class.should eql(CF::RobotWorker)
51
+ line.stations.first.worker.reward.should eql(0.5)
52
+ line.stations.first.worker.number.should eql(1)
53
+ line.stations.first.worker.settings.should eql({:document => ["http://www.sprout-technology.com"], :query => "1st 2 links after Sprout products"})
54
+ line.stations.first.worker.type.should eql("ContentScrapingRobot")
55
55
  end
56
56
  end
57
57
  end
@@ -3,8 +3,7 @@ require 'spec_helper'
3
3
  describe CF::CustomTaskForm do
4
4
  context "create a Custom Task Form" do
5
5
  it "in block DSL way" do
6
- # WebMock.allow_net_connect!
7
- VCR.use_cassette "custom-task-form/block/create", :record => :new_episodes do
6
+ WebMock.allow_net_connect!
8
7
  html = '<div id="form-content">
9
8
  <div id="instructions">
10
9
  <ul>
@@ -32,7 +31,7 @@ describe CF::CustomTaskForm do
32
31
  </div>
33
32
  </div>'
34
33
 
35
- css = '<style>body {background:#fbfbfb;}
34
+ css = '<style>body {background:#fbfbfb;}
36
35
  #instructions{
37
36
  text-align:center;
38
37
  }
@@ -55,7 +54,7 @@ describe CF::CustomTaskForm do
55
54
  margin:4px;
56
55
  }</style>'
57
56
 
58
- javascript = '<script src="http://code.jquery.com/jquery-latest.js"></script>
57
+ javascript = '<script src="http://code.jquery.com/jquery-latest.js"></script>
59
58
  <script type="text/javascript" src="http://www.bizcardarmy.com/javascripts/jquery.autocomplete-min.js"></script>
60
59
  <script type="text/javascript">
61
60
  $(document).ready(function(){
@@ -74,26 +73,26 @@ describe CF::CustomTaskForm do
74
73
  });
75
74
  </script>'
76
75
 
77
-
78
- line = CF::Line.create("Digitizecustomform11", "Digitization") do
79
- CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
80
- CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
81
- CF::Station.create({:line => self, :type => "work"}) do |s|
82
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
83
- CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
84
- end
76
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
77
+ sleep 1
78
+ line = CF::Line.create(title, "Digitization") do
79
+ CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
80
+ CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
81
+ CF::Station.create({:line => self, :type => "work"}) do |s|
82
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
83
+ CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
85
84
  end
86
- line.title.should eql("Digitizecustomform11")
87
- line.department_name.should eql("Digitization")
88
- line.stations.first.type.should eql("WorkStation")
89
- CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
90
- CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
91
- CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
92
85
  end
86
+ line.title.should eql(title)
87
+ line.department_name.should eql("Digitization")
88
+ line.stations.first.type.should eql("WorkStation")
89
+ CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
90
+ CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
91
+ CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
93
92
  end
94
93
 
95
94
  it "in plain ruby way" do
96
- VCR.use_cassette "custom-task-form/plain/create", :record => :new_episodes do
95
+ WebMock.allow_net_connect!
97
96
  html = '<form><div id="form-content">
98
97
  <div id="instructions">
99
98
  <ul>
@@ -121,7 +120,7 @@ describe CF::CustomTaskForm do
121
120
  </div>
122
121
  </div></form>'
123
122
 
124
- css = '<style>body {background:#fbfbfb;}
123
+ css = '<style>body {background:#fbfbfb;}
125
124
  #instructions{
126
125
  text-align:center;
127
126
  }
@@ -162,36 +161,35 @@ describe CF::CustomTaskForm do
162
161
  });
163
162
  });
164
163
  </script>'
164
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
165
+ sleep 1
166
+ line = CF::Line.new(title, "Digitization")
167
+
168
+ input_format_1 = CF::InputFormat.new({:name => "Name", :required => true, :valid_format => "general"})
169
+ input_format_2 = CF::InputFormat.new({:name => "Contact", :required => true, :valid_type => "url"})
170
+ line.input_formats input_format_1
171
+ line.input_formats input_format_2
165
172
 
166
- line = CF::Line.new("Digitizeplainruby111", "Digitization")
167
-
168
- input_format_1 = CF::InputFormat.new({:name => "Name", :required => true, :valid_format => "general"})
169
- input_format_2 = CF::InputFormat.new({:name => "Contact", :required => true, :valid_type => "url"})
170
- line.input_formats input_format_1
171
- line.input_formats input_format_2
172
-
173
- station = CF::Station.new({:type => "work"})
174
- line.stations station
175
-
176
- worker = CF::HumanWorker.new({:number => 1, :reward => 20})
177
- line.stations.first.worker = worker
173
+ station = CF::Station.new({:type => "work"})
174
+ line.stations station
175
+
176
+ worker = CF::HumanWorker.new({:number => 1, :reward => 20})
177
+ line.stations.first.worker = worker
178
178
 
179
- form = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
180
- line.stations.first.form = form
181
- line.title.should eql("Digitizeplainruby111")
182
- line.department_name.should eql("Digitization")
183
- line.stations.first.type.should eql("WorkStation")
184
- CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
185
- CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
186
- CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
187
- end
179
+ form = CF::CustomTaskForm.new({:title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html, :raw_css => css, :raw_javascript => javascript})
180
+ line.stations.first.form = form
181
+ line.title.should eql(title)
182
+ line.department_name.should eql("Digitization")
183
+ line.stations.first.type.should eql("WorkStation")
184
+ CGI.unescape_html(line.stations.first.form.raw_html).should eql(html)
185
+ CGI.unescape_html(line.stations.first.form.raw_css).should eql(css)
186
+ CGI.unescape_html(line.stations.first.form.raw_javascript).should eql(javascript)
188
187
  end
189
188
  end
190
189
 
191
190
  context "create a Custom Task Form for Error Handling;" do
192
- it "creating with invalid Html content" do
193
- # WebMock.allow_net_connect!
194
- VCR.use_cassette "custom-task-form/block/invalid-html-content", :record => :new_episodes do
191
+ it "creating with invalid Html content" do
192
+ WebMock.allow_net_connect!
195
193
  html = '<div id="form-content">
196
194
  <div id="instructions">
197
195
  <ul>
@@ -218,23 +216,23 @@ describe CF::CustomTaskForm do
218
216
  </div>
219
217
  </div>
220
218
  </div>'
221
- line = CF::Line.create("Digitizecustomform111", "Digitization") do
222
- CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
223
- CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
224
- CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
225
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
226
- CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
227
- end
219
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
220
+ sleep 1
221
+ line = CF::Line.create(title, "Digitization") do
222
+ CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
223
+ CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
224
+ CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
225
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
226
+ CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe", :raw_html => html})
228
227
  end
229
- line.title.should eql("Digitizecustomform111")
230
- line.department_name.should eql("Digitization")
231
- line.stations.first.form.errors.should eql(["Raw html should contain a Form tag", "Raw html The name 'final_output[first_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[middle_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[last_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[email]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[phone]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[mobile]' is not valid, it should be of format output[name]"])
232
228
  end
229
+ line.title.should eql(title)
230
+ line.department_name.should eql("Digitization")
231
+ line.stations.first.form.errors.should eql(["Raw html should contain a Form tag", "Raw html The name 'final_output[first_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[middle_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[last_name]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[email]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[phone]' is not valid, it should be of format output[name]", "Raw html The name 'final_output[mobile]' is not valid, it should be of format output[name]"])
233
232
  end
234
233
 
235
234
  it "creating without title" do
236
- # WebMock.allow_net_connect!
237
- VCR.use_cassette "custom-task-form/block/without-title", :record => :new_episodes do
235
+ WebMock.allow_net_connect!
238
236
  html = '<div id="form-content">
239
237
  <div id="instructions">
240
238
  <ul>
@@ -261,23 +259,24 @@ describe CF::CustomTaskForm do
261
259
  </div>
262
260
  </div>
263
261
  </div>'
264
- line = CF::Line.create("Digitizecustomform112", "Digitization") do
265
- CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
266
- CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
267
- CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
268
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
269
- CF::CustomTaskForm.create({:station => s, :instruction => "Describe", :raw_html => html})
270
- end
262
+
263
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
264
+ sleep 1
265
+ line = CF::Line.create(title, "Digitization") do
266
+ CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
267
+ CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
268
+ CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
269
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
270
+ CF::CustomTaskForm.create({:station => s, :instruction => "Describe", :raw_html => html})
271
271
  end
272
- line.title.should eql("Digitizecustomform112")
273
- line.department_name.should eql("Digitization")
274
- line.stations.first.form.errors.should eql(["Title can't be blank", "Raw html should contain a Form tag"])
275
272
  end
273
+ line.title.should eql(title)
274
+ line.department_name.should eql("Digitization")
275
+ line.stations.first.form.errors.should eql(["Title can't be blank", "Raw html should contain a Form tag"])
276
276
  end
277
277
 
278
278
  it "creating without instruction" do
279
- # WebMock.allow_net_connect!
280
- VCR.use_cassette "custom-task-form/block/without-instruction", :record => :new_episodes do
279
+ WebMock.allow_net_connect!
281
280
  html = '<div id="form-content">
282
281
  <div id="instructions">
283
282
  <ul>
@@ -304,55 +303,57 @@ describe CF::CustomTaskForm do
304
303
  </div>
305
304
  </div>
306
305
  </div>'
307
- line = CF::Line.create("Digitizecustomform113", "Digitization") do
308
- CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
309
- CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
310
- CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
311
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
312
- CF::CustomTaskForm.create({:station => s, :title => "title", :raw_html => html})
313
- end
306
+
307
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
308
+ sleep 1
309
+ line = CF::Line.create(title, "Digitization") do
310
+ CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
311
+ CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
312
+ CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
313
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
314
+ CF::CustomTaskForm.create({:station => s, :title => "title", :raw_html => html})
314
315
  end
315
- line.title.should eql("Digitizecustomform113")
316
- line.department_name.should eql("Digitization")
317
- line.stations.first.form.errors.should eql(["Instruction can't be blank", "Raw html should contain a Form tag"])
318
316
  end
317
+ line.title.should eql(title)
318
+ line.department_name.should eql("Digitization")
319
+ line.stations.first.form.errors.should eql(["Instruction can't be blank", "Raw html should contain a Form tag"])
319
320
  end
320
321
 
321
322
  it "creating without any html data" do
322
- # WebMock.allow_net_connect!
323
- VCR.use_cassette "custom-task-form/block/without-html", :record => :new_episodes do
324
- line = CF::Line.create("Digitizecustomform114", "Digitization") do
325
- CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
326
- CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
327
- CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
328
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
329
- CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"})
330
- end
323
+ WebMock.allow_net_connect!
324
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
325
+ sleep 1
326
+ line = CF::Line.create(title, "Digitization") do
327
+ CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
328
+ CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
329
+ CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
330
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
331
+ CF::CustomTaskForm.create({:station => s, :title => "Enter text from a business card image", :instruction => "Describe"})
331
332
  end
332
- line.title.should eql("Digitizecustomform114")
333
- line.department_name.should eql("Digitization")
334
- line.stations.first.form.errors.should eql(["Raw html is required"])
335
333
  end
334
+ line.title.should eql(title)
335
+ line.department_name.should eql("Digitization")
336
+ line.stations.first.form.errors.should eql(["Raw html is required"])
336
337
  end
337
338
 
338
339
  it "creating without any html data in plain ruby way" do
339
- # WebMock.allow_net_connect!
340
- VCR.use_cassette "custom-task-form/plain/without-html", :record => :new_episodes do
341
- line = CF::Line.create("Digitizecustomform115", "Digitization") do
342
- CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
343
- CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
344
- CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
345
- CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
346
- end
340
+ WebMock.allow_net_connect!
341
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
342
+ sleep 1
343
+ line = CF::Line.create(title, "Digitization") do
344
+ CF::InputFormat.new({:line => self, :name => "Name", :required => true, :valid_format => "general"})
345
+ CF::InputFormat.new({:line => self, :name => "Contact", :required => true, :valid_type => "url"})
346
+ CF::Station.create({:line => self, :type => "work", :max_judges => 10, :auto_judge => true}) do |s|
347
+ CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
347
348
  end
348
-
349
- form = CF::CustomTaskForm.create({:title => "Enter text from a business card image", :instruction => "Describe"})
350
- line.stations.first.form = form
351
-
352
- line.title.should eql("Digitizecustomform115")
353
- line.department_name.should eql("Digitization")
354
- line.stations.first.form.errors.should eql(["Raw html is required"])
355
349
  end
350
+
351
+ form = CF::CustomTaskForm.create({:title => "Enter text from a business card image", :instruction => "Describe"})
352
+ line.stations.first.form = form
353
+
354
+ line.title.should eql(title)
355
+ line.department_name.should eql("Digitization")
356
+ line.stations.first.form.errors.should eql(["Raw html is required"])
356
357
  end
357
358
  end
358
359
  end
@@ -3,12 +3,11 @@ require 'spec_helper'
3
3
  describe CF::Department do
4
4
  context "return category" do
5
5
  it "should get all the departments" do
6
- VCR.use_cassette "department/all", :record => :new_episodes do
7
- departments = CF::Department.all
8
- departments.map(&:name).should include("Digitization")
9
- departments.map(&:name).should include("Data Processing")
10
- departments.map(&:name).should include("Survey")
11
- end
6
+ departments = CF::Department.all
7
+ departments_name = departments.map {|d| d['name']}.join(",")
8
+ departments_name.should include("Digitization")
9
+ departments_name.should include("Data Processing")
10
+ departments_name.should include("Survey")
12
11
  end
13
12
  end
14
13
  end
@@ -5,53 +5,53 @@ module CF
5
5
  describe CF::RobotWorker do
6
6
  context "create an entity extraction robot worker" do
7
7
  it "should create entity extraction robot worker for first station in Block DSL way" do
8
- # WebMock.allow_net_connect!
9
- VCR.use_cassette "robot_worker/entity_extraction_robot/block/create-worker-single-station", :record => :new_episodes do
10
- line = CF::Line.create("entity_extraction_robot","Digitization") do |l|
11
- CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
12
- CF::Station.create({:line => l, :type => "work"}) do |s|
13
- CF::RobotWorker.create({:station => s, :type => "entity_extraction_robot", :settings => {:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]}})
14
- end
8
+ WebMock.allow_net_connect!
9
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
10
+ sleep 1
11
+ line = CF::Line.create(title,"Digitization") do |l|
12
+ CF::InputFormat.new({:line => l, :name => "text", :required => "true"})
13
+ CF::Station.create({:line => l, :type => "work"}) do |s|
14
+ CF::RobotWorker.create({:station => s, :type => "entity_extraction_robot", :settings => {:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]}})
15
15
  end
16
- run = CF::Run.create(line, "entity_extraction_robot_run", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
17
- # sleep 20
18
- output = run.final_output
19
- output.first['entity_counts_of_document'].should eql(["2", "2", "1", "1", "2", "1"])
20
- output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "Mozart", "China", "Japan"])
21
- output.first['entity_relevances_of_document'].should eql([92.12089999999999, 73.8997, 48.079100000000004, 28.9416, 27.1982, 21.1997])
22
- output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Person", "Country", "Country"])
23
- line.stations.first.worker.class.should eql(CF::RobotWorker)
24
- line.stations.first.worker.reward.should eql(0.5)
25
- line.stations.first.worker.number.should eql(1)
26
- line.stations.first.worker.settings.should eql({:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]})
27
16
  end
17
+ run = CF::Run.create(line, "run-#{title}", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
18
+ sleep 10
19
+ output = run.final_output
20
+ output.first['entity_counts_of_document'].should eql(["2", "2", "1", "2", "1", "1"])
21
+ output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "countries", "Mozart", "Japan"])
22
+ output.first['entity_relevances_of_document'].should eql([94.98649999999999, 76.0806, 48.079100000000004, 30.461899999999996, 28.9416, 21.1997])
23
+ output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Country", "Person", "Country"])
24
+ line.stations.first.worker.class.should eql(CF::RobotWorker)
25
+ line.stations.first.worker.reward.should eql(0.5)
26
+ line.stations.first.worker.number.should eql(1)
27
+ line.stations.first.worker.settings.should eql({:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]})
28
28
  end
29
29
 
30
30
  it "should create entity extraction robot worker for first station in a plain ruby way" do
31
- # WebMock.allow_net_connect!
32
- VCR.use_cassette "robot_worker/entity_extraction_robot/plain-ruby/create-worker-in-first-station", :record => :new_episodes do
33
- line = CF::Line.new("entity_extraction_robot_1","Digitization")
34
- input_format = CF::InputFormat.new({:name => "text", :required => "true"})
35
- line.input_formats input_format
31
+ WebMock.allow_net_connect!
32
+ title = "line_title#{Time.new.strftime('%Y%b%d-%H%M%S')}".downcase
33
+ sleep 1
34
+ line = CF::Line.new(title,"Digitization")
35
+ input_format = CF::InputFormat.new({:name => "text", :required => "true"})
36
+ line.input_formats input_format
36
37
 
37
- station = CF::Station.new({:type => "work"})
38
- line.stations station
38
+ station = CF::Station.new({:type => "work"})
39
+ line.stations station
39
40
 
40
- worker = CF::RobotWorker.create({:type => "entity_extraction_robot", :settings => {:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]}})
41
- line.stations.first.worker = worker
41
+ worker = CF::RobotWorker.create({:type => "entity_extraction_robot", :settings => {:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]}})
42
+ line.stations.first.worker = worker
42
43
 
43
- run = CF::Run.create(line, "entity_extraction_robot_run_1", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
44
- # sleep 20
45
- output = run.final_output
46
- output.first['entity_counts_of_document'].should eql(["2", "2", "1", "1", "2", "1"])
47
- output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "Mozart", "China", "Japan"])
48
- output.first['entity_relevances_of_document'].should eql([92.12089999999999, 73.8997, 48.079100000000004, 28.9416, 27.1982, 21.1997])
49
- output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Person", "Country", "Country"])
50
- line.stations.first.worker.class.should eql(CF::RobotWorker)
51
- line.stations.first.worker.reward.should eql(0.5)
52
- line.stations.first.worker.number.should eql(1)
53
- line.stations.first.worker.settings.should eql({:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]})
54
- end
44
+ run = CF::Run.create(line, "run-#{title}", [{"text"=> "Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"}])
45
+ sleep 10
46
+ output = run.final_output
47
+ output.first['entity_counts_of_document'].should eql(["2", "2", "1", "2", "1", "1"])
48
+ output.first['entity_names_of_document'].should eql(["Ludwig Von Beethoven", "Franz Kafka", "George Orwell", "countries", "Mozart", "Japan"])
49
+ output.first['entity_relevances_of_document'].should eql([94.98649999999999, 76.0806, 48.079100000000004, 30.461899999999996, 28.9416, 21.1997])
50
+ output.first['entity_types_of_document'].should eql(["Person", "Person", "Person", "Country", "Person", "Country"])
51
+ line.stations.first.worker.class.should eql(CF::RobotWorker)
52
+ line.stations.first.worker.reward.should eql(0.5)
53
+ line.stations.first.worker.number.should eql(1)
54
+ line.stations.first.worker.settings.should eql({:document => ["Franz Kafka and George Orwell are authors. Ludwig Von Beethoven and Mozart are musicians. China and Japan are countries"]})
55
55
  end
56
56
  end
57
57
  end