fixme 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fixme.gemspec +1 -0
- data/lib/fixme.rb +11 -2
- data/lib/fixme/version.rb +1 -1
- data/spec/fixme_spec.rb +27 -8
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5918a9a8d6c7ed2b50dffce574ddd35938855694
|
4
|
+
data.tar.gz: 174d74e39c33019eeb487ad97cf58c827a0618dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f862c20eb8fd60cbc2bd6fcefbaaee13ed635d0f4ebefe84167b13f9c8a3df23eeac57c5ae60c40ec1394f2b4ff029d5fee13d9f0a90138312da6e9977fa4a
|
7
|
+
data.tar.gz: 3bec830317f532f8e923ce858921f3ad12dc1a65ddeb753c8d4771ef0f38950ca672ee36788a368d44c7d65b515b8f92ddbe9eb1aa8ac0313a25124a6a36a010
|
data/fixme.gemspec
CHANGED
data/lib/fixme.rb
CHANGED
@@ -13,9 +13,18 @@ module Fixme
|
|
13
13
|
|
14
14
|
raw_date, message = date_and_message.split(": ", 2)
|
15
15
|
due_date = Date.parse(raw_date)
|
16
|
-
return if Date.today < due_date
|
17
16
|
|
18
|
-
|
17
|
+
raise_if_due = -> {
|
18
|
+
if Date.today >= due_date
|
19
|
+
raise UnfixedError, "Fix by #{due_date}: #{message}"
|
20
|
+
end
|
21
|
+
}
|
22
|
+
|
23
|
+
if defined?(Timecop)
|
24
|
+
Timecop.return(&raise_if_due)
|
25
|
+
else
|
26
|
+
raise_if_due.call
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
data/lib/fixme/version.rb
CHANGED
data/spec/fixme_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "fixme"
|
2
|
+
require "timecop"
|
2
3
|
|
3
4
|
describe Fixme, "#FIXME" do
|
4
5
|
it "raises after the given date" do
|
@@ -34,55 +35,73 @@ describe Fixme, "#FIXME" do
|
|
34
35
|
}.to raise_error(Fixme::UnfixedError)
|
35
36
|
end
|
36
37
|
|
38
|
+
it "is not fooled by the Timecop gem" do
|
39
|
+
future_date = Date.today + 2
|
40
|
+
|
41
|
+
Timecop.travel(future_date) do
|
42
|
+
expect {
|
43
|
+
FIXME "#{future_date}: Travel back in time."
|
44
|
+
}.not_to raise_error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
37
48
|
context "when a Rails environment is detected" do
|
38
49
|
before do
|
39
50
|
stub_const("Rails", double)
|
40
51
|
end
|
41
52
|
|
42
53
|
it "raises in the 'test' environment" do
|
43
|
-
|
54
|
+
stub_rails_env "test"
|
44
55
|
expect_to_raise
|
45
56
|
end
|
46
57
|
|
47
58
|
it "raises in the 'development' environment" do
|
48
|
-
|
59
|
+
stub_rails_env "development"
|
49
60
|
expect_to_raise
|
50
61
|
end
|
51
62
|
|
52
63
|
it "does not raise in other environments" do
|
53
|
-
|
64
|
+
stub_rails_env "production"
|
54
65
|
expect_not_to_raise
|
55
66
|
end
|
56
67
|
end
|
57
68
|
|
58
69
|
context "when a Rack environment is detected" do
|
59
70
|
before do
|
60
|
-
|
71
|
+
stub_env "DO_NOT_RAISE_FIXMES", nil
|
61
72
|
end
|
62
73
|
|
63
74
|
it "raises in the 'test' environment" do
|
64
|
-
|
75
|
+
stub_env "RACK_ENV", "test"
|
65
76
|
expect_to_raise
|
66
77
|
end
|
67
78
|
|
68
79
|
it "raises in the 'development' environment" do
|
69
|
-
|
80
|
+
stub_env "RACK_ENV", "development"
|
70
81
|
expect_to_raise
|
71
82
|
end
|
72
83
|
|
73
84
|
it "does not raise in other environments" do
|
74
|
-
|
85
|
+
stub_env "RACK_ENV", "production"
|
75
86
|
expect_not_to_raise
|
76
87
|
end
|
77
88
|
end
|
78
89
|
|
79
90
|
it "does not raise when the DO_NOT_RAISE_FIXMES environment variable is set" do
|
80
|
-
|
91
|
+
stub_env "DO_NOT_RAISE_FIXMES", true
|
81
92
|
expect_not_to_raise
|
82
93
|
end
|
83
94
|
|
84
95
|
private
|
85
96
|
|
97
|
+
def stub_rails_env(value)
|
98
|
+
allow(Rails).to receive(:env).and_return(value)
|
99
|
+
end
|
100
|
+
|
101
|
+
def stub_env(name, value)
|
102
|
+
allow(ENV).to receive(:[]).with(name).and_return(value)
|
103
|
+
end
|
104
|
+
|
86
105
|
def expect_to_raise
|
87
106
|
expect { FIXME "2013-12-31: X" }.to raise_error(Fixme::UnfixedError)
|
88
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: timecop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- henrik@nyh.se
|