copycopter_client 1.0.0.beta10 → 1.0.0.beta11

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.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  require 'rake/rdoctask'
7
7
  require 'rake/gempackagetask'
8
8
  require 'cucumber/rake/task'
9
- require 'spec/rake/spectask'
9
+ require 'rspec/core/rake_task'
10
10
  require 'yard'
11
11
 
12
12
  desc 'Default: run the specs and features.'
@@ -15,9 +15,9 @@ task :default => :spec do
15
15
  end
16
16
 
17
17
  desc 'Test the copycopter_client plugin.'
18
- Spec::Rake::SpecTask.new do |t|
19
- t.spec_opts = ['--options', "spec/spec.opts"]
20
- t.spec_files = FileList['spec/copycopter_client/**/*_spec.rb']
18
+ RSpec::Core::RakeTask.new do |t|
19
+ t.rspec_opts = ['--color', "--format progress"]
20
+ t.pattern = 'spec/copycopter_client/**/*_spec.rb'
21
21
  end
22
22
 
23
23
  desc "Run cucumber features"
@@ -1,4 +1,4 @@
1
- @disable-bundler @puts @announce
1
+ @disable-bundler
2
2
  Feature: Using copycopter in a rails app
3
3
 
4
4
  Background:
@@ -132,32 +132,6 @@ Feature: Using copycopter in a rails app
132
132
  | key | draft content |
133
133
  | en.users.index.unknown-test | Unknown |
134
134
 
135
- Scenario: backwards compatibility
136
- Given the "abc123" project has the following blurbs:
137
- | key | draft content |
138
- | en.users.index.controller-test | Controller blurb |
139
- | en.users.index.view-test | View blurb |
140
- When I write to "app/controllers/users_controller.rb" with:
141
- """
142
- class UsersController < ActionController::Base
143
- def index
144
- @text = s('.controller-test')
145
- render
146
- end
147
- end
148
- """
149
- When I route the "users" resource
150
- And I write to "app/views/users/index.html.erb" with:
151
- """
152
- <%= @text %>
153
- <%= s(".view-test", "default") %>
154
- """
155
- When I start the application
156
- And I wait for changes to be synchronized
157
- And I visit /users/
158
- Then the response should contain "Controller blurb"
159
- And the response should contain "View blurb"
160
-
161
135
  Scenario: configure a bad api key
162
136
  When I configure the copycopter client with api key "bogus"
163
137
  And I start the application
@@ -19,7 +19,7 @@ When "I generate a rails application" do
19
19
  end
20
20
 
21
21
  When /^I configure the copycopter client with api key "([^"]*)"$/ do |api_key|
22
- create_file("config/initializers/copycopter.rb", <<-RUBY)
22
+ write_file("config/initializers/copycopter.rb", <<-RUBY)
23
23
  CopycopterClient.configure do |config|
24
24
  config.api_key = "#{api_key}"
25
25
  config.polling_delay = 1
@@ -131,7 +131,7 @@ When /^I route the "([^"]+)" resource$/ do |resource|
131
131
 
132
132
  routes = "#{draw}resources :#{resource}\nend"
133
133
 
134
- create_file("config/routes.rb", routes, false)
134
+ overwrite_file("config/routes.rb", routes)
135
135
  end
136
136
 
