fail_fast 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/CHANGELOG.txt +6 -0
  2. data/README.markdown +16 -3
  3. data/fail_fast.gemspec +7 -3
  4. data/lib/fail_fast.rb +88 -1
  5. data/lib/fail_fast/base/base.rb +11 -7
  6. data/lib/fail_fast/base/console_utils.rb +20 -0
  7. data/lib/fail_fast/base/utils.rb +0 -13
  8. data/lib/fail_fast/error_reporter.rb +7 -0
  9. data/lib/fail_fast/error_reporter/base.rb +40 -0
  10. data/lib/fail_fast/error_reporter/hoptoad.rb +34 -0
  11. data/lib/fail_fast/error_reporter/hoptoad/post_error_request.xml.erb +23 -0
  12. data/lib/fail_fast/error_reporter/stdout.rb +9 -0
  13. data/lib/fail_fast/report.txt.erb +9 -4
  14. data/lib/fail_fast/support/error_details.rb +5 -1
  15. data/show_all_errors.rb +5 -5
  16. data/spec/{fixtures → _/fixtures}/empty.yml +0 -0
  17. data/spec/{fixtures → _/fixtures}/simple.yml +3 -3
  18. data/spec/_/support/errors.rb +13 -0
  19. data/spec/_/support/errors_reporters.rb +3 -0
  20. data/spec/_/support/hoptoad.rb +7 -0
  21. data/spec/_/support/it_extensions.rb +126 -0
  22. data/spec/_/support/stdout.rb +8 -0
  23. data/spec/_/support/vcr.rb +11 -0
  24. data/spec/_/support/webmock.rb +4 -0
  25. data/spec/_/support/xml.rb +4 -0
  26. data/spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_1_errors_occurs_in_1_block.yml +35 -0
  27. data/spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_2_errors_occur_in_1_block.yml +37 -0
  28. data/spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_3_errors_occur_in_2_blocks.yml +71 -0
  29. data/spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_the_API_token_is_invalid.yml +67 -0
  30. data/spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_the_API_token_is_valid.yml +35 -0
  31. data/spec/base/error_details_spec.rb +8 -0
  32. data/spec/error_reporter/fail_fast_spec.rb +73 -0
  33. data/spec/error_reporter/global_reporters_spec.rb +22 -0
  34. data/spec/error_reporter/hoptoad/expected_error_1_request.xml.erb +21 -0
  35. data/spec/error_reporter/hoptoad/expected_error_2_request.xml.erb +22 -0
  36. data/spec/error_reporter/hoptoad/hoptoad_activation_spec.rb +14 -0
  37. data/spec/error_reporter/hoptoad/hoptoad_requests_spec.rb +63 -0
  38. data/spec/error_reporter/hoptoad/hoptoad_responses_spec.rb +35 -0
  39. data/spec/error_reporter/stdout/stdout_spec.rb +24 -0
  40. data/spec/extensions/file_or_directory_exists_spec.rb +2 -2
  41. data/spec/extensions/has_url_spec.rb +3 -6
  42. data/spec/extensions/key_prefix_spec.rb +1 -1
  43. data/spec/how_to_use_spec.rb +1 -3
  44. data/spec/spec_helper.rb +13 -134
  45. metadata +120 -18
  46. data/lib/fail_fast/base/messaging.rb +0 -40
  47. data/lib/fail_fast/main.rb +0 -34
  48. data/spec/base/report_printing_spec.rb +0 -29
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: 15
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 2
10
- version: 0.5.2
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
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: 2011-06-16 00:00:00 Z
18
+ date: 2011-06-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false
@@ -40,12 +40,14 @@ dependencies:
40
40
  version_requirements: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - "="
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 27
46
46
  segments:
47
- - 0
48
- version: "0"
47
+ - 2
48
+ - 3
49
+ - 12
50
+ version: 2.3.12
49
51
  requirement: *id002
50
52
  - !ruby/object:Gem::Dependency
51
53
  prerelease: false
@@ -63,7 +65,7 @@ dependencies:
63
65
  requirement: *id003
64
66
  - !ruby/object:Gem::Dependency
65
67
  prerelease: false
66
- name: fakeweb
68
+ name: webmock
67
69
  type: :development
