td-client 0.9.0dev2 → 1.0.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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/td/client.rb +16 -8
  3. data/lib/td/client/api.rb +66 -47
  4. data/lib/td/client/api/bulk_import.rb +1 -2
  5. data/lib/td/client/api/bulk_load.rb +3 -3
  6. data/lib/td/client/api/export.rb +12 -0
  7. data/lib/td/client/api/import.rb +3 -2
  8. data/lib/td/client/api/job.rb +146 -71
  9. data/lib/td/client/api/schedule.rb +1 -1
  10. data/lib/td/client/api_error.rb +5 -0
  11. data/lib/td/client/model.rb +92 -28
  12. data/lib/td/client/version.rb +1 -1
  13. data/spec/spec_helper.rb +5 -5
  14. data/spec/td/client/account_api_spec.rb +5 -5
  15. data/spec/td/client/api_error_spec.rb +77 -0
  16. data/spec/td/client/api_spec.rb +76 -52
  17. data/spec/td/client/api_ssl_connection_spec.rb +1 -1
  18. data/spec/td/client/bulk_import_spec.rb +28 -29
  19. data/spec/td/client/bulk_load_spec.rb +60 -35
  20. data/spec/td/client/db_api_spec.rb +1 -1
  21. data/spec/td/client/export_api_spec.rb +11 -1
  22. data/spec/td/client/import_api_spec.rb +85 -10
  23. data/spec/td/client/job_api_spec.rb +568 -61
  24. data/spec/td/client/model_job_spec.rb +27 -10
  25. data/spec/td/client/model_schedule_spec.rb +2 -2
  26. data/spec/td/client/model_schema_spec.rb +134 -0
  27. data/spec/td/client/partial_delete_api_spec.rb +1 -1
  28. data/spec/td/client/result_api_spec.rb +3 -3
  29. data/spec/td/client/sched_api_spec.rb +12 -4
  30. data/spec/td/client/server_status_api_spec.rb +2 -2
  31. data/spec/td/client/spec_resources.rb +1 -0
  32. data/spec/td/client/table_api_spec.rb +14 -14
  33. data/spec/td/client/user_api_spec.rb +12 -12
  34. data/spec/td/client_sched_spec.rb +31 -6
  35. data/spec/td/client_spec.rb +1 -0
  36. metadata +42 -81
@@ -26,7 +26,7 @@ describe 'Job Model' do
26
26
  'job_id', 'type', 'query', 'status', 'url', 'debug',
27
27
  'start_at', 'end_at', 'cpu_time', 'result_size', 'result', 'result_url',
28
28
  'hive_result_schema', 'priority', 'retry_limit', 'org_name', 'db_name',
29
- 'duration'
29
+ 'duration', 'num_records'
30
30
  ].map {|name| job_attributes[name]}
31
31
  end
32
32
 
@@ -43,20 +43,20 @@ describe 'Job Model' do
43
43
  let(:io) { StringIO.new }
44
44
 
45
45
  context 'not finished?' do
46
- before { job.stub(:finished?) { false } }
46
+ before { allow(job).to receive(:finished?) { false } }
47
47
 
48
48
  it 'do not call #job_result_raw' do
49
- client.should_not_receive(:job_result_raw)
49
+ expect(client).not_to receive(:job_result_raw)
50
50
 
51
51
  expect(job.result_raw(format, io)).to_not be
52
52
  end
53
53
  end
54
54
 
55
55
  context 'finished?' do
56
- before { job.stub(:finished?) { true } }
56
+ before { allow(job).to receive(:finished?) { true } }
57
57
 
58
58
  it 'call #job_result_raw' do
59
- client.should_receive(:job_result_raw).with(job_id, format, io)
59
+ expect(client).to receive(:job_result_raw).with(job_id, format, io)
60
60
 
61
61
  job.result_raw(format, io)
62
62
  end
@@ -90,14 +90,17 @@ describe 'Job Model' do
90
90
  end
91
91
 
92
92
  it 'calls a given block in every wait_interval second' do
