rhoconnect 5.5.18 → 7.4.1

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.
@@ -13,11 +13,11 @@ describe "Middleware" do
13
13
  @now = 10.0
14
14
  Store.flush_all
15
15
  app = double('app')
16
- app.stub(:call)
16
+ allow(app).to receive(:call)
17
17
  Rhoconnect.stats = true
18
18
  Rhoconnect::Server.enable :stats
19
19
  @middleware_new_routes = Rhoconnect::Middleware::Stats.new(app)
20
- Store.stub(:lock).and_yield
20
+ allow(Store).to receive(:lock).and_yield
21
21
  end
22
22
 
23
23
  after(:each) do
@@ -27,7 +27,7 @@ describe "Middleware" do
27
27
 
28
28
  it "should compute http average" do
29
29
  @incr = 0
30
- Time.stub(:now).and_return do
30
+ allow(Time).to receive(:now) do
31
31
  if @incr > 0
32
32
  @now += 0.3
33
33
  @incr -= 1
@@ -43,15 +43,15 @@ describe "Middleware" do
43
43
  }
44
44
  10.times { @incr = 3; @middleware_new_routes.call(env) }
45
45
  metric = 'http:GET:/api/application/query:SampleAdapter'
46
- Rhoconnect::Stats::Record.key(metric).should == "stat:#{metric}"
46
+ expect(Rhoconnect::Stats::Record.key(metric)).to eq("stat:#{metric}")
47
47
 
48
48
  # The conversion algorithm (float to string) currently checks two precisions.
49
49
  # it tries 16 digits and if that's not enough it then uses 17.
50
- Rhoconnect::Stats::Record.range(metric, 0, -1).should == [
50
+ expect(Rhoconnect::Stats::Record.range(metric, 0, -1)).to eq([
51
51
  "2.0,0.6000000000000014:12",
52
52
  "2.0,0.6000000000000014:14",
53
53
  "2.0,0.6000000000000014:16",
54
54
  "2.0,0.6000000000000014:18"
55
- ]
55
+ ])
56
56
  end
57
- end
57
+ end
@@ -50,11 +50,11 @@ describe "XDomainSessionWrapper middleware" do
50
50
  'QUERY_STRING' => PROPER_QUERY_STRING
51
51
  }
52
52
  status, headers, body = @middleware_new_routes.call(env)
53
- 200.should == status
54
- COOKIE_ANOTHER_NV.should == headers['Set-Cookie']
55
- COOKIE_NV.should_not == env['HTTP_COOKIE']
56
- headers['Content-Length'].should == body[0].length.to_s
57
- ''.should == body[0]
53
+ expect(status).to eq(200)
54
+ expect(COOKIE_ANOTHER_NV). to eq(headers['Set-Cookie'])
55
+ expect(COOKIE_NV).not_to eq(env['HTTP_COOKIE'])
56
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
57
+ expect(body[0]).to eq('')
58
58
  end
59
59
 
60
60
  it "should skip if it isn't a sync protocol URI, for old REST routes" do
@@ -63,11 +63,11 @@ describe "XDomainSessionWrapper middleware" do
63
63
  'QUERY_STRING' => PROPER_QUERY_STRING
64
64
  }
65
65
  status, headers, body = @middleware_old_routes.call(env)
66
- 200.should == status
67
- COOKIE_ANOTHER_NV.should == headers['Set-Cookie']
68
- COOKIE_NV.should_not == env['HTTP_COOKIE']
69
- headers['Content-Length'].should == body[0].length.to_s
70
- ''.should == body[0]
66
+ expect(status).to eq(200)
67
+ expect(COOKIE_ANOTHER_NV). to eq(headers['Set-Cookie'])
68
+ expect(COOKIE_NV).not_to eq(env['HTTP_COOKIE'])
69
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
70
+ expect(body[0]).to eq('')
71
71
  end
72
72
 
73
73
  it "should process cookie from QUERY_STRING if it is a sync protocol URI, for new REST routes" do
@@ -76,11 +76,11 @@ describe "XDomainSessionWrapper middleware" do
76
76
  'QUERY_STRING' => PROPER_QUERY_STRING
77
77
  }
78
78
  status, headers, body = @middleware_new_routes.call(env)
79
- 200.should == status
80
- COOKIE_ANOTHER_NV.should == headers['Set-Cookie']
81
- env['HTTP_COOKIE'].should == COOKIE_VALUE
82
- headers['Content-Length'].should == body[0].length.to_s
83
- ''.should == body[0]
79
+ expect(status).to eq(200)
80
+ expect(COOKIE_ANOTHER_NV). to eq(headers['Set-Cookie'])
81
+ expect(env['HTTP_COOKIE']).to eq(COOKIE_VALUE)
82
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
83
+ expect(body[0]).to eq('')
84
84
  end
