localeapp 0.9.3 → 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.
@@ -2,37 +2,37 @@ Feature: Getting new translations
2
2
 
3
3
  Scenario: Running update
4
4
  In order to receive the translations that have been updated since the last check
5
- When I have a valid project on localeapp.com with api key "MYAPIKEY"
6
- And an initializer file
7
- And the timestamp is 2 months old
8
- And new translations for the api key "MYAPIKEY" since last fetch with time "60" seconds later
9
- And a directory named "config/locales"
5
+ Given I have a valid project on localeapp.com with api key "MYAPIKEY"
6
+ And an initializer file
7
+ And the timestamp is 2 months old
8
+ And new translations for the api key "MYAPIKEY" since last fetch with time "60" seconds later
9
+ And a directory named "config/locales"
10
10
  When I run `localeapp update`
11
11
  Then translations should be fetched since last fetch only
12
- And help should not be displayed
13
- And a file named "config/locales/en.yml" should exist
14
- # check the content here
15
- # and the localeapp.yml file
12
+ And help should not be displayed
13
+ And a file named "config/locales/en.yml" should exist
14
+ # check the content here
15
+ # and the localeapp.yml file
16
16
 
17
17
  Scenario: Running update with no initializer file, passing the key on the command line
18
18
  In order to receive the translations that have been updated since the last check
19
- When I have a valid project on localeapp.com with api key "MYAPIKEY"
20
- And the timestamp is 2 months old
21
- And new translations for the api key "MYAPIKEY" since last fetch with time "60" seconds later
22
- And a directory named "config/locales"
19
+ Given I have a valid project on localeapp.com with api key "MYAPIKEY"
20
+ And the timestamp is 2 months old
21
+ And new translations for the api key "MYAPIKEY" since last fetch with time "60" seconds later
22
+ And a directory named "config/locales"
23
23
  When I run `localeapp -k MYAPIKEY update`
24
24
  Then translations should be fetched since last fetch only
25
- And help should not be displayed
26
- And a file named "config/locales/en.yml" should exist
25
+ And help should not be displayed
26
+ And a file named "config/locales/en.yml" should exist
27
27
 
28
28
  Scenario: Running update with a too old timestamp
29
29
  In order to receive the translations that have been updated since the last check
30
- When I have a valid project on localeapp.com with api key "MYAPIKEY"
31
- And an initializer file
32
- And the timestamp is 8 months old
30
+ Given I have a valid project on localeapp.com with api key "MYAPIKEY"
31
+ And an initializer file
32
+ And the timestamp is 8 months old
33
33
  When I run `localeapp update`
34
34
  Then the output should contain:
35
35
  """
36
36
  Timestamp is missing or too old
37
37
  """
38
- And help should not be displayed
38
+ And help should not be displayed
@@ -1,3 +1,3 @@
1
1
  module Localeapp
2
- VERSION = '0.9.3'
2
+ VERSION = '1.0.0'
3
3
  end
data/localeapp.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency('i18n')
23
+ s.add_dependency('i18n', '< 0.7')
24
24
  s.add_dependency('json')
25
25
  s.add_dependency('rest-client')
26
26
  s.add_dependency('rack')
@@ -28,10 +28,10 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency('gli')
29
29
 
30
30
  s.add_development_dependency('rake')
31
- s.add_development_dependency('rspec', '~> 2.14.1')
31
+ s.add_development_dependency('rspec', '~> 3.3')
32
32
  s.add_development_dependency('yard')
33
33
  s.add_development_dependency('RedCloth')
34
- s.add_development_dependency('aruba')
35
- s.add_development_dependency('cucumber', '~> 1.3')
34
+ s.add_development_dependency('aruba', '~> 0.8')
35
+ s.add_development_dependency('cucumber', '~> 2.0')
36
36
  s.add_development_dependency('fakeweb')
37
37
  end
@@ -8,8 +8,8 @@ describe Localeapp::ApiCall, "#api_call(endpoint, options = {})" do
8
8
  it "creates an ApiCaller object and tells it to make the call" do