68
70
  version_requirements: &id004 !ruby/object:Gem::Requirement
69
71
  none: false
@@ -75,6 +77,62 @@ dependencies:
75
77
  - 0
76
78
  version: "0"
77
79
  requirement: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ prerelease: false
82
+ name: bson_ext
83
+ type: :development
84
+ version_requirements: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirement: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ prerelease: false
96
+ name: bson_ext
97
+ type: :development
98
+ version_requirements: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ requirement: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ prerelease: false
110
+ name: timecop
111
+ type: :development
112
+ version_requirements: &id007 !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ requirement: *id007
122
+ - !ruby/object:Gem::Dependency
123
+ prerelease: false
124
+ name: vcr
125
+ type: :development
126
+ version_requirements: &id008 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
135
+ requirement: *id008
78
136
  description: raises an error if the yaml contents of a config file does pass a test script.
79
137
  email: alain.ravet@gmail.com
80
138
  executables: []
@@ -96,9 +154,14 @@ files:
96
154
  - fail_fast.gemspec
97
155
  - lib/fail_fast.rb
98
156
  - lib/fail_fast/base/base.rb
99
- - lib/fail_fast/base/messaging.rb
157
+ - lib/fail_fast/base/console_utils.rb
100
158
  - lib/fail_fast/base/utils.rb
101
159
  - lib/fail_fast/base/z_only_for_tests.rb
160
+ - lib/fail_fast/error_reporter.rb
161
+ - lib/fail_fast/error_reporter/base.rb
162
+ - lib/fail_fast/error_reporter/hoptoad.rb
163
+ - lib/fail_fast/error_reporter/hoptoad/post_error_request.xml.erb
164
+ - lib/fail_fast/error_reporter/stdout.rb
102
165
  - lib/fail_fast/extensions/base_commands.rb
103
166
  - lib/fail_fast/extensions/directory_exists.rb
104
167
  - lib/fail_fast/extensions/file_exists.rb
@@ -108,12 +171,26 @@ files:
108
171
  - lib/fail_fast/extensions/has_url.rb
109
172
  - lib/fail_fast/extensions/has_value.rb
110
173
  - lib/fail_fast/extensions/is_on_path.rb
111
- - lib/fail_fast/main.rb
112
174
  - lib/fail_fast/report.txt.erb
113
175
  - lib/fail_fast/support/error_db.rb
114
176
  - lib/fail_fast/support/error_details.rb
115
177
  - lib/fail_fast/support/z_only_for_tests.rb
116
178
  - show_all_errors.rb
179
+ - spec/_/fixtures/empty.yml
180
+ - spec/_/fixtures/simple.yml
181
+ - spec/_/support/errors.rb
182
+ - spec/_/support/errors_reporters.rb
183
+ - spec/_/support/hoptoad.rb
184
+ - spec/_/support/it_extensions.rb
185
+ - spec/_/support/stdout.rb
186
+ - spec/_/support/vcr.rb
187
+ - spec/_/support/webmock.rb
188
+ - spec/_/support/xml.rb
189
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_1_errors_occurs_in_1_block.yml
190
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_2_errors_occur_in_1_block.yml
191
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_3_errors_occur_in_2_blocks.yml
192
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_the_API_token_is_invalid.yml
193
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_the_API_token_is_valid.yml
117
194
  - spec/base/base_commands/fail_spec.rb
118
195
  - spec/base/base_commands/failed_spec.rb
119
196
  - spec/base/base_commands/only_if_spec.rb
@@ -122,9 +199,16 @@ files:
122
199
  - spec/base/errors_storage_spec.rb
123
200
  - spec/base/multiple_blocks_support_spec.rb
124
201
  - spec/base/not_linked_to_a_config_file_spec.rb
125
- - spec/base/report_printing_spec.rb
126
202
  - spec/base/when_config_file_is_empty_spec.rb
127
203
  - spec/base/when_config_file_is_missing_spec.rb