85
85
 
86
86
  it "should process cookie from QUERY_STRING if it is a sync protocol URI, for old REST routes" do
@@ -89,11 +89,11 @@ describe "XDomainSessionWrapper middleware" do
89
89
  'QUERY_STRING' => PROPER_QUERY_STRING
90
90
  }
91
91
  status, headers, body = @middleware_old_routes.call(env)
92
- 200.should == status
93
- COOKIE_ANOTHER_NV.should == headers['Set-Cookie']
94
- env['HTTP_COOKIE'].should == COOKIE_VALUE
95
- headers['Content-Length'].should == body[0].length.to_s
96
- ''.should == body[0]
92
+ expect(status).to eq(200)
93
+ expect(COOKIE_ANOTHER_NV). to eq(headers['Set-Cookie'])
94
+ expect(env['HTTP_COOKIE']).to eq(COOKIE_VALUE)
95
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
96
+ expect(body[0]).to eq('')
97
97
  end
98
98
 
99
99
  it "shouldn't process cookie from QUERY_STRING if there is no appropriate parameter name or value, for new REST routes" do
@@ -102,11 +102,11 @@ describe "XDomainSessionWrapper middleware" do
102
102
  'QUERY_STRING' => WRONG_QUERY_STRING
103
103
  }
104
104
  status, headers, body = @middleware_new_routes.call(env)
105
- 200.should == status
106
- COOKIE_ANOTHER_NV.should == headers['Set-Cookie']
107
- env['HTTP_COOKIE'].should_not == COOKIE_VALUE
108
- headers['Content-Length'].should == body[0].length.to_s
109
- ''.should == body[0]
105
+ expect(status).to eq(200)
106
+ expect(COOKIE_ANOTHER_NV). to eq(headers['Set-Cookie'])
107
+ expect(env['HTTP_COOKIE']).not_to eq(COOKIE_VALUE)
108
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
109
+ expect(body[0]).to eq('')
110
110
  end
111
111
 
112
112
  it "shouldn't process cookie from QUERY_STRING if there is no appropriate parameter name or value, for old REST routes" do
@@ -115,11 +115,11 @@ describe "XDomainSessionWrapper middleware" do
115
115
  'QUERY_STRING' => WRONG_QUERY_STRING
116
116
  }
117
117
  status, headers, body = @middleware_old_routes.call(env)
118
- 200.should == status
119
- COOKIE_ANOTHER_NV.should == headers['Set-Cookie']
120
- env['HTTP_COOKIE'].should_not == COOKIE_VALUE
121
- headers['Content-Length'].should == body[0].length.to_s
122
- ''.should == body[0]
118
+ expect(status).to eq(200)
119
+ expect(COOKIE_ANOTHER_NV). to eq(headers['Set-Cookie'])
120
+ expect(env['HTTP_COOKIE']).not_to eq(COOKIE_VALUE)
121
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
122
+ expect(body[0]).to eq('')
123
123
  end
124
124
 
125
125
  it "should respond with cookie in a body if it is a login URI, for new REST routes" do
@@ -128,11 +128,11 @@ describe "XDomainSessionWrapper middleware" do
128
128
  'QUERY_STRING' => PROPER_QUERY_STRING
129
129
  }
130
130
  status, headers, body = @middleware_new_routes.call(env)
131
- 200.should == status
132
- headers['Set-Cookie'].should == COOKIE_ANOTHER_NV
133
- env['HTTP_COOKIE'].should == COOKIE_VALUE
134
- headers['Content-Length'].should == body[0].length.to_s
135
- ''.should_not == body[0]
131
+ expect(status).to eq(200)
132
+ expect(headers['Set-Cookie']).to eq(COOKIE_ANOTHER_NV)
133
+ expect(env['HTTP_COOKIE']).to eq(COOKIE_VALUE)
134
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
135
+ expect('').not_to eq(body[0])
136
136
  end
137
137
 
138
138
  it "should respond with cookie in a body if it is a login URI, for old REST routes" do
@@ -141,10 +141,10 @@ describe "XDomainSessionWrapper middleware" do
141
141
  'QUERY_STRING' => PROPER_QUERY_STRING
142
142
  }
143
143
  status, headers, body = @middleware_old_routes.call(env)