9
9
  api_call_test = ApiCallTest.new
10
10
  api_call = double('api_call')
11
- api_call.should_receive(:call).with(api_call_test)
12
- Localeapp::ApiCaller.should_receive(:new).with(:endpoint, { :foo => :bar }).and_return(api_call)
11
+ expect(api_call).to receive(:call).with(api_call_test)
12
+ expect(Localeapp::ApiCaller).to receive(:new).with(:endpoint, { :foo => :bar }).and_return(api_call)
13
13
  api_call_test.api_call(:endpoint, { :foo => :bar })
14
14
  end
15
15
  end
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe Localeapp::ApiCaller, ".new(endpoint, options = {})" do
4
4
  it "stores the endpoint and options" do
5
5
  api_caller = Localeapp::ApiCaller.new(:endpoint, :foo => :bar)
6
- api_caller.endpoint.should == :endpoint
7
- api_caller.options.should == { :foo => :bar }
6
+ expect(api_caller.endpoint).to eq(:endpoint)
7
+ expect(api_caller.options).to eq({ :foo => :bar })
8
8
  end
9
9
  end
10
10
 
@@ -14,39 +14,41 @@ describe Localeapp::ApiCaller, "#call(object)" do
14
14
  @api_caller = Localeapp::ApiCaller.new(:test)
15
15
  end
16
16
  @url = 'https://example.com/test'
17
- @api_caller.stub(:test_endpoint).and_return([:get, @url])
18
- @api_caller.stub(:sleep_if_retrying)
17
+ allow(@api_caller).to receive(:test_endpoint).and_return([:get, @url])
18
+ allow(@api_caller).to receive(:sleep_if_retrying)
19
19
  end
20
20
 
21
21
  it "gets the method and url for the endpoint" do
22
- @api_caller.should_receive(:test_endpoint).with({}).and_return([:get, @url])
23
- RestClient::Request.stub(:execute).and_return(double('response', :code => 200))
22
+ expect(@api_caller).to receive(:test_endpoint).with({}).and_return([:get, @url])
23
+ allow(RestClient::Request).to receive(:execute).and_return(double('response', :code => 200))
24
24
  @api_caller.call(self)
25
25
  end
26
26
 
27
27
  it "passes through any url options" do
28
- @api_caller.should_receive(:test_endpoint).with({:foo => :bar}).and_return([:get, @url])
28
+ expect(@api_caller).to receive(:test_endpoint).with({:foo => :bar}).and_return([:get, @url])
29
29
  @api_caller.options[:url_options] = { :foo => :bar }
30
- RestClient::Request.stub(:execute).and_return(double('response', :code => 200))
30
+ allow(RestClient::Request).to receive(:execute).and_return(double('response', :code => 200))
31
31
  @api_caller.call(self)
32
32
  end
33
33
 
34
34
  it "adds the gem version to the headers" do
35
- RestClient::Request.should_receive(:execute).with(hash_including(:headers => { :x_localeapp_gem_version => Localeapp::VERSION })).and_return(double('response', :code => 200))
35
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:headers => { :x_localeapp_gem_version => Localeapp::VERSION })).and_return(double('response', :code => 200))
36
36
  @api_caller.call(self)
37
37
  end
38
38
 
39
39
  if "".respond_to?(:force_encoding)
40
40
  def success_check(response)
41
- response.encoding.should == Encoding.find('UTF-8')
41
+ expect(response.encoding).to eq(Encoding.find('UTF-8'))
42
42
  end
43
43
 
44
44
  it "sets the response encoding based on the response charset" do
45
45
  response = "string"
46
- response.stub(:code).and_return(200)
46
+ allow(response).to receive(:code).and_return(200)
47
47
  response.force_encoding('US-ASCII')
