fixme 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c22c8de703949aee9f30546eb6e2c7bb31cbc01
4
- data.tar.gz: a8ad824e7c638e50bc0f22fd865fb7808fc28290
3
+ metadata.gz: cbc2e5c159dcd920e203ec950ac493e9339b77e8
4
+ data.tar.gz: 96191e0feb5b2c28d2dc3d7bb65fd3e162307ef6
5
5
  SHA512:
6
- metadata.gz: b3d9ec182e5b1a70559e04a14df877fa20432fde0567a77e73ac42444261eafcc8b47e042f9e71116c412c4441ff86778c015fe2fae85fe50cf5e6dd7c02d3d6
7
- data.tar.gz: 0cbc5e4615e2debaf36b8251a10a29ab684e02fddfd9b2aa1ca82a3ca7653ff8d2b7c53229048516ac60aaccf9fd3e7c2e4c79d92dbc992584fdf2d323623d96
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"` environment. The production app will never raise these exceptions.
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
- rspec # Run tests.
43
+ rake # Run tests.
44
44
  ```
45
45
 
46
46
 
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/lib/fixme.rb CHANGED
@@ -1,5 +1,22 @@
1
1
  require "fixme/version"
2
+ require "date"
2
3
 
3
4
  module Fixme
4
- # Your code goes here...
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
@@ -1,3 +1,3 @@
1
1
  module Fixme
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/spec/fixme_spec.rb CHANGED
@@ -1,2 +1,77 @@
1
- describe Fixme do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh