enhanced_errors 2.0.6 → 2.1.1

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.
@@ -0,0 +1,22 @@
1
+ require 'minitest/autorun'
2
+ require 'enhanced_errors'
3
+ require 'enhanced/minitest_patch'
4
+
5
+ # You must install minitest and load it first to run this demo.
6
+ # EnhancedErrors does NOT ship with minitest as a dependency.
7
+
8
+ class MagicBallTest < Minitest::Test
9
+ def setup
10
+ @foo = 'bar'
11
+ end
12
+
13
+ def test_boo_capture
14
+ bee = 'fee'
15
+ assert false
16
+ end
17
+
18
+ def test_i_raise
19
+ zoo = 'zee'
20
+ raise "Crud"
21
+ end
22
+ end
@@ -0,0 +1,56 @@
1
+ # spec/enhanced_errors_spec.rb
2
+
3
+ # INSTRUCTIONS: Install rspec
4
+ # gem install rspec
5
+ # rspec examples/example_spec.rb
6
+
7
+ require 'rspec'
8
+ require_relative '../lib/enhanced_errors'
9
+
10
+ RSpec.configure do |config|
11
+
12
+ # -- Add to your RSPec config in your spec_helper.
13
+ config.before(:example) do |_example|
14
+ EnhancedErrors.start_rspec_binding_capture
15
+ end
16
+
17
+ config.before(:example) do |_example|
18
+ EnhancedErrors.start_rspec_binding_capture
19
+ end
20
+
21
+ config.after(:example) do |example|
22
+ EnhancedErrors.override_rspec_message(example, EnhancedErrors.stop_rspec_binding_capture)
23
+ end
24
+ # -- End EnhancedErrors config
25
+
26
+ end
27
+
28
+
29
+ RSpec.describe 'Neo' do
30
+ describe 'sees through' do
31
+ let(:the_matrix) { 'code rains, dramatically' }
32
+
33
+ before(:each) do
34
+ @spoon = 'there is no spoon'
35
+ end
36
+
37
+ it 'the matrix' do
38
+ #activate memoized item
39
+ the_matrix
40
+ stop = 'bullets'
41
+ raise 'No!'
42
+ end
43
+
44
+ it "dodges multiple exception-bullets at once" do
45
+ foo = 'bar'
46
+ expect(1).to eq(2)
47
+ expect(true).to eq(false)
48
+ end
49
+
50
+ after(:each) do
51
+ raise "This is another error"
52
+ end
53
+
54
+ end
55
+ end
56
+
@@ -0,0 +1,17 @@
1
+ module Minitest
2
+ class << self
3
+ alias_method :original_run_one_method, :run_one_method
4
+
5
+ def run_one_method(klass, method_name)
6
+ EnhancedErrors.start_minitest_binding_capture
7
+ result = original_run_one_method(klass, method_name)
8
+ ensure
9
+ begin
10
+ binding_infos = EnhancedErrors.stop_minitest_binding_capture
11
+ EnhancedErrors.override_exception_message(result.failures.last, binding_infos) if result.failures.any?
12
+ rescue => e
13
+ puts "Ignored error during error enhancement: #{e}"
14
+ end
15
+ end
16
+ end
17
+ end