48
- response.stub_chain(:net_http_res, :type_params).and_return('charset' => 'utf-8')
49
- RestClient::Request.stub(:execute).and_return(response)
48
+ allow(response).to receive_message_chain(:net_http_res, :type_params) do
49
+ { "charset" => "utf-8" }
50
+ end
51
+ allow(RestClient::Request).to receive(:execute).and_return(response)
50
52
  @api_caller.options[:success] = :success_check
51
53
  @api_caller.call(self)
52
54
  end
@@ -54,17 +56,17 @@ describe Localeapp::ApiCaller, "#call(object)" do
54
56
 
55
57
  context "Proxy" do
56
58
  before do
57
- RestClient::Request.stub(:execute).and_return(double('response', :code => 200))
59
+ allow(RestClient::Request).to receive(:execute).and_return(double('response', :code => 200))
58
60
  end
59
61
 
60
62
  it "sets the proxy if configured" do
61
63
  Localeapp.configuration.proxy = "http://localhost:8888"
62
- RestClient.should_receive(:proxy=).with('http://localhost:8888')
64
+ expect(RestClient).to receive(:proxy=).with('http://localhost:8888')
63
65
  @api_caller.call(self)
64
66
  end
65
67
 
66
68
  it "doesn't set the proxy if it's not configured" do
67
- RestClient.should_not_receive(:proxy=)
69
+ expect(RestClient).not_to receive(:proxy=)
68
70
  @api_caller.call(self)
69
71
  end
70
72
  end
@@ -72,12 +74,12 @@ describe Localeapp::ApiCaller, "#call(object)" do
72
74
  context "SSL Certificate Validation" do
73
75
  it "set the HTTPClient verify_ssl to VERIFY_PEER if ssl_verify is set to true" do
74
76
  Localeapp.configuration.ssl_verify = true
75
- RestClient::Request.should_receive(:execute).with(hash_including(:verify_ssl => OpenSSL::SSL::VERIFY_PEER)).and_return(double('response', :code => 200))
77
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:verify_ssl => OpenSSL::SSL::VERIFY_PEER)).and_return(double('response', :code => 200))
76
78
  @api_caller.call(self)
77
79
  end
78
80
 
79
81
  it "set the HTTPClient verify_ssl to false if ssl_verify is set to false" do
80
- RestClient::Request.should_receive(:execute).with(hash_including(:verify_ssl => false)).and_return(double('response', :code => 200))
82
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:verify_ssl => false)).and_return(double('response', :code => 200))
81
83
  @api_caller.call(self)
82
84
  end
83
85
  end
@@ -85,13 +87,13 @@ describe Localeapp::ApiCaller, "#call(object)" do
85
87
  context "SSL Certificate Validation" do
86
88
  it "set the HTTPClient ca_file to the value given to ssl_ca_file if it's not nil" do
87
89
  Localeapp.configuration.ssl_ca_file = '/tmp/test'
88
- RestClient::Request.should_receive(:execute).with(hash_including(:ca_file => '/tmp/test')).and_return(double('response', :code => 200))
90
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:ca_file => '/tmp/test')).and_return(double('response', :code => 200))
89
91
  @api_caller.call(self)
90
92
  end
91
93
 
92
94
  it "doesn't set the HTTPClient ca_file if ssl_ca_file is nil" do
93
95
  Localeapp.configuration.ssl_ca_file = nil
94
- RestClient::Request.should_receive(:execute).with(hash_not_including(:ca_file => nil)).and_return(double('response', :code => 200))
96
+ expect(RestClient::Request).to receive(:execute).with(hash_not_including(:ca_file => nil)).and_return(double('response', :code => 200))
95
97
  @api_caller.call(self)
96
98
  end
97
99
  end
@@ -99,13 +101,13 @@ describe Localeapp::ApiCaller, "#call(object)" do
99
101
  context "SSL version" do
100
102
  it "sets the HTTPClient ssl_version to the value given to ssl_version" do
101
103
  Localeapp.configuration.ssl_version = 'SSLv3'
102
- RestClient::Request.should_receive(:execute).with(hash_including(:ssl_version => 'SSLv3')).and_return(double('response', :code => 200))
104
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:ssl_version => 'SSLv3')).and_return(double('response', :code => 200))
103
105
  @api_caller.call(self)
104
106
  end
105
107
 
106
108
  it "doesn't set the HTTPClient ssl_version if it's nil" do
107
109
  Localeapp.configuration.ssl_version = nil
108
- RestClient::Request.should_receive(:execute).with(hash_including(:ssl_version => nil)).and_return(double('response', :code => 200))
110
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:ssl_version => nil)).and_return(double('response', :code => 200))
109
111
  @api_caller.call(self)
110
112
  end
111
113
  end
@@ -113,19 +115,19 @@ describe Localeapp::ApiCaller, "#call(object)" do
113
115
  context "Timeout" do
114
116
  it "sets the timeout to the configured timeout" do
115
117
  Localeapp.configuration.timeout = 120
116
- RestClient::Request.should_receive(:execute).with(hash_including(:timeout => 120)).and_return(double('response', :code => 200))
118
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:timeout => 120)).and_return(double('response', :code => 200))
117
119
  @api_caller.call(self)
118
120
  end
119
121
  end
120
122
 
121
123
  context "a GET request" do
122
124
  it "makes the call to the api" do
123
- RestClient::Request.should_receive(:execute).with(hash_including(:url => @url, :method => :get)).and_return(double('response', :code => 200))
125
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:url => @url, :method => :get)).and_return(double('response', :code => 200))
124
126
  @api_caller.call(self)
125
127
  end
126
128
 
127
129
  it "adds any :headers to the api call" do
128
- RestClient::Request.should_receive(:execute).with(hash_including(:headers => { :x_localeapp_gem_version => Localeapp::VERSION, :foo => :bar })).and_return(double('response', :code => 200))
130
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:headers => { :x_localeapp_gem_version => Localeapp::VERSION, :foo => :bar })).and_return(double('response', :code => 200))
129
131
  @api_caller.options[:headers] = { :foo => :bar }
130
132
  @api_caller.call(self)
131
133
  end
@@ -134,17 +136,17 @@ describe Localeapp::ApiCaller, "#call(object)" do
134
136
 
135
137
  context " a POST request" do
136
138
  before do
137
- @api_caller.stub(:test_endpoint).and_return([:post, @url])
139
+ allow(@api_caller).to receive(:test_endpoint).and_return([:post, @url])
138
140
  @api_caller.options[:payload] = "test data"
139
141
  end
140
142
 
141
143
  it "makes the call to the api using :payload as the payload" do
142
- RestClient::Request.should_receive(:execute).with(hash_including(:url => @url, :payload => "test data", :method => :post)).and_return(double('response', :code => 200))
144
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:url => @url, :payload => "test data", :method => :post)).and_return(double('response', :code => 200))
143
145
  @api_caller.call(self)
144
146
  end
145
147
 
146
148
  it "adds any :headers to the api call" do
147
- RestClient::Request.should_receive(:execute).with(hash_including(:headers => { :x_localeapp_gem_version => Localeapp::VERSION, :foo => :bar })).and_return(double('response', :code => 200))
149
+ expect(RestClient::Request).to receive(:execute).with(hash_including(:headers => { :x_localeapp_gem_version => Localeapp::VERSION, :foo => :bar })).and_return(double('response', :code => 200))
148
150
  @api_caller.options[:headers] = { :foo => :bar }
149
151
  @api_caller.call(self)
150
152
  end
@@ -158,24 +160,24 @@ describe Localeapp::ApiCaller, "#call(object)" do
158
160
 
159
161
  it "calls the :success option callback if present" do
160
162
  @api_caller.options[:success] = :success
161
- @object.should_receive(:success).with(kind_of(RestClient::Response))
163
+ expect(@object).to receive(:success).with(kind_of(RestClient::Response))
162
164
  @api_caller.call(@object)
163
165
  end
164
166
 
165
167
  it "does nothing if :success option callback not present" do
166
- @object.should_not_receive(:success)
168
+ expect(@object).not_to receive(:success)
167
169
  @api_caller.call(@object)
