zonebie 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -9
- data/Changelog.md +5 -0
- data/Gemfile +5 -0
- data/README.md +12 -12
- data/lib/zonebie.rb +17 -20
- data/lib/zonebie/backends.rb +2 -2
- data/lib/zonebie/rspec.rb +1 -1
- data/lib/zonebie/version.rb +2 -1
- data/spec/integrations/activesupport_spec.rb +0 -1
- data/spec/lib/zonebie/backends/active_support_spec.rb +8 -9
- data/spec/lib/zonebie/backends/tzinfo_spec.rb +8 -9
- data/spec/lib/zonebie_spec.rb +3 -6
- data/zonebie.gemspec +16 -12
- metadata +34 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ac61eaa2de78b672edd604210408215be46a490
|
4
|
+
data.tar.gz: ff3af6b4e27c25a521b466a2d3aa6c454ce1aa87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0e8dce6f7e8c5f7a3b1f804010d64c8d41d460ba05140c54211fe6e796b533da28a7bcc6c8da92b7fb010db8a6ad9b5c251b379f399678e8f1c4248d91c96b7
|
7
|
+
data.tar.gz: 9e444956b30c04f538713c8c14f732b6fab1fb63ddfd6eff68dee24a21fe987d5b04e9cac7437aae334e00558e6c7cbf8aa4638874542cf46b18fbefb3041a53
|
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,16 +11,16 @@ debug (more information below).
|
|
11
11
|
|
12
12
|
## Requirements
|
13
13
|
|
14
|
-
* MRI (
|
15
|
-
* JRuby (1.
|
16
|
-
* Rubinius (
|
14
|
+
* MRI (2.0.x, 2.1.x, 2.2.x, 2.3.x)
|
15
|
+
* JRuby (1.7)
|
16
|
+
* Rubinius (2.0)
|
17
17
|
|
18
18
|
***
|
19
19
|
|
20
20
|
And **either** of these gems which adds timezone support to Ruby:
|
21
21
|
|
22
|
-
* `activesupport` >=
|
23
|
-
* `tzinfo` >=
|
22
|
+
* `activesupport` >= 3.0 (Rails 3.0, 3.1, 3.2, 4.0, 4.1, 4.2)
|
23
|
+
* `tzinfo` >= 1.2
|
24
24
|
|
25
25
|
## Installation
|
26
26
|
|
@@ -30,13 +30,13 @@ If using Bundler (recommended), add to Gemfile:
|
|
30
30
|
gem 'zonebie'
|
31
31
|
````
|
32
32
|
|
33
|
-
## Usage with Rails &
|
33
|
+
## Usage with Rails & Active Support
|
34
34
|
|
35
|
-
|
35
|
+
Active Support allows setting a global timezone that will be used for many date
|
36
36
|
and time calculations throughout the application.
|
37
37
|
|
38
38
|
Zonebie can set this to a random timezone at the beginning of test runs.
|
39
|
-
Specifically for
|
39
|
+
Specifically for Active Support, it sets `Time.zone`.
|
40
40
|
|
41
41
|
### Test::Unit & Minitest
|
42
42
|
|
@@ -51,7 +51,7 @@ Zonebie.set_random_timezone
|
|
51
51
|
Add to `spec/spec_helper.rb`:
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
|
54
|
+
require "zonebie/rspec"
|
55
55
|
```
|
56
56
|
|
57
57
|
### Cucumber
|
@@ -64,10 +64,10 @@ Zonebie.set_random_timezone
|
|
64
64
|
|
65
65
|
## Usage with TZInfo
|
66
66
|
|
67
|
-
Zonebie can use the `tzinfo` gem, allowing it to work outside of
|
67
|
+
Zonebie can use the `tzinfo` gem, allowing it to work outside of Active Support
|
68
68
|
(Rails).
|
69
69
|
|
70
|
-
However, `Zonebie.set_random_timezone` does not work outside of
|
70
|
+
However, `Zonebie.set_random_timezone` does not work outside of Active Support
|
71
71
|
because there is not a concept of a global timezone setting. If you simply need
|
72
72
|
a random timezone for some other part of your tests, Zonebie can help.
|
73
73
|
|
@@ -75,7 +75,7 @@ a random timezone for some other part of your tests, Zonebie can help.
|
|
75
75
|
zone = TZInfo::Timezone.get(Zonebie.random_timezone)
|
76
76
|
puts zone.now
|
77
77
|
|
78
|
-
# Also works in Rails/
|
78
|
+
# Also works in Rails/Active Support
|
79
79
|
zone = ActiveSupport::TimeZone[Zonebie.random_timezone]
|
80
80
|
puts zone.now
|
81
81
|
```
|
data/lib/zonebie.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path('zonebie/version', File.dirname(__FILE__))
|
2
2
|
|
3
3
|
module Zonebie
|
4
4
|
class << self
|
@@ -6,26 +6,28 @@ module Zonebie
|
|
6
6
|
|
7
7
|
def backend
|
8
8
|
unless @backend
|
9
|
-
@backend =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
@backend = \
|
10
|
+
if @backends[:activesupport].usable?
|
11
|
+
@backends[:activesupport]
|
12
|
+
else
|
13
|
+
@backends.values.detect(&:usable?)
|
14
|
+
end
|
14
15
|
end
|
15
16
|
|
16
17
|
@backend
|
17
18
|
end
|
18
19
|
|
19
20
|
def backend=(backend)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
@backend = \
|
22
|
+
case backend
|
23
|
+
when Symbol
|
24
|
+
@backends[backend]
|
25
|
+
else
|
26
|
+
backend
|
27
|
+
end
|
26
28
|
|
27
29
|
if !backend.nil? && @backend.nil?
|
28
|
-
|
30
|
+
fail ArgumentError, "Unsupported backend: #{backend}"
|
29
31
|
end
|
30
32
|
|
31
33
|
@backend
|
@@ -37,17 +39,12 @@ module Zonebie
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def set_random_timezone
|
40
|
-
zone = ENV['ZONEBIE_TZ'] ||
|
42
|
+
zone = ENV['ZONEBIE_TZ'] || backend.zones.sample
|
41
43
|
|
42
44
|
$stdout.puts("[Zonebie] Setting timezone: ZONEBIE_TZ=\"#{zone}\"") unless quiet
|
43
45
|
backend.zone = zone
|
44
46
|
end
|
45
|
-
|
46
|
-
def random_timezone
|
47
|
-
zones = backend.zones
|
48
|
-
zones[rand(zones.length)]
|
49
|
-
end
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
|
-
require File.expand_path(
|
50
|
+
require File.expand_path('zonebie/backends', File.dirname(__FILE__))
|
data/lib/zonebie/backends.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require File.expand_path(
|
2
|
-
require File.expand_path(
|
1
|
+
require File.expand_path('backends/active_support', File.dirname(__FILE__))
|
2
|
+
require File.expand_path('backends/tzinfo', File.dirname(__FILE__))
|
data/lib/zonebie/rspec.rb
CHANGED
data/lib/zonebie/version.rb
CHANGED
@@ -3,19 +3,18 @@ require "spec_helper"
|
|
3
3
|
describe Zonebie::Backends::ActiveSupport do
|
4
4
|
describe "#name" do
|
5
5
|
it "is :activesupport" do
|
6
|
-
described_class.name.
|
6
|
+
expect(described_class.name).to eq :activesupport
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#zones" do
|
11
11
|
it "returns a list of zones provided by ActiveSupport" do
|
12
|
-
::ActiveSupport::TimeZone.stubs(:all).
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
])
|
12
|
+
::ActiveSupport::TimeZone.stubs(:all).returns([
|
13
|
+
stub(:name => "Eastern Time (US & Canada)"),
|
14
|
+
stub(:name => "Central Time (US & Canada)")
|
15
|
+
])
|
17
16
|
|
18
|
-
described_class.zones.
|
17
|
+
expect(described_class.zones).to eq ["Eastern Time (US & Canada)", "Central Time (US & Canada)"]
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
@@ -29,14 +28,14 @@ describe Zonebie::Backends::ActiveSupport do
|
|
29
28
|
|
30
29
|
describe "usable?" do
|
31
30
|
it "returns true if ActiveSupport is available" do
|
32
|
-
described_class.
|
31
|
+
expect(described_class).to be_usable
|
33
32
|
end
|
34
33
|
|
35
34
|
it "returns false if ActiveSupport is unavailable" do
|
36
35
|
old_active_support = ActiveSupport
|
37
36
|
Object.send(:remove_const, :ActiveSupport)
|
38
37
|
begin
|
39
|
-
described_class.
|
38
|
+
expect(described_class).not_to be_usable
|
40
39
|
ensure
|
41
40
|
ActiveSupport = old_active_support
|
42
41
|
end
|
@@ -3,19 +3,18 @@ require "spec_helper"
|
|
3
3
|
describe Zonebie::Backends::TZInfo do
|
4
4
|
describe "#name" do
|
5
5
|
it "is :tzinfo" do
|
6
|
-
described_class.name.
|
6
|
+
expect(described_class.name).to eq :tzinfo
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#zones" do
|
11
11
|
it "returns a list of zones provided by TZInfo" do
|
12
|
-
::TZInfo::Timezone.stubs(:all).
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
])
|
12
|
+
::TZInfo::Timezone.stubs(:all).returns([
|
13
|
+
stub(:identifier => "America/Chicago"),
|
14
|
+
stub(:identifier => "America/New York")
|
15
|
+
])
|
17
16
|
|
18
|
-
described_class.zones.
|
17
|
+
expect(described_class.zones).to eq ["America/Chicago", "America/New York"]
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
@@ -28,14 +27,14 @@ describe Zonebie::Backends::TZInfo do
|
|
28
27
|
|
29
28
|
describe "usable?" do
|
30
29
|
it "returns true if TZInfo is available" do
|
31
|
-
described_class.
|
30
|
+
expect(described_class).to be_usable
|
32
31
|
end
|
33
32
|
|
34
33
|
it "returns false if TZInfo is unavailable" do
|
35
34
|
old_tz_info = TZInfo
|
36
35
|
Object.send(:remove_const, :TZInfo)
|
37
36
|
begin
|
38
|
-
described_class.
|
37
|
+
expect(described_class).not_to be_usable
|
39
38
|
ensure
|
40
39
|
TZInfo = old_tz_info
|
41
40
|
end
|
data/spec/lib/zonebie_spec.rb
CHANGED
@@ -3,18 +3,18 @@ require "spec_helper"
|
|
3
3
|
describe Zonebie do
|
4
4
|
describe "#backend" do
|
5
5
|
it "defaults to the activesupport backend in the presence of activesupport" do
|
6
|
-
Zonebie.backend.name.
|
6
|
+
expect(Zonebie.backend.name).to eq :activesupport
|
7
7
|
end
|
8
8
|
|
9
9
|
it "allows setting the backend to tzinfo" do
|
10
10
|
Zonebie.backend = :tzinfo
|
11
|
-
Zonebie.backend.name.
|
11
|
+
expect(Zonebie.backend.name).to eq :tzinfo
|
12
12
|
end
|
13
13
|
|
14
14
|
it "defaults to tzinfo in the absense of activesupport" do
|
15
15
|
Zonebie::Backends::ActiveSupport.stubs(:usable?).returns(false)
|
16
16
|
|
17
|
-
Zonebie.backend.name.
|
17
|
+
expect(Zonebie.backend.name).to eq :tzinfo
|
18
18
|
end
|
19
19
|
|
20
20
|
it "does not allow setting the backend to an unsupported value" do
|
@@ -90,8 +90,5 @@ describe Zonebie do
|
|
90
90
|
Zonebie.backend = :my_awesome_backend
|
91
91
|
end
|
92
92
|
|
93
|
-
it "returns a random timezone" do
|
94
|
-
Zonebie.random_timezone.should == "Eastern Time (US & Canada)"
|
95
|
-
end
|
96
93
|
end
|
97
94
|
end
|
data/zonebie.gemspec
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'zonebie/version'
|
3
5
|
|
4
6
|
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "zonebie"
|
8
|
+
gem.version = Zonebie::VERSION
|
5
9
|
gem.authors = ['Andy Lindeman', 'Steven Harman', 'Patrick Van Stee']
|
6
10
|
gem.email = ['andy@andylindeman.com', 'steveharman@gmail.com', 'patrickvanstee@gmail.com']
|
7
11
|
gem.description = %q{Runs your tests in a random timezone}
|
@@ -9,18 +13,18 @@ Gem::Specification.new do |gem|
|
|
9
13
|
gem.homepage = "https://github.com/alindeman/zonebie"
|
10
14
|
gem.license = 'MIT'
|
11
15
|
|
12
|
-
gem.
|
13
|
-
gem.
|
14
|
-
gem.
|
15
|
-
gem.name = "zonebie"
|
16
|
+
gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|gem|features)/}) }
|
17
|
+
gem.bindir = "exe"
|
18
|
+
gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
19
|
gem.require_paths = ["lib"]
|
17
|
-
|
20
|
+
|
21
|
+
gem.required_ruby_version = '>= 2.0.0'
|
18
22
|
|
19
23
|
gem.add_development_dependency "rake"
|
20
|
-
gem.add_development_dependency "rspec", "~>
|
21
|
-
gem.add_development_dependency "mocha", "~>0.14.0"
|
24
|
+
gem.add_development_dependency "rspec", "~> 3.4"
|
25
|
+
gem.add_development_dependency "mocha", "~> 0.14.0"
|
22
26
|
|
23
|
-
gem.add_development_dependency "activesupport", "
|
24
|
-
gem.add_development_dependency "tzinfo", "~>1.
|
25
|
-
gem.add_development_dependency "tzinfo-data", ">= 1.
|
27
|
+
gem.add_development_dependency "activesupport", "~> 3.0"
|
28
|
+
gem.add_development_dependency "tzinfo", "~> 1.2", ">= 1.2.2"
|
29
|
+
gem.add_development_dependency "tzinfo-data", ">= 1.2016.1"
|
26
30
|
end
|
metadata
CHANGED
@@ -1,107 +1,107 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zonebie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Lindeman
|
8
8
|
- Steven Harman
|
9
9
|
- Patrick Van Stee
|
10
10
|
autorequire:
|
11
|
-
bindir:
|
11
|
+
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rspec
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '3.4'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '3.4'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: mocha
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 0.14.0
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ~>
|
54
|
+
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 0.14.0
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: activesupport
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '3.0'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
70
|
+
version: '3.0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: tzinfo
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - ~>
|
75
|
+
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '1.
|
78
|
-
- -
|
77
|
+
version: '1.2'
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: 1.
|
80
|
+
version: 1.2.2
|
81
81
|
type: :development
|
82
82
|
prerelease: false
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - ~>
|
85
|
+
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '1.
|
88
|
-
- -
|
87
|
+
version: '1.2'
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 1.
|
90
|
+
version: 1.2.2
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: tzinfo-data
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 1.
|
97
|
+
version: 1.2016.1
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 1.
|
104
|
+
version: 1.2016.1
|
105
105
|
description: Runs your tests in a random timezone
|
106
106
|
email:
|
107
107
|
- andy@andylindeman.com
|
@@ -111,9 +111,9 @@ executables: []
|
|
111
111
|
extensions: []
|
112
112
|
extra_rdoc_files: []
|
113
113
|
files:
|
114
|
-
- .gitignore
|
115
|
-
- .rspec
|
116
|
-
- .travis.yml
|
114
|
+
- ".gitignore"
|
115
|
+
- ".rspec"
|
116
|
+
- ".travis.yml"
|
117
117
|
- Changelog.md
|
118
118
|
- Gemfile
|
119
119
|
- LICENSE
|
@@ -141,17 +141,17 @@ require_paths:
|
|
141
141
|
- lib
|
142
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- -
|
144
|
+
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
146
|
+
version: 2.0.0
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
|
-
- -
|
149
|
+
- - ">="
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.5.1
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Zonebie prevents bugs in code that deals with timezones by randomly assigning
|