hobbit-contrib 0.4.1 → 0.4.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -0
- data/lib/hobbit/contrib/version.rb +1 -1
- data/lib/hobbit/environment.rb +5 -1
- data/spec/environment_spec.rb +62 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba27dac2bea807bb25e736cc7c7434195f88d923
|
4
|
+
data.tar.gz: 9c04e21b41ebea5084eccb794d0a76c2f986e8bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 250a1cc17556504c69ad5e0d43a751ae5a431bce48819d82bacccb2f5c5047fd3928f18c291c0e3c9f1ae9b753cf041f23e7737daa41d77c83a346ead1f98332
|
7
|
+
data.tar.gz: b50979f85f54764f2422419273407a46fec4f0ce9973a61ad4534e349f6c31ec407f1b11b6809042c8d062ed3a6260a052e66738f8cb7c07feb63879f6003547
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -71,6 +71,8 @@ run App.new
|
|
71
71
|
* `production?`: Returns true if the current environment is `:production`.
|
72
72
|
* `test?`: Returns true if the current environment is `:test`.
|
73
73
|
|
74
|
+
**Note**: All methods are available at class and instance context.
|
75
|
+
|
74
76
|
### Hobbit::ErrorHandling
|
75
77
|
|
76
78
|
This extension provides a way of handling errors raised by your application. To
|
data/lib/hobbit/environment.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module Hobbit
|
2
2
|
module Environment
|
3
|
+
def self.included(othermod)
|
4
|
+
othermod.extend self
|
5
|
+
end
|
6
|
+
|
3
7
|
def environment
|
4
8
|
ENV['RACK_ENV'].to_sym
|
5
9
|
end
|
@@ -8,4 +12,4 @@ module Hobbit
|
|
8
12
|
define_method("#{env}?") { environment == env.to_sym }
|
9
13
|
end
|
10
14
|
end
|
11
|
-
end
|
15
|
+
end
|
data/spec/environment_spec.rb
CHANGED
@@ -9,19 +9,45 @@ describe Hobbit::Environment do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
def with_env(environment)
|
13
|
+
env, ENV['RACK_ENV'] = ENV['RACK_ENV'], environment
|
14
|
+
yield
|
15
|
+
ENV['RACK_ENV'] = env
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '::environment' do
|
19
|
+
it 'must return the current environment' do
|
20
|
+
with_env('development') do
|
21
|
+
app.to_app.class.environment.must_equal :development
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
12
26
|
describe '#environment' do
|
13
27
|
it 'must return the current environment' do
|
14
|
-
|
15
|
-
|
16
|
-
|
28
|
+
with_env('development') do
|
29
|
+
app.to_app.environment.must_equal :development
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '::development?' do
|
35
|
+
it "must return true if ENV['RACK_ENV'] = :development" do
|
36
|
+
with_env('development') do
|
37
|
+
app.to_app.class.development?.must_equal true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "must return false if ENV['RACK_ENV'] != :development" do
|
42
|
+
app.to_app.class.development?.must_equal false
|
17
43
|
end
|
18
44
|
end
|
19
45
|
|
20
46
|
describe '#development?' do
|
21
47
|
it "must return true if ENV['RACK_ENV'] = :development" do
|
22
|
-
|
23
|
-
|
24
|
-
|
48
|
+
with_env('development') do
|
49
|
+
app.to_app.development?.must_equal true
|
50
|
+
end
|
25
51
|
end
|
26
52
|
|
27
53
|
it "must return false if ENV['RACK_ENV'] != :development" do
|
@@ -29,11 +55,23 @@ describe Hobbit::Environment do
|
|
29
55
|
end
|
30
56
|
end
|
31
57
|
|
58
|
+
describe '::production?' do
|
59
|
+
it "must return true if ENV['RACK_ENV'] = :production" do
|
60
|
+
with_env('production') do
|
61
|
+
app.to_app.class.production?.must_equal true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "must return false if ENV['RACK_ENV'] != :production" do
|
66
|
+
app.to_app.class.production?.must_equal false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
32
70
|
describe '#production?' do
|
33
71
|
it "must return true if ENV['RACK_ENV'] = :production" do
|
34
|
-
|
35
|
-
|
36
|
-
|
72
|
+
with_env('production') do
|
73
|
+
app.to_app.production?.must_equal true
|
74
|
+
end
|
37
75
|
end
|
38
76
|
|
39
77
|
it "must return false if ENV['RACK_ENV'] != :production" do
|
@@ -41,15 +79,27 @@ describe Hobbit::Environment do
|
|
41
79
|
end
|
42
80
|
end
|
43
81
|
|
82
|
+
describe '::test?' do
|
83
|
+
it "must return true if ENV['RACK_ENV'] = :test" do
|
84
|
+
app.to_app.class.test?.must_equal true
|
85
|
+
end
|
86
|
+
|
87
|
+
it "must return false if ENV['RACK_ENV'] != :test" do
|
88
|
+
with_env('development') do
|
89
|
+
app.to_app.class.test?.must_equal false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
44
94
|
describe '#test?' do
|
45
95
|
it "must return true if ENV['RACK_ENV'] = :test" do
|
46
96
|
app.to_app.test?.must_equal true
|
47
97
|
end
|
48
98
|
|
49
99
|
it "must return false if ENV['RACK_ENV'] != :test" do
|
50
|
-
|
51
|
-
|
52
|
-
|
100
|
+
with_env('development') do
|
101
|
+
app.to_app.test?.must_equal false
|
102
|
+
end
|
53
103
|
end
|
54
104
|
end
|
55
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobbit-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Mac Adden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|