168
170
  end
169
171
 
170
172
  it "should not try the call again" do
171
173
  @api_caller.max_connection_attempts = 2
172
174
  @api_caller.call(@object)
173
- @api_caller.connection_attempts.should == 1
175
+ expect(@api_caller.connection_attempts).to eq(1)
174
176
  end
175
177
 
176
178
  it "doesn't call the failure handler" do
177
179
  @api_caller.options[:failure] = :failure
178
- @object.should_not_receive(:failure)
180
+ expect(@object).not_to receive(:failure)
179
181
  @api_caller.call(@object)
180
182
  end
181
183
  end
@@ -189,22 +191,22 @@ describe Localeapp::ApiCaller, "#call(object)" do
189
191
  it "retries call, up to value of :max_connection_attempts option" do
190
192
  @api_caller.max_connection_attempts = 2
191
193
  @api_caller.call(@object)
192
- @api_caller.connection_attempts.should == 2
194
+ expect(@api_caller.connection_attempts).to eq(2)
193
195
  end
194
196
 
195
197
  it "backs off each retry attempt" do
196
- @api_caller.should_receive(:sleep_if_retrying)
198
+ expect(@api_caller).to receive(:sleep_if_retrying)
197
199
  @api_caller.call(@object)
198
200
  end
199
201
 
200
202
  it "calls the :failure option callback if present" do
201
203
  @api_caller.options[:failure] = :fail
202
- @object.should_receive(:fail).with(kind_of(RestClient::Response))
204
+ expect(@object).to receive(:fail).with(kind_of(RestClient::Response))
203
205
  @api_caller.call(@object)
204
206
  end
205
207
 
206
208
  it "does nothing if :failure option callback not present" do
207
- @object.should_not_receive(:fail)
209
+ expect(@object).not_to receive(:fail)
208
210
  @api_caller.call(@object)
209
211
  end
210
212
 
@@ -232,29 +234,29 @@ describe Localeapp::ApiCaller, "#call(object)" do
232
234
  it "fails when response is #{code} #{reason}" do
233
235
  FakeWeb.register_uri(:get, @url, :body => '', :status => [code.to_s, reason])
234
236
  @api_caller.options[:failure] = :fail
235
- @object.should_receive(:fail)
237
+ expect(@object).to receive(:fail)
236
238
  @api_caller.call(@object)
237
239
  end
238
240
  end
239
241
 
240
242
  it "handles ECONNREFUSED" do
241
- RestClient::Request.stub(:execute).and_raise(Errno::ECONNREFUSED)
243
+ allow(RestClient::Request).to receive(:execute).and_raise(Errno::ECONNREFUSED)
242
244
  @api_caller.options[:failure] = :fail
243
- @object.should_receive(:fail)
245
+ expect(@object).to receive(:fail)
244
246
  @api_caller.call(@object)
245
247
  end
246
248
 
247
249
  it "handles RestClient::ServerBrokeConnection" do
248
- RestClient::Request.stub(:execute).and_raise(RestClient::ServerBrokeConnection)
250
+ allow(RestClient::Request).to receive(:execute).and_raise(RestClient::ServerBrokeConnection)
249
251
  @api_caller.options[:failure] = :fail
250
- @object.should_receive(:fail)
252
+ expect(@object).to receive(:fail)
251
253
  @api_caller.call(@object)
252
254
  end
253
255
 
254
256
  it "handles SocketError" do
255
- RestClient::Request.stub(:execute).and_raise(SocketError)
257
+ allow(RestClient::Request).to receive(:execute).and_raise(SocketError)
256
258
  @api_caller.options[:failure] = :fail
257
- @object.should_receive(:fail)
259
+ expect(@object).to receive(:fail)
258
260
  @api_caller.call(@object)
259
261
  end
260
262
  end
@@ -13,34 +13,34 @@ describe Localeapp::CLI::Add, "#execute(key, *translations)" do
13
13
 
14
14
  it "adds the translations to missing_translations" do