93
+ now = 1_400_000_000
94
+ allow(self).to receive(:sleep){|arg| now += arg }
95
+ allow(Process).to receive(:clock_gettime){ now }
93
96
  expect { |b|
94
97
  begin
95
98
  thread = Thread.start {
96
- job.wait(nil, 0.1, &b)
99
+ job.wait(nil, 2, &b)
97
100
  }
98
- sleep 0.3
101
+ sleep 6
99
102
  change_job_status(Job::STATUS_SUCCESS)
100
- thread.join(0.5)
103
+ thread.join(1)
101
104
  expect(thread).to be_stop
102
105
  ensure
103
106
  thread.kill # just in case
@@ -108,12 +111,26 @@ describe 'Job Model' do
108
111
 
109
112
  context 'with timeout' do
110
113
  context 'the job running time is too long' do
111
- it 'raise TreasureData::Job::TimeoutError' do
114
+ it 'raise Timeout::Error' do
112
115
  expect {
113
116
  job.wait(0.1)
114
- }.to raise_error(Job::TimeoutError)
117
+ }.to raise_error(Timeout::Error)
115
118
  end
116
119
  end
120
+
121
+ it 'calls a given block in every wait_interval second, and timeout' do
122
+ expect { |b|
123
+ begin
124
+ thread = Thread.start {
125
+ job.wait(0.3, 0.1, &b)
126
+ }
127
+ expect{ thread.value }.to raise_error(Timeout::Error)
128
+ expect(thread).to be_stop
129
+ ensure
130
+ thread.kill # just in case
131
+ end
132
+ }.to yield_control.at_least(2).times
133
+ end
117
134
  end
118
135
  end
119
136
  end
@@ -14,11 +14,11 @@ describe 'Schedule Model' do
14
14
  let(:num) { 1 }
15
15
 
16
16
  before do
17
- API.stub(:new).with(api_key, {}).and_return(api)
17
+ allow(API).to receive(:new).with(api_key, {}).and_return(api)
18
18
  end
19
19
 
20
20
  it 'success call api' do
21
- api.should_receive(:run_schedule).with(name, time, num).and_return([])
21
+ expect(api).to receive(:run_schedule).with(name, time, num).and_return([])
22
22
 
23
23
  schedule.run(time, num)
24
24
  end
