nexmos 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,63 +2,65 @@ require 'spec_helper'
2
2
  describe ::Nexmos::Number do
3
3
  let(:webmock_default_headers) do
4
4
  {
5
- :headers => {
6
- 'Accept' => 'application/json',
7
- 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
8
- 'User-Agent' => ::Nexmos.user_agent
9
- }
5
+ :headers => {
6
+ 'Accept' => 'application/json',
7
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
8
+ 'User-Agent' => ::Nexmos.user_agent
9
+ }
10
10
  }
11
11
  end
12
12
 
13
13
  let(:finland_numbers_search) do
14
- {"numbers" => [
15
- {"type" => "mobile-lvn",
16
- "msisdn" => "3584573950816",
17
- "country" => "FI",
18
- "cost" => "3.00"},
19
- {"type" => "mobile-lvn",
20
- "msisdn" => "3584573950815",
21
- "country" => "FI",
22
- "cost" => "3.00"},
23
- {"type" => "mobile-lvn",
24
- "msisdn" => "3584573950814",
25
- "country" => "FI",
26
- "cost" => "3.00"},
27
- {"type" => "mobile-lvn",
28
- "msisdn" => "3584573950813",
29
- "country" => "FI",
30
- "cost" => "3.00"},
31
- {"type" => "mobile-lvn",
32
- "msisdn" => "3584573950812",
33
- "country" => "FI",
34
- "cost" => "3.00"},
35
- {"type" => "mobile-lvn",
36
- "msisdn" => "3584573950806",
37
- "country" => "FI",
38
- "cost" => "3.00"},
39
- {"type" => "mobile-lvn",
40
- "msisdn" => "3584573950805",
41
- "country" => "FI",
42
- "cost" => "3.00"},
43
- {"type" => "mobile-lvn",
44
- "msisdn" => "3584573950804",
45
- "country" => "FI",
46
- "cost" => "3.00"},
47
- {"type" => "mobile-lvn",
48
- "msisdn" => "3584573950798",
49
- "country" => "FI",
50
- "cost" => "3.00"},
51
- {"type" => "mobile-lvn",
52
- "msisdn" => "3584573950796",
53
- "country" => "FI",
54
- "cost" => "3.00"}],
55
- "count" => 22}
14
+ {
15
+ "numbers" => [
16
+ { "type" => "mobile-lvn",
17
+ "msisdn" => "3584573950816",
18
+ "country" => "FI",
19
+ "cost" => "3.00" },
20
+ { "type" => "mobile-lvn",
21
+ "msisdn" => "3584573950815",
22
+ "country" => "FI",
23
+ "cost" => "3.00" },
24
+ { "type" => "mobile-lvn",
25
+ "msisdn" => "3584573950814",
26
+ "country" => "FI",
27
+ "cost" => "3.00" },
28
+ { "type" => "mobile-lvn",
29
+ "msisdn" => "3584573950813",
30
+ "country" => "FI",
31
+ "cost" => "3.00" },
32
+ { "type" => "mobile-lvn",
33
+ "msisdn" => "3584573950812",
34
+ "country" => "FI",
35
+ "cost" => "3.00" },
36
+ { "type" => "mobile-lvn",
37
+ "msisdn" => "3584573950806",
38
+ "country" => "FI",
39
+ "cost" => "3.00" },
40
+ { "type" => "mobile-lvn",
41
+ "msisdn" => "3584573950805",
42
+ "country" => "FI",
43
+ "cost" => "3.00" },
44
+ { "type" => "mobile-lvn",
45
+ "msisdn" => "3584573950804",
46
+ "country" => "FI",
47
+ "cost" => "3.00" },
48
+ { "type" => "mobile-lvn",
49
+ "msisdn" => "3584573950798",
50
+ "country" => "FI",
51
+ "cost" => "3.00" },
52
+ { "type" => "mobile-lvn",
53
+ "msisdn" => "3584573950796",
54
+ "country" => "FI",
55
+ "cost" => "3.00" }
56
+ ],
57
+ "count" => 22 }.to_json
56
58
  end
57
59
 
58
60
  before(:each) do
59
61
  ::Nexmos.reset!
60
62
  ::Nexmos.setup do |c|
61
- c.api_key = 'default_key'
63
+ c.api_key = 'default_key'
62
64
  c.api_secret = 'default_secret'
63
65
  end
64
66
  end
@@ -72,15 +74,15 @@ describe ::Nexmos::Number do
72
74
 
73
75
  it 'should return list of numbers' do
74
76
  request = stub_request(:get, "https://rest.nexmo.com/number/search?api_key=default_key&api_secret=default_secret&country=FI").