15
15
  with_configuration do
16
- Localeapp.sender.stub(:post_missing_translations)
16
+ allow(Localeapp.sender).to receive(:post_missing_translations)
17
17
  do_action
18
18
  end
19
19
  en_missing = Localeapp.missing_translations['en']
20
- en_missing.size.should == 1
21
- en_missing['test.key'].locale.should == 'en'
22
- en_missing['test.key'].description.should == 'test en'
20
+ expect(en_missing.size).to eq(1)
21
+ expect(en_missing['test.key'].locale).to eq('en')
22
+ expect(en_missing['test.key'].description).to eq('test en')
23
23
  es_missing = Localeapp.missing_translations['es']
24
- es_missing.size.should == 1
25
- es_missing['test.key'].locale.should == 'es'
26
- es_missing['test.key'].description.should == 'test es'
24
+ expect(es_missing.size).to eq(1)
25
+ expect(es_missing['test.key'].locale).to eq('es')
26
+ expect(es_missing['test.key'].description).to eq('test es')
27
27
  end
28
28
 
29
29
  it "ignores badly formed arguments" do
30
30
  with_configuration do
31
- Localeapp.sender.stub(:post_missing_translations)
31
+ allow(Localeapp.sender).to receive(:post_missing_translations)
32
32
  do_action('test.key', ["en:this is fine", "esbad"])
33
33
  end
34
- Localeapp.missing_translations['en'].size.should == 1
35
- Localeapp.missing_translations['es'].size.should == 0
36
- Localeapp.missing_translations['esbad'].size.should == 0
37
- @output.string.should include("Ignoring bad translation esbad")
38
- @output.string.should include("format should be <locale>:<translation content>")
34
+ expect(Localeapp.missing_translations['en'].size).to eq(1)
35
+ expect(Localeapp.missing_translations['es'].size).to eq(0)
36
+ expect(Localeapp.missing_translations['esbad'].size).to eq(0)
37
+ expect(@output.string).to include("Ignoring bad translation esbad")
38
+ expect(@output.string).to include("format should be <locale>:<translation content>")
39
39
  end
40
40
 
41
41
  it "tells the sender to send the missing translations" do
42
42
  with_configuration do
43
- Localeapp.sender.should_receive(:post_missing_translations)
43
+ expect(Localeapp.sender).to receive(:post_missing_translations)
44
44
  do_action
45
45
  end
46
46
  end
@@ -6,21 +6,21 @@ describe Localeapp::CLI::Daemon, "#execute(options)" do
6
6
  let(:interval) { 5 }
7
7
 
8
8
  before do
9
- command.stub(:update_loop)
9
+ allow(command).to receive(:update_loop)
10
10
  end
11
11
 
12
12
  it "exits when interval isn't greater than 0" do
13
- command.should_receive(:exit_now!)
13
+ expect(command).to receive(:exit_now!)
14
14
  command.execute(:interval => -1)
15
15
  end
16
16
 
17
17
  it "runs the loop directly when not running in background" do
18
- command.should_receive(:update_loop).with(interval)
18
+ expect(command).to receive(:update_loop).with(interval)
19
19
  command.execute(:interval => interval)
20
20
  end
21
21
 
22
22
  it "runs the loop in the background when background options set" do
23
- command.should_receive(:run_in_background).with(interval)
23
+ expect(command).to receive(:run_in_background).with(interval)
24
24
  command.execute(:interval => interval, :background => true)
25
25
  end
26
26
  end
@@ -31,8 +31,8 @@ describe Localeapp::CLI::Daemon, "#do_update" do
31
31
 
32
32
  it "creates and executes and Updater" do
33
33
  stub = double(:updater)
34
- stub.should_receive(:execute)
35
- Localeapp::CLI::Update.should_receive(:new).and_return(stub)
34
+ expect(stub).to receive(:execute)
35
+ expect(Localeapp::CLI::Update).to receive(:new).and_return(stub)
36
36
  command.do_update
37
37
  end
38
38
  end