fail_fast 0.1.1 → 0.1.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.
- data/CHANGELOG.txt +2 -0
- data/README.markdown +14 -3
- data/VERSION +1 -1
- data/fail_fast.gemspec +2 -2
- data/lib/fail_fast/misc.rb +8 -0
- data/spec/misc_spec.rb +43 -1
- metadata +4 -4
data/CHANGELOG.txt
CHANGED
data/README.markdown
CHANGED
@@ -20,12 +20,17 @@ Early in your project boot sequence insert code like
|
|
20
20
|
FailFast('path_to/config.yml', prefix=Rails.env).check do
|
21
21
|
has_values_for 'author/fname', 'author/lname'
|
22
22
|
has_email_for 'newsletter/to_address'
|
23
|
-
|
23
|
+
|
24
|
+
only_if Rails.env.production? do
|
25
|
+
has_url_for 'bug_tracker/url', :reachable => true
|
26
|
+
end
|
24
27
|
|
25
28
|
directory_exists_for '/tmp'
|
26
29
|
file_exists_for 'public/nda.pdf'
|
27
30
|
|
28
|
-
|
31
|
+
skip_if Rails.env.development? do
|
32
|
+
fail "I don't work on Sunday" if 0 == Time.now.wday
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
If it fails, you'll get a report like this :
|
@@ -88,7 +93,7 @@ You can also add custom rules, not related to any config files :
|
|
88
93
|
file_exists '/Users/me/.bash_profile'
|
89
94
|
has_mongoDB 'localhost', 'db_app_1'
|
90
95
|
has_active_record_db :host => 'dbserv', :adapter => 'mysql', :database => 'db'
|
91
|
-
|
96
|
+
fail "I don't work on Sunday" if (0 == Time.now.wday)
|
92
97
|
|
93
98
|
### _keyed_ commands (linked to a value found in a yaml file) :
|
94
99
|
|
@@ -124,3 +129,9 @@ Test external services :
|
|
124
129
|
# can we connect to a SQL db :
|
125
130
|
has_active_record_db_for 'production/db_connection'
|
126
131
|
|
132
|
+
Misc :
|
133
|
+
fail 'message'
|
134
|
+
|
135
|
+
Control commands :
|
136
|
+
skip_if <condition> do .. end
|
137
|
+
only_if <condition> do .. end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/fail_fast.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fail_fast}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alain Ravet"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-22}
|
13
13
|
s.description = %q{raises an error if the yaml contents of a config file does not pass a test script.}
|
14
14
|
s.email = %q{alainravet@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/fail_fast/misc.rb
CHANGED
@@ -8,6 +8,14 @@ class FailFast
|
|
8
8
|
def fail(message)
|
9
9
|
FailFast.errors << ErrorDetails.new(nil, :fail, message)
|
10
10
|
end
|
11
|
+
|
12
|
+
def only_if(condition, &block)
|
13
|
+
yield if condition
|
14
|
+
end
|
15
|
+
|
16
|
+
def skip_if(condition, &block)
|
17
|
+
yield if !condition
|
18
|
+
end
|
11
19
|
end
|
12
20
|
end
|
13
21
|
FailFast.send :include, FailFast::Misc
|
data/spec/misc_spec.rb
CHANGED
@@ -1,7 +1,49 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "fail()" do
|
4
4
|
it_should_raise_a_direct_error('message-123', :fail, 'when fail() is called') {
|
5
5
|
fail 'message-123'
|
6
6
|
}
|
7
7
|
end
|
8
|
+
|
9
|
+
describe "only_if" do
|
10
|
+
it_should_not_raise_an_error('only_if false does not run the block') {
|
11
|
+
only_if false do
|
12
|
+
fail 'never executed'
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
it_should_raise_a_direct_error('message 456', :fail, 'only_if true runs the block') {
|
17
|
+
only_if true do
|
18
|
+
fail 'message 456'
|
19
|
+
end
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "skip_if" do
|
24
|
+
it_should_not_raise_an_error('skip_if(true) does not run the block') {
|
25
|
+
skip_if true do
|
26
|
+
fail 'never executed'
|
27
|
+
end
|
28
|
+
}
|
29
|
+
|
30
|
+
it_should_raise_a_direct_error('message 456', :fail, 'skip_if(false) runs the block') {
|
31
|
+
skip_if false do
|
32
|
+
fail 'message 456'
|
33
|
+
end
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "skip_if" do
|
38
|
+
it_should_not_raise_an_error('skip_if(true) does not run the block') {
|
39
|
+
skip_if true do
|
40
|
+
fail 'never executed'
|
41
|
+
end
|
42
|
+
}
|
43
|
+
|
44
|
+
it_should_raise_a_direct_error('message 456', :fail, 'skip_if(false) runs the block') {
|
45
|
+
skip_if false do
|
46
|
+
fail 'message 456'
|
47
|
+
end
|
48
|
+
}
|
49
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fail_fast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alain Ravet
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-22 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|