75
- with(webmock_default_headers).to_return(:status => 200, :body => finland_numbers_search, :headers => {})
76
- res = subject.search(:country => 'FI')
77
- res.should be_kind_of(::Hash)
78
- res.success?.should be_true
79
- res['count'].should == 22
80
- res['numbers'].should be_kind_of(::Array)
81
- res['numbers'].size.should == 10
82
- res['numbers'].first.keys.sort.should == ["cost", "country", "msisdn", "type"]
83
- request.should have_been_made.once
77
+ with(webmock_default_headers).to_return(:status => 200, :body => finland_numbers_search, :headers => {'Content-Type' => 'application/json'})
78
+ res = subject.search(:country => 'FI')
79
+ expect(res).to be_kind_of(::Hash)
80
+ expect(res.success?).to be_truthy
81
+ expect(res['count']).to eq(22)
82
+ expect(res['numbers']).to be_kind_of(::Array)
83
+ expect(res['numbers'].size).to eq(10)
84
+ expect(res['numbers'].first.keys.sort).to eq(["cost", "country", "msisdn", "type"])
85
+ expect(request).to have_been_made.once
84
86
  end
85
87
  end
86
88
 
@@ -95,13 +97,13 @@ describe ::Nexmos::Number do
95
97
  it 'should buy number' do
96
98
  request = stub_request(:post, "https://rest.nexmo.com/number/buy").
97
99
  with(
98
- :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=> ::Nexmos.user_agent},
99
- :body => {"api_key"=>"default_key", "api_secret"=>"default_secret", "country"=>"FI", "msisdn"=>"3584573950816"}
100
- ).to_return(:status => 200, :body => "", :headers => {})
101
- res = subject.buy(:country => 'FI', :msisdn => '3584573950816' )
102
- res.should be_kind_of(::Hash)
103
- res.success?.should be_true
104
- request.should have_been_made.once
100
+ :headers => { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => ::Nexmos.user_agent },
101
+ :body => { "api_key" => "default_key", "api_secret" => "default_secret", "country" => "FI", "msisdn" => "3584573950816" }
102
+ ).to_return(:status => 200, :body => "", :headers => {'Content-Type' => 'application/json'})
103
+ res = subject.buy(:country => 'FI', :msisdn => '3584573950816')
104
+ expect(res).to be_kind_of(::Hash)
105
+ expect(res.success?).to be_truthy
106
+ expect(request).to have_been_made.once
105
107
  end
106
108
 
107
109
  end
@@ -3,14 +3,29 @@ describe ::Nexmos do
3
3
  subject{ ::Nexmos }
4
4
 
5
5
  before(:each) do
6
- subject.reset!
6
+ described_class.reset!
7
7
  end
8
8
 
9
9
  context '#reset!' do
10
- its(:user_agent) { should == "Nexmos v#{::Nexmos::VERSION}" }
11
- its(:api_key) { should be_nil }
12
- its(:api_secret) { should be_nil }
13
- its(:logger) { should be_kind_of(::Logger) }
10
+ describe '#user_agent' do
11
+ subject { super().user_agent }
12
+ it { is_expected.to eq("Nexmos v#{::Nexmos::VERSION}") }
13
+ end
14
+
15
+ describe '#api_key' do
16
+ subject { super().api_key }
17
+ it { is_expected.to be_nil }
18
+ end
19
+
20
+ describe '#api_secret' do
21
+ subject { super().api_secret }
22
+ it { is_expected.to be_nil }
23
+ end
24
+
25
+ describe '#logger' do
26
+ subject { super().logger }
27
+ it { is_expected.to be_kind_of(::Logger) }
28
+ end
14
29
  end
15
30
 
16
31
  context '#setup' do
@@ -20,7 +35,7 @@ describe ::Nexmos do
20
35
  subject.setup do |c|
21
36
  c.user_agent = 'Test1245'
22
37
  end
23
- subject.user_agent.should == 'Test1245'
38
+ expect(subject.user_agent).to eq('Test1245')
24
39
  end
25
40
 
26
41
  it 'should set logger' do
@@ -28,21 +43,21 @@ describe ::Nexmos do
28
43
  subject.setup do |c|
29
44
  c.logger = newlogger
30
45
  end
31
- subject.logger.should == newlogger
46
+ expect(subject.logger).to eq(newlogger)
32
47
  end
33
48
 
34
49
  it 'should set api_key' do
35
50
  subject.setup do |c|
36
51
  c.api_key = 'test-api-key'
37
52
  end