137
137
  When /^I run a short lived process that sets the key "([^"]*)" to "([^"]*)"$/ do |key, value|
@@ -6,3 +6,7 @@ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
6
6
  $LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
7
7
  require "copycopter_client/version"
8
8
 
9
+ Before do
10
+ @aruba_timeout_seconds = 15
11
+ end
12
+
@@ -28,6 +28,12 @@ class RailsServer
28
28
  end
29
29
 
30
30
  def self.run(port, silent)
31
+ if silent
32
+ require 'stringio'
33
+ $stdout = StringIO.new
34
+ $stderr = StringIO.new
35
+ end
36
+
31
37
  require 'config/environment'
32
38
  require 'thin'
33
39
 
@@ -1,12 +1,3 @@
1
- require 'copycopter_client/helper'
2
-
3
- if defined?(ActionController::Base)
4
- ActionController::Base.send :include, CopycopterClient::Helper
5
- end
6
- if defined?(ActionView::Base)
7
- ActionView::Base.send :include, CopycopterClient::Helper
8
- end
9
-
10
1
  module CopycopterClient
11
2
  # Responsible for Rails initialization
12
3
  module Rails
@@ -1,6 +1,6 @@
1
1
  module CopycopterClient
2
2
  # Client version
3
- VERSION = "1.0.0.beta10"
3
+ VERSION = "1.0.0.beta11"
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = "2.0"
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CopycopterClient::Configuration do
4
- Spec::Matchers.define :have_config_option do |option|
4
+ RSpec::Matchers.define :have_config_option do |option|
5
5
  match do |config|
6
6
  config.should respond_to(option)
7
7
 
@@ -204,6 +204,7 @@ share_examples_for "applied configuration" do
204
204
  CopycopterClient::Client.stubs(:new => client)
205
205
  CopycopterClient::Sync.stubs(:new => sync)
206
206
  subject.logger = logger
207
+ apply
207
208
  end
208
209
 
209
210
  it { should be_applied }
@@ -233,51 +234,51 @@ share_examples_for "applied configuration" do
233
234
  end
234
235
 
235
236
  describe CopycopterClient::Configuration, "applied when testing" do
236
- it_should_behave_like "applied configuration"
237
+ it_should_behave_like "applied configuration" do
238
+ it "doesn't start sync" do
239
+ sync.should have_received(:start).never
240
+ end
241
+ end
237
242
 
238
- before do
243
+ def apply
239
244
  subject.environment_name = 'test'
240
245
  subject.apply
241
246
  end
242
-
243
- it "doesn't start sync" do
244
- sync.should have_received(:start).never
245
- end
246
247
  end
247
248
 
248
249
  describe CopycopterClient::Configuration, "applied when not testing" do
249
- it_should_behave_like "applied configuration"
250
+ it_should_behave_like "applied configuration" do
251
+ it "starts sync" do
252
+ sync.should have_received(:start)
253
+ end
254
+ end
250
255
 
251
- before do
256
+ def apply
252
257
  subject.environment_name = 'development'
253
258
  subject.apply
254
259
  end
255
-
256
- it "starts sync" do
257
- sync.should have_received(:start)
258
- end
259
260
  end
260
261
 
261
262
  describe CopycopterClient::Configuration, "applied when developing with middleware" do
262
- it_should_behave_like "applied configuration"
263
+ it_should_behave_like "applied configuration" do
264
+ it "adds the sync middleware" do
265
+ middleware.should include(CopycopterClient::RequestSync)
266
+ end
267
+ end
263
268
 
264
269
  let(:middleware) { MiddlewareStack.new }
265
270
 
266
- before do
271
+ def apply
267
272
  subject.middleware = middleware
268
273
  subject.environment_name = 'development'
269
274
  subject.apply
270
275
  end
271
-
272
- it "adds the sync middleware" do
273
- middleware.should include(CopycopterClient::RequestSync)
274
- end
275
276
  end
276
277
 
277
278
  describe CopycopterClient::Configuration, "applied when developing without middleware" do
278
279
  it_should_behave_like "applied configuration"
279
280
 
280
- before do
281
+ def apply
281
282
  subject.middleware = nil
282
283
  subject.environment_name = 'development'
283
284
  subject.apply
@@ -289,7 +290,7 @@ describe CopycopterClient::Configuration, "applied with middleware when not deve
289
290
 
290
291
  let(:middleware) { MiddlewareStack.new }
291
292
 
292
- before do
293
+ def apply
293
294
  subject.middleware = middleware
294
295
  subject.environment_name = 'test'
295
296
  subject.apply
@@ -343,7 +343,7 @@ describe CopycopterClient::Sync do
343
343
  end
344
344
 
345
345
  describe "given locked mutex" do
346
- Spec::Matchers.define :finish_after_unlocking do |mutex|
346
+ RSpec::Matchers.define :finish_after_unlocking do |mutex|
347
347
  match do |thread|
348
348
  sleep(0.1)
349
349
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
- require 'spec'
3
- require 'spec/autorun'
2
+ require 'rspec'
4
3
  require 'bourne'
5
4
  require 'sham_rack'
6
5
  require 'webmock/rspec'
@@ -18,7 +17,7 @@ end
18
17
  WebMock.disable_net_connect!
19
18
  ShamRack.mount(FakeCopycopterApp.new, "copycopter.com", 443)
20
19
 
21
- Spec::Runner.configure do |config|
20
+ RSpec.configure do |config|
22
21
  config.include ClientSpecHelpers
23
22
  config.include WebMock::API
24
23
  config.mock_with :mocha
@@ -41,7 +41,7 @@ class FakeLogger
41
41
  attr_reader :entries
42
42
  end
43
43
 
44
- Spec::Matchers.define :have_entry do |severity, entry|
44
+ RSpec::Matchers.define :have_entry do |severity, entry|
45
45
  match do |logger|
46
46
  @logger = logger
47
47
  logger.has_entry?(severity, entry)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copycopter_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 180128174
4
+ hash: 180128175
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - beta10
11
- version: 1.0.0.beta10
10
+ - beta11
11
+ version: 1.0.0.beta11
12
12
  platform: ruby
13
13
  authors:
14
14
  - thoughtbot
@@ -65,7 +65,6 @@ files:
65
65
  - lib/copycopter_client/client.rb
66
66
  - lib/copycopter_client/configuration.rb
67
67
  - lib/copycopter_client/errors.rb
68
- - lib/copycopter_client/helper.rb
69
68
  - lib/copycopter_client/i18n_backend.rb
70
69
  - lib/copycopter_client/prefixed_logger.rb
71
70
  - lib/copycopter_client/rails.rb
@@ -77,12 +76,10 @@ files:
77
76
  - lib/tasks/copycopter_client_tasks.rake
78
77
  - spec/copycopter_client/client_spec.rb
79
78
  - spec/copycopter_client/configuration_spec.rb
80
- - spec/copycopter_client/helper_spec.rb
81
79
  - spec/copycopter_client/i18n_backend_spec.rb
82
80
  - spec/copycopter_client/prefixed_logger_spec.rb
83
81
  - spec/copycopter_client/request_sync_spec.rb
84
82
  - spec/copycopter_client/sync_spec.rb
85
- - spec/spec.opts
86
83
  - spec/spec_helper.rb
87
84
  - spec/support/client_spec_helpers.rb
88
85
  - spec/support/defines_constants.rb
@@ -1,40 +0,0 @@
1
- module CopycopterClient
2
- # Helper methods for Copycopter
3
- # @deprecated use +I81n#translate+ instead.
4
- module Helper
5
- # Returns copy for the given key in the current locale.
6
- # @param key [String] the key you want copy for
7
- # @param default [String, Hash] an optional default value, used if this key is missing
8
- # @option default [String] :default the default text
9
- def copy_for(key, default=nil)
10
- default = if default.respond_to?(:to_hash)
11
- default[:default]
12
- else
13
- default
14
- end
15
-
16
- key = scope_copycopter_key_by_partial(key)
17
- warn("WARNING: #s is deprecated; use t(#{key.inspect}, :default => #{default.inspect}) instead.")
18
- I18n.translate(key, { :default => default })
19
- end
20
- alias_method :s, :copy_for
21
-
22
- private
23
-
24
- def scope_copycopter_key_by_partial(key)
25
- if respond_to?(:scope_key_by_partial, true)
26
- scope_key_by_partial(key)
27
- elsif key.to_s[0].chr == "."
28
- if respond_to?(:template)
29
- "#{template.path_without_format_and_extension.gsub(%r{/_?}, '.')}#{key}"
30
- else
31
- "#{controller_name}.#{action_name}#{key}"
32
- end
33
- else
34
- key
35
- end
36
- end
37
- end
38
-
39
- extend Helper
40
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
- require 'copycopter_client/helper'
3
-
4
- describe CopycopterClient::Helper do
5
- subject { Object.new }
6
-
7
- before do
8
- class << subject
9
- include CopycopterClient::Helper
10
- def warn(*args); end # these are annoying in test output
11
- end
12
- I18n.stubs(:translate)
13
- end
14
-
15
- Spec::Matchers.define :have_translated do |key, default|
16
- match do |ignored_subject|
17
- extend Mocha::API
18
- I18n.should have_received(:translate).with(key, :default => default)
19
- end
20
- end
21
-
22
- it "translates keys on CopycopterClient.s" do
23
- CopycopterClient.s('test.key', 'default')
24
- should have_translated("test.key", 'default')
25
- end
26
-
27
- it "translates keys on CopycopterClient.copy_for" do
28
- CopycopterClient.copy_for('test.key', 'default')
29
- should have_translated("test.key", 'default')
30
- end
31
-
32
- it "uses existing scope by partial key when present" do
33
- subject.stubs(:scope_key_by_partial => "controller.action.key")
34
- class << subject
35
- private :scope_key_by_partial
36
- end
37
-
38
- subject.s(".key")
39
-
40
- subject.should have_received(:scope_key_by_partial).with(".key")
41
- should have_translated("controller.action.key", nil)
42
- end
43
-
44
- it "should prepend current partial when key starts with . and inside a view" do
45
- template = stub(:path_without_format_and_extension => "controller/action")
46
- subject.stubs(:template => template)
47
-
48
- subject.s(".key")
49
-
50
- should have_translated("controller.action.key", nil)
51
- end
52
-
53
- it "should prepend controller and action when key starts with . and inside a controller" do
54
- subject.stubs(:controller_name => "controller", :action_name => "action")
55
-
56
- subject.s(".key")
57
-
58
- should have_translated("controller.action.key", nil)
59
- end
60
-
61
- describe "default assignment" do
62
- before do
63
- subject.stubs(:scope_copycopter_key_by_partial => '.key')
64
- end
65
-
66
- it "should allow a hash with key default" do
67
- subject.s(@key, :default => "Default string")
68
- should have_translated('.key', "Default string")
69
- end
70
-
71
- it "should not allow a hash with stringed key default" do
72
- subject.s(@key, "default" => "Default string")
73
- should have_translated('.key', nil)
74
- end
75
-
76
- it "should not allow a hash with key other than default" do
77
- subject.s(@key, :junk => "Default string")
78
- should have_translated('.key', nil)
79
- end
80
-
81
- it "should allow a string" do
82
- subject.s(@key, "Default string")
83
- should have_translated('.key', "Default string")
84
- end
85
- end
86
- end
data/spec/spec.opts DELETED
@@ -1,2 +0,0 @@
1
- --format progress
2
- --color