td-client 0.8.79 → 0.8.80

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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
@@ -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,7 @@ 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
24
  end
25
25
 
26
26
  it 'should create a dummy schedule' do
@@ -28,7 +28,7 @@ describe 'Schedule API' do
28
28
  with(:body => opts.merge('type' => 'hive')).
29
29
  to_return(:body => {'name' => sched_name, 'start' => nil}.to_json)
30
30
 
31
- api.create_schedule(sched_name, opts.merge('type' => 'hive')).should be_nil
31
+ expect(api.create_schedule(sched_name, opts.merge('type' => 'hive'))).to be_nil
32
32
  end
33
33
 
34
34
  it 'should return 422 error with invalid name' do
@@ -48,7 +48,7 @@ describe 'Schedule API' do
48
48
  it 'should delete the schedule' do
49
49
  stub_api_request(:post, "/v3/schedule/delete/#{e(sched_name)}").
50
50
  to_return(:body => {'cron' => 'cron', 'query' => 'query'}.to_json)
51
- api.delete_schedule(sched_name).should == ['cron', 'query']
51
+ expect(api.delete_schedule(sched_name)).to eq(['cron', 'query'])
52
52
  end
53
53
  end
54
54
 
@@ -94,7 +94,7 @@ describe 'Schedule API' do
94
94
  stub_api_request(:get, "/v3/schedule/history/#{e(sched_name)}").
95
95
  with(:query => {'from' => 0, 'to' => 100}).
96
96
  to_return(:body => {'history' => [history]}.to_json)
97
- 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']])
98
98
  end
99
99
  end
100
100
 
@@ -103,7 +103,7 @@ describe 'Schedule API' do
103
103
  stub_api_request(:post, "/v3/schedule/run/#{e(sched_name)}/123456789").
104
104
  with(:body => {'num' => '5'}).
105
105
  to_return(:body => {'jobs' => [{'job_id' => 'job_id', 'scheduled_at' => 'scheduled_at', 'type' => 'type'}]}.to_json)
106
- 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']])
107
107
  end
108
108
  end
109
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
@@ -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
@@ -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
@@ -28,14 +28,14 @@ describe 'Schedule Command' do
28
28
  context 'start is now' do
29
29
  let (:start){ Time.now.round }
30
30
  it 'returns Time object' do
31
- client.create_schedule(sched_name, opts).should == start
31
+ expect(client.create_schedule(sched_name, opts)).to eq(start)
32
32
  end
33
33
  end
34
34
 
35
35
  context 'start is nil' do
36
36
  let (:start){ nil }
37
37
  it do
38
- client.create_schedule(sched_name, opts).should == start
38
+ expect(client.create_schedule(sched_name, opts)).to eq(start)
39
39
  end
40
40
  end
41
41
  end
@@ -58,11 +58,11 @@ describe 'Schedule Command' do
58
58
  to_return(:body => {'count' => 1, 'history' => [h]}.to_json)
59
59
 
60
60
  client.history(sched_name, 0, 19).each do |scheduled_job|
61
- scheduled_job.scheduled_at.xmlschema.should == Time.parse('2015-02-17T14:16:00+09:00').xmlschema #avoid depending on CI's Locale
62
- scheduled_job.job_id.should == 'job_id'
63
- scheduled_job.status.should == 'status'
64
- scheduled_job.priority.should == 'priority'
65
- scheduled_job.result_url.should == 'result'
61
+ expect(scheduled_job.scheduled_at.xmlschema).to eq(Time.parse('2015-02-17T14:16:00+09:00').xmlschema) #avoid depending on CI's Locale
62
+ expect(scheduled_job.job_id).to eq('job_id')
63
+ expect(scheduled_job.status).to eq('status')
64
+ expect(scheduled_job.priority).to eq('priority')
65
+ expect(scheduled_job.result_url).to eq('result')
66
66
  end
67
67
  end
68
68
 
@@ -72,7 +72,7 @@ describe 'Schedule Command' do
72
72
  to_return(:body => {'count' => 1, 'history' => [h]}.to_json)
73
73
 
74
74
  client.history(sched_name, 0, 19).each do |scheduled_job|
75
- scheduled_job.scheduled_at.should == nil
75
+ expect(scheduled_job.scheduled_at).to eq(nil)
76
76
  end
77
77
  end
78
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.79
4
+ version: 0.8.80
5
5
  platform: ruby
6
6
  authors:
7
7
  - Treasure Data, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-25 00:00:00.000000000 Z
11
+ date: 2016-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -88,14 +88,14 @@ dependencies:
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: '2.8'
91
+ version: '3.0'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: '2.8'
98
+ version: '3.0'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: mime-types
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  version: '0'
265
265
  requirements: []
266
266
  rubyforge_project:
267
- rubygems_version: 2.4.5.1
267
+ rubygems_version: 2.5.1
268
268
  signing_key:
269
269
  specification_version: 4
270
270
  summary: Treasure Data API library for Ruby