38
- subject.api_key.should == 'test-api-key'
53
+ expect(subject.api_key).to eq('test-api-key')
39
54
  end
40
55
 
41
56
  it 'should set api_secret' do
42
57
  subject.setup do |c|
43
58
  c.api_secret = 'test-api-secret'
44
59
  end
45
- subject.api_secret.should == 'test-api-secret'
60
+ expect(subject.api_secret).to eq('test-api-secret')
46
61
  end
47
62
 
48
63
  end
@@ -55,9 +70,9 @@ describe ::Nexmos do
55
70
  subject.setup do |c|
56
71
  c.api_key = 'test-api-key2'
57
72
  end
58
- subject.api_key.should == 'test-api-key'
73
+ expect(subject.api_key).to eq('test-api-key')
59
74
  end
60
75
  end
61
76
  end
62
77
 
63
- end
78
+ end
@@ -1,23 +1,18 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
1
+ require 'simplecov'
7
2
  require 'coveralls'
8
- Coveralls.wear!
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start do
9
+ add_filter 'spec'
10
+ minimum_coverage(76)
11
+ end
9
12
  require 'webmock'
10
13
  require 'webmock/rspec'
11
14
  require 'nexmos'
15
+ require 'json'
12
16
 
13
17
  RSpec.configure do |config|
14
- config.treat_symbols_as_metadata_keys_with_true_values = true
15
- config.run_all_when_everything_filtered = true
16
- config.filter_run :focus
17
-
18
- # Run specs in random order to surface order dependencies. If you find an
19
- # order dependency and want to debug it, you can fix the order by providing
20
- # the seed, which is printed after each run.
21
- # --seed 1234
22
- config.order = 'random'
23
18
  end
metadata CHANGED
@@ -1,97 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmos
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Simonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-20 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rash
14
+ name: hashie
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday_middleware
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ - - "<="
60
63
  - !ruby/object:Gem::Version
61
- version: 3.0.0
64
+ version: '5.0'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - '>='
69
+ - - ">="
67
70
  - !ruby/object:Gem::Version
68
- version: 3.0.0
71
+ version: '3.0'
72
+ - - "<="
73
+ - !ruby/object:Gem::Version
74
+ version: '5.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rspec
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - '>='
79
+ - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: '0'
81
+ version: '3.0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - '>='
86
+ - - ">="
81
87
  - !ruby/object:Gem::Version
82
- version: '0'
88
+ version: '3.0'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: webmock
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - '>='
93
+ - - ">="
88
94
  - !ruby/object:Gem::Version
89
95
  version: '0'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - '>='
100
+ - - ">="
95
101
  - !ruby/object:Gem::Version
96
102
  version: '0'
97
103
  description: Nexmo API client
@@ -101,16 +107,24 @@ executables: []
101
107
  extensions: []
102
108
  extra_rdoc_files: []
103
109
  files:
104
- - .gitignore
105
- - .rspec
106
- - .ruby-gemset
107
- - .ruby-version
108
- - .travis.yml
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".rubocop.yml"
113
+ - ".travis.yml"
114
+ - Appraisals
109
115
  - Gemfile
116
+ - Guardfile
110
117
  - LICENSE.txt
111
118
  - README.md
112
119
  - Rakefile
120
+ - defaults.reek
121
+ - gemfiles/activesupport_3.2.gemfile
122
+ - gemfiles/activesupport_4.0.gemfile
123
+ - gemfiles/activesupport_4.1.gemfile
124
+ - gemfiles/activesupport_4.2.gemfile
113
125
  - lib/api.yml
126
+ - lib/faraday_middleware/response/mashrashify.rb
127
+ - lib/hashie/mash/rash.rb
114
128
  - lib/nexmos.rb
115
129
  - lib/nexmos/account.rb
116
130
  - lib/nexmos/base.rb
@@ -135,17 +149,17 @@ require_paths:
135
149
  - lib
136
150
  required_ruby_version: !ruby/object:Gem::Requirement
137
151
  requirements:
138
- - - '>='
152
+ - - ">="
139
153
  - !ruby/object:Gem::Version
140
154
  version: '0'
141
155
  required_rubygems_version: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - '>='
157
+ - - ">="
144
158
  - !ruby/object:Gem::Version
145
159
  version: '0'
146
160
  requirements: []
147
161
  rubyforge_project:
148
- rubygems_version: 2.0.6
162
+ rubygems_version: 2.2.2
149
163
  signing_key:
150
164
  specification_version: 4
151
165
  summary: Nexmo API client
@@ -1 +0,0 @@
1
- nexmos