144
- 200.should == status
145
- headers['Set-Cookie'].should == COOKIE_ANOTHER_NV
146
- env['HTTP_COOKIE'].should == COOKIE_VALUE
147
- headers['Content-Length'].should == body[0].length.to_s
148
- ''.should_not == body[0]
144
+ expect(status).to eq(200)
145
+ expect(headers['Set-Cookie']).to eq(COOKIE_ANOTHER_NV)
146
+ expect(env['HTTP_COOKIE']).to eq(COOKIE_VALUE)
147
+ expect(headers['Content-Length']).to eq(body[0].length.to_s)
148
+ expect('').not_to eq(body[0])
149
149
  end
150
150
  end
@@ -61,7 +61,7 @@ describe "Model" do
61
61
 
62
62
  it "should create model with trailing spaces" do
63
63
  s = setup_adapter('SimpleAdapter ')
64
- Rhoconnect::Model::Base.create(s).is_a?(SimpleAdapter).should be_true
64
+ Rhoconnect::Model::Base.create(s).is_a?(SimpleAdapter).should be true
65
65
  end
66
66
 
67
67
  describe "model methods" do
@@ -152,4 +152,4 @@ describe "Model" do
152
152
  end
153
153
  end
154
154
  end
155
- end
155
+ end
@@ -578,7 +578,7 @@ describe "SourceSync" do
578
578
  set_source_queue_state(@s, {@create_queue_name => [[@s.name, [['5', { 'name' => 'Android', 'link' => '1', 'force_duplicate_error' => '1' }]]]]},@c.id,true)
579
579
  @sscud.do_cud
580
580
  verify_source_queue_data(@s, @create_queue_name => [])
581
- verify_doc_result(@c, :create_errors => {"5-error"=>{"message"=>"Error during create: object confict detected"}, "5"=>{"name"=>"Android", "link"=>"1", 'force_duplicate_error' => '1'}} )
581
+ verify_doc_result(@c, :create_errors => {"5-error"=>{"message"=>"Error during create: object conflict detected"}, "5"=>{"name"=>"Android", "link"=>"1", 'force_duplicate_error' => '1'}} )
582
582
  end
583
583
 
584
584
  it "should detect create conflict in the intermediate state create and skip the duplicate record create" do
@@ -609,7 +609,7 @@ describe "SourceSync" do
609
609
  @sscud.do_cud
610
610
 
611
611
  verify_source_queue_data(@s, @update_queue_name => [])
612
- verify_doc_result(@c, :update_errors => {"4-error"=>{"message"=>"Error during update: object confict detected"}, "4"=>{"name"=>"ErrorName", 'force_duplicate_error' => '1'}})
612
+ verify_doc_result(@c, :update_errors => {"4-error"=>{"message"=>"Error during update: object conflict detected"}, "4"=>{"name"=>"ErrorName", 'force_duplicate_error' => '1'}})
613
613
  verify_doc_result(@c, :update_rollback => {'4'=> {'name' => 'Apple'}})
614
614
  end
615
615
 
@@ -644,7 +644,7 @@ describe "SourceSync" do
644
644
  @sscud.do_cud
645
645
 
646
646
  verify_source_queue_data(@s, @update_queue_name => [])
647
- verify_doc_result(@c, :update_errors => {"4-error"=>{"message"=>"Error during update: object confict detected"}, "4"=>{"name"=>"ErrorName", 'force_duplicate_error' => '1'}})
647
+ verify_doc_result(@c, :update_errors => {"4-error"=>{"message"=>"Error during update: object conflict detected"}, "4"=>{"name"=>"ErrorName", 'force_duplicate_error' => '1'}})
648
648
  verify_doc_result(@c, :update_rollback => {'4'=> {'name' => 'Apple'}})
649
649
  end
650
650
 
@@ -704,7 +704,7 @@ describe "SourceSync" do
704
704
  @sscud.do_cud
705
705
 
706
706
  verify_source_queue_data(@s, @delete_queue_name => [])
707
- verify_doc_result(@c, :delete_errors => {"4-error"=>{"message"=>"Error during delete: object confict detected"}, "4"=>{"name"=>"Apple", 'force_duplicate_error' => '1'}})
707
+ verify_doc_result(@c, :delete_errors => {"4-error"=>{"message"=>"Error during delete: object conflict detected"}, "4"=>{"name"=>"Apple", 'force_duplicate_error' => '1'}})
708
708
  end
709
709
  end
710
710
 
data/spec/spec_helper.rb CHANGED
@@ -143,7 +143,7 @@ module TestHelpers
143
143
  end
144
144
 
145
145
  def setup_post_yield(response)
146
- RestClient.stub(:post).and_yield(response, nil, nil)
146
+ allow(RestClient).to receive(:post).and_yield(response, nil, nil)
147
147
  end
148
148
 
149
149
  def set_state(state,append=false)
@@ -186,11 +186,11 @@ module TestHelpers
186
186
  expected = result[dockey]
187
187
  begin
188
188
  if expected.is_a?(Hash)
189
- Store.get_data(dockey).should == expected
189
+ expect(Store.get_data(dockey)).to eq(expected)
190
190
  elsif expected.is_a?(Array)
191
- Store.get_data(dockey,Array).should == expected
191
+ expect(Store.get_data(dockey, Array)).to eq(expected)
192
192
  else
193
- Store.get_value(dockey).should == expected
193
+ expect(Store.get_value(dockey)).to eq(expected)
194
194
  end
195
195
  rescue RSpec::Expectations::ExpectationNotMetError => e
196
196
  message = "\nVerifying `#{dockey}`\n\n" + e.to_s
@@ -204,11 +204,11 @@ module TestHelpers
204
204
  expected = result[dockey]
205
205
  begin
206
206
  if expected.is_a?(Hash)
207
- docobj.get_data(dockey).should == expected
207
+ expect(docobj.get_data(dockey)).to eq(expected)
208
208
  elsif expected.is_a?(Array)
209
- docobj.get_data(dockey,Array).should == expected
209
+ expect(docobj.get_data(dockey,Array)).to eq(expected)
210
210
  else
211
- docobj.get_value(dockey).should == expected
211
+ expect(docobj.get_value(dockey)).to eq(expected)
212
212
  end
213
213
  rescue RSpec::Expectations::ExpectationNotMetError => e
214
214
  message = "\nVerifying `#{dockey}`\n\n" + e.to_s
@@ -222,7 +222,7 @@ module TestHelpers
222
222
  expected = result[dockey]
223
223
  begin
224
224
  data,assoc_keys = source.get_queue(dockey)
225
- data.should == expected
225
+ expect(data).to eq(expected)
226
226
  rescue RSpec::Expectations::ExpectationNotMetError => e
227
227
  message = "\nVerifying `#{dockey}`\n\n" + e.to_s
228
228
  Kernel::raise(RSpec::Expectations::ExpectationNotMetError.new(message))
@@ -16,13 +16,13 @@ describe "Record" do
16
16
  end
17
17
 
18
18
  it "should add metric to the record and trim record size" do
19
- Time.stub(:now).and_return { @now }
19
+ allow(Time).to receive(:now) { @now }
20
20
  10.times { @now += 1; Rhoconnect::Stats::Record.add('foo') }
21
21
  Store.zrange('stat:foo', 0, -1).should == ["2:12", "2:14", "2:16", "2:18"]
22
22
  end
23
23
 
24
24
  it "should add single record" do
25
- Time.stub(:now).and_return { @now += 1; @now }
25
+ allow(Time).to receive(:now) { @now += 1; @now }
26
26
  Rhoconnect::Stats::Record.add('foo')
27
27
  Store.zrange('stat:foo', 0, -1).should == ["1:10"]
28
28
  end
@@ -49,7 +49,7 @@ describe "Record" do
49
49
  end
50
50
 
51
51
  it "should add absolute metric value" do
52
- Time.stub(:now).and_return { @now }
52
+ allow(Time).to receive(:now) { @now }
53
53
  time = 0
54
54
  4.times do
55
55
  @now += 1
@@ -62,7 +62,7 @@ describe "Record" do
62
62
  it "should update metric" do
63
63
  Rhoconnect.stats = true
64
64
  @incr = 0
65
- Time.stub(:now).and_return do
65
+ allow(Time).to receive(:now) do
66
66
  if @incr > 0
67
67
  @now += 1
68
68
  @incr -= 1
@@ -80,13 +80,13 @@ describe "Record" do
80
80
  end
81
81
 
82
82
  it "should get range of metric values" do
83
- Time.stub(:now).and_return { @now }
83
+ allow(Time).to receive(:now) { @now }
84
84
  10.times { @now += 1; Rhoconnect::Stats::Record.add('foo') }
85
85
  Rhoconnect::Stats::Record.range('foo', 0, 1).should == ["2:12", "2:14"]
86
86
  end
87
87
 
88
88
  it "should reset metric" do
89
- Time.stub(:now).and_return { @now }
89
+ allow(Time).to receive(:now) { @now }
90
90
  10.times { @now += 1; Rhoconnect::Stats::Record.add('foo') }
91
91
  Store.zrange('stat:foo', 0, -1).should == ["2:12", "2:14", "2:16", "2:18"]
92
92
  Rhoconnect::Stats::Record.reset('foo')
@@ -99,4 +99,4 @@ describe "Record" do
99
99
  Rhoconnect::Stats::Record.reset_all
100
100
  Store.keys('stat:*').should == []
101
101
  end
102
- end
102
+ end