@@ -0,0 +1,134 @@
1
+ require 'spec_helper'
2
+ require 'td/client/spec_resources'
3
+
4
+ describe 'TreasureData::Schema::Field' do
5
+ describe '.new' do
6
+ context 'name="v"' do
7
+ it 'raises ParameterValidationError' do
8
+ expect{ Schema::Field.new('v', 'int') }.to raise_error(ParameterValidationError)
9
+ end
10
+ end
11
+ context 'name="time"' do
12
+ it 'raises ParameterValidationError' do
13
+ expect{ Schema::Field.new('time', 'int') }.to raise_error(ParameterValidationError)
14
+ end
15
+ end
16
+ context 'name with UTF-8' do
17
+ it 'works' do
18
+ name = "\u3042\u3044\u3046"
19
+ f = Schema::Field.new(name, 'int')
20
+ expect(f.name).to eq name
21
+ expect(f.type).to eq 'int'
22
+ expect(f.sql_alias).to be_nil
23
+ end
24
+ end
25
+ context 'with sql_alias' do
26
+ it 'raises' do
27
+ f = Schema::Field.new('t:t', 'int', 'alice')
28
+ expect(f.name).to eq 't:t'
29
+ expect(f.type).to eq 'int'
30
+ expect(f.sql_alias).to eq 'alice'
31
+ end
32
+ end
33
+ context 'with invalid sql_alias' do
34
+ it 'raises' do
35
+ expect{ Schema::Field.new('t:t', 'int', 't:t') }.to raise_error(ParameterValidationError)
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ describe 'TreasureData::Schema' do
42
+ describe '.parse' do
43
+ let(:columns){ ["foo:int", "BAR\u3070\u30FC:string@bar", "baz:baz!:array<double>@baz"] }
44
+ it do
45
+ sc = Schema.parse(columns)
46
+ expect(sc.fields.size).to eq 3
47
+ expect(sc.fields[0].name).to eq 'foo'
48
+ expect(sc.fields[0].type).to eq 'int'
49
+ expect(sc.fields[0].sql_alias).to be_nil
50
+ expect(sc.fields[1].name).to eq "BAR\u3070\u30FC"
51
+ expect(sc.fields[1].type).to eq 'string'
52
+ expect(sc.fields[1].sql_alias).to eq 'bar'
53
+ expect(sc.fields[2].name).to eq 'baz:baz!'
54
+ expect(sc.fields[2].type).to eq 'array<double>'
55
+ expect(sc.fields[2].sql_alias).to eq 'baz'
56
+ end
57
+ end
58
+
59
+ describe '.new' do
60
+ it do
61
+ f = Schema::Field.new('a', 'int')
62
+ sc = Schema.new([f])
63
+ expect(sc.fields[0]).to eq f
64
+ end
65
+ end
66
+
67
+ describe '#fields' do
68
+ it do
69
+ f = Schema::Field.new('a', 'int')
70
+ sc = Schema.new([f])
71
+ expect(sc.fields[0]).to eq f
72
+ end
73
+ end
74
+
75
+ describe '#add_field' do
76
+ it do
77
+ f = Schema::Field.new('a', 'int')
78
+ sc = Schema.new([f])
79
+ sc.add_field('b', 'double', 'bb')
80
+ expect(sc.fields[1].name).to eq 'b'
81
+ end
82
+ it 'raises ParameterValidationError if name is duplicated' do
83
+ f = Schema::Field.new('a', 'int')
84
+ sc = Schema.new([f])
85
+ expect{ sc.add_field('a', 'double') }.to raise_error(ParameterValidationError)
86
+ end
87
+ it 'raises ParameterValidationError if sql_alias is duplicated' do
88
+ f = Schema::Field.new('a', 'int')
89
+ sc = Schema.new([f])
90
+ expect{ sc.add_field('abc', 'double', 'a') }.to raise_error(ParameterValidationError)
91
+ end
92
+ end
93
+
94
+ describe '#merge' do
95
+ it do
96
+ sc1 = Schema.parse(['foo:int', 'bar:float'])
97
+ sc2 = Schema.parse(['bar:double', 'baz:string'])
98
+ sc3 = sc1.merge(sc2)
99
+ expect(sc3.fields.size).to eq 3
100
+ expect(sc3.fields[0].name).to eq 'foo'
101
+ expect(sc3.fields[0].type).to eq 'int'
102
+ expect(sc3.fields[1].name).to eq 'bar'
103
+ expect(sc3.fields[1].type).to eq 'double'
104
+ expect(sc3.fields[2].name).to eq 'baz'
105
+ expect(sc3.fields[2].type).to eq 'string'
106
+ end
107
+ it do
108
+ sc1 = Schema.parse(['foo:int', 'bar:float'])
109
+ sc2 = Schema.parse(['bar:double@foo'])
110
+ expect{ sc1.merge(sc2) }.to raise_error(ArgumentError)
111
+ end
112
+ end
113
+
114
+ describe '#to_json' do
115
+ it do
116
+ sc = Schema.parse(['foo:int', 'bar:float@baz'])
117
+ expect(sc.to_json).to eq '[["foo","int"],["bar","float","baz"]]'
118
+ end
119
+ end
120
+
121
+ describe '#from_json' do
122
+ it do
123
+ sc = Schema.new
124
+ sc.from_json [["foo","int"],["bar","float","baz"]]
125
+ expect(sc.fields.size).to eq 2
126
+ expect(sc.fields[0].name).to eq 'foo'
127
+ expect(sc.fields[0].type).to eq 'int'
128
+ expect(sc.fields[0].sql_alias).to be_nil
129
+ expect(sc.fields[1].name).to eq 'bar'
130
+ expect(sc.fields[1].type).to eq 'float'
131
+ expect(sc.fields[1].sql_alias).to eq 'baz'
132
+ end
133
+ end
134
+ end
@@ -27,7 +27,7 @@ describe 'PartialDelete API' do
27
27
  stub_api_request(:post, "/v3/table/partialdelete/#{e(db_name)}/#{e(table_name)}").with(:body => from_to).
28
28
  to_return(:body => {'database' => db_name, 'table' => table_name, 'job_id' => '1'}.to_json)
29
29
 
30
- api.partial_delete(db_name, table_name, to, from).should == '1'
30
+ expect(api.partial_delete(db_name, table_name, to, from)).to eq('1')
31
31
  end
32
32
 
33
33
  it 'should return 404 error with non exist database name' do
@@ -14,7 +14,7 @@ describe 'Result API' do
14
14
  params = {'url' => result_url}
15
15
  stub_api_request(:post, "/v3/result/create/#{e(result_name)}").with(:body => params).to_return(:body => {'result' => result_name}.to_json)
16
16
 
17
- api.create_result(result_name, result_url).should be true
17
+ expect(api.create_result(result_name, result_url)).to be true
18
18
  end
19
19
 
20
20
  it 'should return 422 error with invalid name' do
@@ -56,14 +56,14 @@ describe 'Result API' do
56
56
  it 'should return name and url' do
57
57
  stub_api_request(:get, '/v3/result/list').
58
58
  to_return(:body => {'results' => [{'name' => 'name', 'url' => 'url'}]}.to_json)
59
- api.list_result.should == [['name', 'url', nil]]
59
+ expect(api.list_result).to eq([['name', 'url', nil]])
60
60
  end
61
61
  end
62
62
 
63
63
  describe 'delete_result' do
64
64
  it 'should delete the result' do
65
65
  stub_api_request(:post, "/v3/result/delete/#{e(result_name)}")
66
- api.delete_result(result_name).should == true
66
+ expect(api.delete_result(result_name)).to eq(true)
67
67
  end
68
68
 
69
69
  it 'should raise error' do
@@ -20,7 +20,15 @@ describe 'Schedule API' do
20
20
  with(:body => opts.merge('type' => 'hive')).
21
21
  to_return(:body => {'name' => sched_name, 'start' => start.to_s}.to_json)
22
22
 
23
- api.create_schedule(sched_name, opts.merge('type' => 'hive')).should == start.to_s
23
+ expect(api.create_schedule(sched_name, opts.merge('type' => 'hive'))).to eq(start.to_s)
24
+ end
25
+
26
+ it 'should create a dummy schedule' do
27
+ stub_api_request(:post, "/v3/schedule/create/#{e(sched_name)}").
28
+ with(:body => opts.merge('type' => 'hive')).
29
+ to_return(:body => {'name' => sched_name, 'start' => nil}.to_json)
30
+
31
+ expect(api.create_schedule(sched_name, opts.merge('type' => 'hive'))).to be_nil
24
32
  end
25
33
 
26
34
  it 'should return 422 error with invalid name' do
@@ -40,7 +48,7 @@ describe 'Schedule API' do
40
48
  it 'should delete the schedule' do
41
49
  stub_api_request(:post, "/v3/schedule/delete/#{e(sched_name)}").
42
50
  to_return(:body => {'cron' => 'cron', 'query' => 'query'}.to_json)
43
- api.delete_schedule(sched_name).should == ['cron', 'query']
51
+ expect(api.delete_schedule(sched_name)).to eq(['cron', 'query'])
44
52
  end
45
53
  end
46
54
 
@@ -86,7 +94,7 @@ describe 'Schedule API' do
86
94
  stub_api_request(:get, "/v3/schedule/history/#{e(sched_name)}").
87
95
  with(:query => {'from' => 0, 'to' => 100}).
88
96
  to_return(:body => {'history' => [history]}.to_json)
89
- api.history(sched_name, 0, 100).should == [[nil, 'job_id', :type, 'status', 'query', 'start_at', 'end_at', 'result', 'priority', 'database']]
97
+ expect(api.history(sched_name, 0, 100)).to eq([[nil, 'job_id', :type, 'status', 'query', 'start_at', 'end_at', 'result', 'priority', 'database']])
90
98
  end