204
+ - spec/error_reporter/fail_fast_spec.rb
205
+ - spec/error_reporter/global_reporters_spec.rb
206
+ - spec/error_reporter/hoptoad/expected_error_1_request.xml.erb
207
+ - spec/error_reporter/hoptoad/expected_error_2_request.xml.erb
208
+ - spec/error_reporter/hoptoad/hoptoad_activation_spec.rb
209
+ - spec/error_reporter/hoptoad/hoptoad_requests_spec.rb
210
+ - spec/error_reporter/hoptoad/hoptoad_responses_spec.rb
211
+ - spec/error_reporter/stdout/stdout_spec.rb
128
212
  - spec/extensions/file_or_directory_exists_spec.rb
129
213
  - spec/extensions/has_active_record_db_spec.rb
130
214
  - spec/extensions/has_email_spec.rb
@@ -133,8 +217,6 @@ files:
133
217
  - spec/extensions/has_value_spec.rb
134
218
  - spec/extensions/is_on_path_spec.rb
135
219
  - spec/extensions/key_prefix_spec.rb
136
- - spec/fixtures/empty.yml
137
- - spec/fixtures/simple.yml
138
220
  - spec/how_to_use_spec.rb
139
221
  - spec/spec.opts
140
222
  - spec/spec_helper.rb
@@ -172,6 +254,21 @@ signing_key:
172
254
  specification_version: 3
173
255
  summary: raises an error if the yaml contents of a config file does pass a test script.
174
256
  test_files:
257
+ - spec/_/fixtures/empty.yml
258
+ - spec/_/fixtures/simple.yml
259
+ - spec/_/support/errors.rb
260
+ - spec/_/support/errors_reporters.rb
261
+ - spec/_/support/hoptoad.rb
262
+ - spec/_/support/it_extensions.rb
263
+ - spec/_/support/stdout.rb
264
+ - spec/_/support/vcr.rb
265
+ - spec/_/support/webmock.rb
266
+ - spec/_/support/xml.rb
267
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_1_errors_occurs_in_1_block.yml
268
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_2_errors_occur_in_1_block.yml
269
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_3_errors_occur_in_2_blocks.yml
270
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_the_API_token_is_invalid.yml
271
+ - spec/_vcr_cassette_library/FailFast_ErrorReporter_Hoptoad/when_the_API_token_is_valid.yml
175
272
  - spec/base/base_commands/fail_spec.rb
176
273
  - spec/base/base_commands/failed_spec.rb
177
274
  - spec/base/base_commands/only_if_spec.rb
@@ -180,9 +277,16 @@ test_files:
180
277
  - spec/base/errors_storage_spec.rb
181
278
  - spec/base/multiple_blocks_support_spec.rb
182
279
  - spec/base/not_linked_to_a_config_file_spec.rb
183
- - spec/base/report_printing_spec.rb
184
280
  - spec/base/when_config_file_is_empty_spec.rb
185
281
  - spec/base/when_config_file_is_missing_spec.rb
282
+ - spec/error_reporter/fail_fast_spec.rb
283
+ - spec/error_reporter/global_reporters_spec.rb
284
+ - spec/error_reporter/hoptoad/expected_error_1_request.xml.erb
285
+ - spec/error_reporter/hoptoad/expected_error_2_request.xml.erb
286
+ - spec/error_reporter/hoptoad/hoptoad_activation_spec.rb
287
+ - spec/error_reporter/hoptoad/hoptoad_requests_spec.rb
288
+ - spec/error_reporter/hoptoad/hoptoad_responses_spec.rb
289
+ - spec/error_reporter/stdout/stdout_spec.rb
186
290
  - spec/extensions/file_or_directory_exists_spec.rb
187
291
  - spec/extensions/has_active_record_db_spec.rb
188
292
  - spec/extensions/has_email_spec.rb
@@ -191,8 +295,6 @@ test_files:
191
295
  - spec/extensions/has_value_spec.rb
192
296
  - spec/extensions/is_on_path_spec.rb
193
297
  - spec/extensions/key_prefix_spec.rb
194
- - spec/fixtures/empty.yml
195
- - spec/fixtures/simple.yml
196
298
  - spec/how_to_use_spec.rb
197
299
  - spec/spec.opts
198
300
  - spec/spec_helper.rb
