fixme 0.0.1 → 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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +5 -0
- data/lib/fixme.rb +18 -1
- data/lib/fixme/version.rb +1 -1
- data/spec/fixme_spec.rb +76 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbc2e5c159dcd920e203ec950ac493e9339b77e8
|
4
|
+
data.tar.gz: 96191e0feb5b2c28d2dc3d7bb65fd3e162307ef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13424bc30b93a5c28007dd1bd80f4786c5c9a36918dde89c4d4e81e133fd7458bc5c8e6c41e2843db73840e918a2f036135aee3770e89e1171eaa260f6943d31
|
7
|
+
data.tar.gz: 8694fdbb13ed2d7382f3e04cfbe98c1ae3843e6d2baefaafad6f19dbf37f2d399ddcbadfd608b0e6f099d88a135af7b45edae60f2b7a239b16c8478dd6b50c86
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ You may want to use them next to:
|
|
16
16
|
|
17
17
|
Starting July 31st 2014, the "FIXME" line in the example above would start raising an exception with the given message.
|
18
18
|
|
19
|
-
If `Rails.environment` (Ruby on Rails) or `ENV["RACK_ENV"]` (e.g. Sinatra) is present, it will only ever raise in the `"test"`
|
19
|
+
If `Rails.environment` (Ruby on Rails) or `ENV["RACK_ENV"]` (e.g. Sinatra) is present, it will only ever raise in the `"test"` and `"development"` environments. That is, the production app will never raise these exceptions.
|
20
20
|
|
21
21
|
|
22
22
|
## Installation
|
@@ -40,7 +40,7 @@ Clone the repo, then:
|
|
40
40
|
|
41
41
|
```
|
42
42
|
bundle # Install gem dependencies.
|
43
|
-
|
43
|
+
rake # Run tests.
|
44
44
|
```
|
45
45
|
|
46
46
|
|
data/Rakefile
CHANGED
data/lib/fixme.rb
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
require "fixme/version"
|
2
|
+
require "date"
|
2
3
|
|
3
4
|
module Fixme
|
4
|
-
|
5
|
+
class UnfixedError < StandardError; end
|
6
|
+
|
7
|
+
module Mixin
|
8
|
+
def FIXME(date_and_message)
|
9
|
+
raw_date, message = date_and_message.split(": ")
|
10
|
+
due_date = Date.parse(raw_date)
|
11
|
+
|
12
|
+
return if Date.today < due_date
|
13
|
+
|
14
|
+
env = defined?(Rails) ? Rails.env : ENV["RACK_ENV"]
|
15
|
+
return unless [ "", "test", "development" ].include?(env.to_s)
|
16
|
+
|
17
|
+
raise UnfixedError, "Fix by #{due_date}: #{message}"
|
18
|
+
end
|
19
|
+
end
|
5
20
|
end
|
21
|
+
|
22
|
+
Object.include(Fixme::Mixin)
|
data/lib/fixme/version.rb
CHANGED
data/spec/fixme_spec.rb
CHANGED
@@ -1,2 +1,77 @@
|
|
1
|
-
|
1
|
+
require "fixme"
|
2
|
+
|
3
|
+
describe Fixme, "#TODO" do
|
4
|
+
it "raises after the given date" do
|
5
|
+
expect {
|
6
|
+
FIXME "2013-12-31: Remove this stuff."
|
7
|
+
}.to raise_error(Fixme::UnfixedError, "Fix by 2013-12-31: Remove this stuff.")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "raises on the given date" do
|
11
|
+
expect {
|
12
|
+
FIXME "#{Date.today.to_s}: Remove this stuff."
|
13
|
+
}.to raise_error(Fixme::UnfixedError, "Fix by #{Date.today.to_s}: Remove this stuff.")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "does not raise before the given date" do
|
17
|
+
expect {
|
18
|
+
FIXME "9999-01-01: Upgrade to Ruby 641.3.1."
|
19
|
+
}.not_to raise_error
|
20
|
+
end
|
21
|
+
|
22
|
+
it "is available everywhere" do
|
23
|
+
expect {
|
24
|
+
"some random object".instance_eval do
|
25
|
+
FIXME "2013-12-31: Make it work everywhere."
|
26
|
+
end
|
27
|
+
}.to raise_error(Fixme::UnfixedError)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when a Rails environment is detected" do
|
31
|
+
before do
|
32
|
+
stub_const("Rails", double)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "raises in the 'test' environment" do
|
36
|
+
Rails.stub(env: "test")
|
37
|
+
expect_to_raise
|
38
|
+
end
|
39
|
+
|
40
|
+
it "raises in the 'development' environment" do
|
41
|
+
Rails.stub(env: "development")
|
42
|
+
expect_to_raise
|
43
|
+
end
|
44
|
+
|
45
|
+
it "does not raise in other environments" do
|
46
|
+
Rails.stub(env: "production")
|
47
|
+
expect_not_to_raise
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when a Rack environment is detected" do
|
52
|
+
it "raises in the 'test' environment" do
|
53
|
+
ENV.stub(:[]).with("RACK_ENV").and_return("test")
|
54
|
+
expect_to_raise
|
55
|
+
end
|
56
|
+
|
57
|
+
it "raises in the 'development' environment" do
|
58
|
+
ENV.stub(:[]).with("RACK_ENV").and_return("development")
|
59
|
+
expect_to_raise
|
60
|
+
end
|
61
|
+
|
62
|
+
it "does not raise in other environments" do
|
63
|
+
ENV.stub(:[]).with("RACK_ENV").and_return("production")
|
64
|
+
expect_not_to_raise
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def expect_to_raise
|
71
|
+
expect { FIXME "2013-12-31: X" }.to raise_error(Fixme::UnfixedError)
|
72
|
+
end
|
73
|
+
|
74
|
+
def expect_not_to_raise
|
75
|
+
expect { FIXME "2013-12-31: X" }.not_to raise_error
|
76
|
+
end
|
2
77
|
end
|