91
99
  end
92
100
 
@@ -95,7 +103,7 @@ describe 'Schedule API' do
95
103
  stub_api_request(:post, "/v3/schedule/run/#{e(sched_name)}/123456789").
96
104
  with(:body => {'num' => '5'}).
97
105
  to_return(:body => {'jobs' => [{'job_id' => 'job_id', 'scheduled_at' => 'scheduled_at', 'type' => 'type'}]}.to_json)
98
- api.run_schedule(sched_name, 123456789, 5).should == [['job_id', :type, 'scheduled_at']]
106
+ expect(api.run_schedule(sched_name, 123456789, 5)).to eq([['job_id', :type, 'scheduled_at']])
99
107
  end
100
108
  end
101
109
  end
@@ -13,13 +13,13 @@ describe 'ServerStatus API' do
13
13
  it 'returns status' do
14
14
  stub_api_request(:get, '/v3/system/server_status').
15
15
  to_return(:body => {'status' => 'OK'}.to_json)
16
- api.server_status.should == 'OK'
16
+ expect(api.server_status).to eq('OK')
17
17
  end
18
18
 
19
19
  it 'returns error description' do
20
20
  stub_api_request(:get, '/v3/system/server_status').
21
21
  to_return(:status => 500)
22
- api.server_status.should == 'Server is down (500)'
22
+ expect(api.server_status).to eq('Server is down (500)')
23
23
  end
24
24
  end
25
25
  end
@@ -86,6 +86,7 @@ shared_context 'job resources' do
86
86
  "result_size" => i * 1000,
87
87
  'retry_limit' => 10,
88
88
  "duration" => i,
89
+ "num_records" => i * 1000,
89
90
  'organization' => nil,
90
91
  'hive_result_schema' => nil,