@@ -1,40 +0,0 @@
1
- class FailFast
2
-
3
- module Messaging #:nodoc:
4
-
5
- def default_message_for(e)
6
- qc_value = "'#{vcol(e.value)}'"
7
- qc_key = "'#{kcol(e.key)}'"
8
- details = if e.value.nil? then " for the key #{qc_key}"
9
- elsif e.key.nil? then " #{qc_value}"
10
- else " #{qc_value} for the key #{qc_key}"
11
- end
12
-
13
- s = case e.kind
14
- when :config_file_not_found then mcol("The config file could not be found") + " : #{yellow(e.value)}."
15
- when :missing_value then mcol("Missing value") +" #{details}."
16
- when :value_does_not_match then mcol("Invalid value") +" #{details}."
17
- when :not_an_email then mcol("Invalid email address") + " #{details}."
18
- when :not_a_url then mcol("Invalid url") + " #{details}."
19
- when :url_not_reachable then mcol("Could not reach the url") + " #{details}."
20
- when :directory_not_found then mcol("Missing directory") + " #{details}."
21
- when :file_not_found then mcol("Missing file") + " #{details}."
22
- when :not_on_path then mcol("App not on path : ") + " #{details}."
23
- when :mongoDB_server_not_found then mcol("Could not connect to the mongoDb server") + " #{details}."
24
- when :mongoDB_db_not_found then mcol("Could not open the mongoDb db") + " #{details}."
25
- when :active_record_db_connection_error then mcol("Could not connect to the DB server") + " #{details}."
26
- when :fail then mcol(e.value)
27
- else
28
- "%-38s %-35s %-30s \n" % [ e.kind, e.key, qc_value]
29
- end
30
- e.message ? "#{e.message}\n| #{s}": s
31
- end
32
-
33
- def mcol(msg) lred(msg) end
34
- def kcol(key) yellow(key) end
35
- def vcol(val) yellow(val) end
36
-
37
- end
38
- end
39
-
40
- FailFast.send :include, FailFast::Messaging
@@ -1,34 +0,0 @@
1
- require 'yaml'
2
- require 'erb'
3
- require File.expand_path(File.dirname(__FILE__) + '/support/error_db')
4
-
5
- class FailFast
6
-
7
- @@_errors_db = FailFast::ErrorDb.new
8
-
9
- def initialize(config_file_path, keys_prefix=nil)
10
- @config_file_path = config_file_path
11
- @keys_prefix = keys_prefix
12
- @errors_key = ErrorDb.key_for(config_file_path, keys_prefix)
13
- end
14
-
15
- def self.fail_now
16
- exit(1) unless errors_db.keys.empty?
17
- end
18
-
19
- def self.failed?
20
- !global_errors.empty?
21
- end
22
-
23
- def self.errors_db #:nodoc:
24
- @@_errors_db
25
- end
26
-
27
- def add_error(value)
28
- @@_errors_db.append(@errors_key, value)
29
- end
30
-
31
- def errors
32
- @@_errors_db.errors_for(@errors_key)
33
- end
34
- end
@@ -1,29 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe "the printed error report" do
4
- before(:each) { capture_stdout }
5
- after( :each) { restore_stdout }
6
-
7
- it "contains an error details" do
8
- begin
9
- FailFast(SIMPLE_FILE_PATH).check { has_value_for :anykey }
10
- rescue
11
- end
12
- $stdout.string.should match(/error.*#{SIMPLE_FILE_PATH}.*missing value/mi)
13
- end
14
-
15
-
16
- it "contains an error details, even when we delay the failing" do
17
- FailFast(SIMPLE_FILE_PATH).check_now.but_fail_later { has_value_for :unknown_key }
18
- $stdout.string.should match(/error.*#{SIMPLE_FILE_PATH}.*missing value/mi)
19
- $stdout.string.should match(/error.*#{SIMPLE_FILE_PATH}.*unknown_key/mi)
20
- end
21
-
22
- it "contains all errors details, in the right order, when they appear in 2 separate blocks" do
23
- FailFast(EMPTY_FILE_PATH ).check_now.but_fail_later { has_value_for :unknown_key_1 }
24
- FailFast(SIMPLE_FILE_PATH).check_now.but_fail_later { has_value_for :unknown_key_2 }
25
-
26
- $stdout.string.should match(/error.*#{EMPTY_FILE_PATH }.*unknown_key_1.*#{SIMPLE_FILE_PATH}.*unknown_key_2/m)
27
- end
28
-
29
- end