91
92
  'debug' => {
@@ -27,7 +27,7 @@ describe 'Table API' do
27
27
  it 'should create a new table if the database exists' do
28
28
  stub_api_request(:post, "/v3/table/create/#{e db_name}/#{e(table_name)}/log").
29
29
  to_return(:body => {'database' => db_name, 'table' => table_name, 'type' => 'log'}.to_json)
30
- api.create_log_table(db_name, table_name).should be true
30
+ expect(api.create_log_table(db_name, table_name)).to be true
31
31
  end
32
32
 
33
33
  it 'should return 400 error with invalid name' do
@@ -82,10 +82,10 @@ describe 'Table API' do
82
82
  describe "'tables' Client API" do
83
83
  it 'should return an array of Table objects' do
84
84
  tables = [
85
- ["table_1", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 111, "2013-01-21 01:51:41 UTC", "2014-01-21 01:51:41 UTC"],
86
- ["table_2", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 222, "2013-02-22 02:52:42 UTC", "2014-02-22 02:52:42 UTC"],
87
- ["table_3", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
88
- ["table_4", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
85
+ ["table_1", "item", "[[\"value\",\"string\"]]", 111, "2013-01-21 01:51:41 UTC", "2014-01-21 01:51:41 UTC"],
86
+ ["table_2", "log", "[[\"value\",\"long\"]]", 222, "2013-02-22 02:52:42 UTC", "2014-02-22 02:52:42 UTC"],
87
+ ["table_3", "item", "[[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
88
+ ["table_4", "log", "[[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
89
89
  ]
90
90
  stub_api_request(:get, "/v3/table/list/#{e db_name}").
91
91
  to_return(:body => {'tables' => [
@@ -138,10 +138,10 @@ describe 'Table API' do
138
138
  describe "'table' Client API" do
139
139
  it 'should return the Table object corresponding to the name' do
140
140
  tables = [
141
- ["table_1", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 111, "2013-01-21 01:51:41 UTC", "2014-01-21 01:51:41 UTC"],
142
- ["table_2", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 222, "2013-02-22 02:52:42 UTC", "2014-02-22 02:52:42 UTC"],
143
- ["table_3", "item", "[[\"time\",\"long\"],[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
144
- ["table_4", "log", "[[\"time\",\"long\"],[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
141
+ ["table_1", "item", "[[\"value\",\"string\"]]", 111, "2013-01-21 01:51:41 UTC", "2014-01-21 01:51:41 UTC"],
142
+ ["table_2", "log", "[[\"value\",\"long\"]]", 222, "2013-02-22 02:52:42 UTC", "2014-02-22 02:52:42 UTC"],
143
+ ["table_3", "item", "[[\"value\",\"string\"]]", 333, "2013-03-23 03:53:43 UTC", "2014-03-23 03:53:43 UTC"],
144
+ ["table_4", "log", "[[\"value\",\"long\"]]", 444, "2013-04-24 04:54:44 UTC", "2014-04-24 04:54:44 UTC"]
145
145
  ]
146
146
  stub_api_request(:get, "/v3/table/list/#{e db_name}").
147
147
  to_return(:body => {'tables' => [
@@ -166,7 +166,7 @@ describe 'Table API' do
166
166
  describe 'swap_table' do
167
167
  it 'should swap tables' do
168
168
  stub_api_request(:post, '/v3/table/swap/db/table1/table2')
169
- api.swap_table('db', 'table1', 'table2').should == true
169
+ expect(api.swap_table('db', 'table1', 'table2')).to eq(true)
170
170
  end
171
171
  end
172
172
 
@@ -175,7 +175,7 @@ describe 'Table API' do
175
175
  stub_api_request(:post, '/v3/table/update/db/table').
176
176
  with(:body => {'expire_days' => '5'}).
177
177
  to_return(:body => {'type' => 'type'}.to_json)
178
- api.update_expire('db', 'table', 5).should == true
178
+ expect(api.update_expire('db', 'table', 5)).to eq(true)
179
179
  end
180
180
  end
181
181
 
@@ -197,14 +197,14 @@ describe 'Table API' do
197
197
  api.tail('db', 'table', 10) do |row|
198
198
  result << row
199
199
  end
200
- result.should == [[1, 2, 3], [4, 5, 6]]
200
+ expect(result).to eq([[1, 2, 3], [4, 5, 6]])
201
201
  end
202
202
 
203
203
  it 'returns rows' do
204
204
  stub_api_request(:get, '/v3/table/tail/db/table').
205
205
  with(:query => {'format' => 'msgpack', 'count' => '10'}).
206
206
  to_return(:body => packed)
207
- api.tail('db', 'table', 10).should == [[1, 2, 3], [4, 5, 6]]
207
+ expect(api.tail('db', 'table', 10)).to eq([[1, 2, 3], [4, 5, 6]])
208
208
  end
209
209
 
210
210
  it 'shows deprecated warning for from and to' do
@@ -220,7 +220,7 @@ describe 'Table API' do
220
220
  $stderr.reopen(backup)
221
221
  w.close
222
222
  end
223
- r.read.should == %Q(parameter "to" and "from" no longer work\n)
223
+ expect(r.read).to eq(%Q(parameter "to" and "from" no longer work\n))
224
224
  end
225
225
  end
226
226
  end
@@ -14,7 +14,7 @@ describe 'User API' do
14
14
  it 'returns apikey' do
15
15
  stub_api_request(:post, "/v3/user/authenticate").
16
16
  to_return(:body => {'apikey' => 'apikey'}.to_json)
17
- api.authenticate('user', 'password').should == 'apikey'
17
+ expect(api.authenticate('user', 'password')).to eq('apikey')
18
18
  end
19
19
 
20
20
  it 'raises AuthError for authentication failure' do
@@ -38,30 +38,30 @@ describe 'User API' do
38
38
  it 'returns users' do
39
39
  stub_api_request(:get, "/v3/user/list").
40
40
  to_return(:body => {'users' => [{'name' => 'name1', 'email' => 'email1'}, {'name' => 'name2', 'email' => 'email2'}]}.to_json)
41
- api.list_users.should == [
41
+ expect(api.list_users).to eq([
42
42
  ['name1', nil, nil, 'email1'],
43
43
  ['name2', nil, nil, 'email2'],
44
- ]
44
+ ])
45
45
  end
46
46
  end
47
47
 
48
48
  describe 'add_user' do
49
49
  it 'runs' do
50
50
  stub_api_request(:post, "/v3/user/add/name").to_return(:body => {}.to_json)
51
- api.add_user('name', "org", 'name+suffix@example.com', 'password').should == true
51
+ expect(api.add_user('name', "org", 'name+suffix@example.com', 'password')).to eq(true)
52
52
  end
53
53
 
54
54
  # TODO
55
55
  it 'does not escape sp but it must be a bug' do
56
56
  stub_api_request(:post, "/v3/user/add/!%20%20%20%20@%23$%25%5E&*()_%2B%7C~%2Ecom").to_return(:body => {}.to_json)
57
- api.add_user('! @#$%^&*()_+|~.com', "org", 'name+suffix@example.com', 'password').should == true
57
+ expect(api.add_user('! @#$%^&*()_+|~.com', "org", 'name+suffix@example.com', 'password')).to eq(true)
58
58
  end
59
59
  end
60
60
 
61
61
  describe 'remove_user' do
62
62
  it 'runs' do
63
63
  stub_api_request(:post, "/v3/user/remove/name").to_return(:body => {}.to_json)
64
- api.remove_user('name').should == true
64
+ expect(api.remove_user('name')).to eq(true)
65
65
  end
66
66
  end
67
67
 
@@ -70,7 +70,7 @@ describe 'User API' do
70
70
  stub_api_request(:post, "/v3/user/email/change/name").
71
71
  with(:body => {'email' => 'new@email.com'}).
72
72
  to_return(:body => {}.to_json)
73
- api.change_email('name', 'new@email.com').should == true
73
+ expect(api.change_email('name', 'new@email.com')).to eq(true)
74
74
  end
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ describe 'User API' do
78
78
  it 'runs' do
79
79
  stub_api_request(:get, "/v3/user/apikey/list/name").
80
80
  to_return(:body => {'apikeys' => ['key1', 'key2']}.to_json)
81
- api.list_apikeys('name').should == ['key1', 'key2']
81
+ expect(api.list_apikeys('name')).to eq(['key1', 'key2'])
82
82
  end
83
83
  end
84
84
 
@@ -86,7 +86,7 @@ describe 'User API' do
86
86
  it 'does not return the generated apikey because you can list apikey afterwards' do
87
87
  stub_api_request(:post, "/v3/user/apikey/add/name").
88
88
  to_return(:body => {'apikey' => 'apikey'}.to_json)
89
- api.add_apikey('name').should == true
89
+ expect(api.add_apikey('name')).to eq(true)
90
90
  end
91
91
  end
92
92
 
@@ -94,7 +94,7 @@ describe 'User API' do
94
94
  it 'runs' do
95
95
  stub_api_request(:post, "/v3/user/apikey/remove/name").
96
96
  to_return(:body => {}.to_json)
97
- api.remove_apikey('name', 'apikey').should == true
97
+ expect(api.remove_apikey('name', 'apikey')).to eq(true)
98
98
  end
99
99
  end
100
100
 
@@ -103,7 +103,7 @@ describe 'User API' do
103
103
  stub_api_request(:post, "/v3/user/password/change/name").
104
104
  with(:body => {'password' => 'password'}).
105
105
  to_return(:body => {}.to_json)
106
- api.change_password('name', 'password').should == true
106
+ expect(api.change_password('name', 'password')).to eq(true)
107
107
  end
108
108
  end
109
109
 
@@ -112,7 +112,7 @@ describe 'User API' do
112
112
  stub_api_request(:post, "/v3/user/password/change").
113
113
  with(:body => {'old_password' => 'old_password', 'password' => 'password'}).
114
114
  to_return(:body => {}.to_json)
115
- api.change_my_password('old_password', 'password').should == true
115
+ expect(api.change_my_password('old_password', 'password')).to eq(true)
116
116
  end
117
117
  end
118
118
  end