solid_use_case 1.0.1 → 1.0.2

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: a75fb4eab33c1942ba1b3d2f5af8450ad6b9d7a8
4
- data.tar.gz: 18303c9f6d0f0caf2d874e17175888f62947932e
3
+ metadata.gz: fc73aaa654b2bb9094f89bdc59eadb2c6e6850ad
4
+ data.tar.gz: daf146af027dca257b571f6ee43487a1a30343cd
5
5
  SHA512:
6
- metadata.gz: c482f81c0e82b031533dfe3252c51229971882037b20bec61af68a5631335946c62f85c75783fa655503c87261a51296c7a22ce93afe6ad53be60f2023f375ae
7
- data.tar.gz: 33d6162f7d0457934309fefc1c2704a0442681c3bf7b87d371df4fe002ee145ccc82a56bcf9596882ceb4a64da825c657dc612afacfcab99bc0cb592a88a71fe
6
+ metadata.gz: a18e3f021309842f666d8c8ee25d95468aa68c23d8c8d0bae297dbbe0a0868a125f23c436c7207ad3536b4aa1bfe645b51fa50069d246628f9eaa4e1f9b74fde
7
+ data.tar.gz: cfca654335a96807e4e95351981643a6e0a1dff902a604fadda53905b85da1c52a3e955981700a11344400499d6d25524f1eb34b688fce5d299c23481cc48d35
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'solid_use_case', '~> 1.0.1'
9
+ gem 'solid_use_case', '~> 1.0.2'
10
10
 
11
11
  And then execute:
12
12
 
@@ -16,7 +16,19 @@ module SolidUseCase
16
16
  end
17
17
 
18
18
  def failure_message_for_should
19
- "expected result to be a success\nError & Data:\n #{@result.value.type} - #{@result.value.inspect}"
19
+ "expected result to be a success\n" +
20
+ if @result.value.is_a? SolidUseCase::ErrorStruct
21
+ "Error & Data:\n #{@result.value.type} - #{@result.value.inspect}"
22
+ elsif @result.value.is_a? Exception
23
+ backtrace = @result.value.backtrace.reject do |file|
24
+ file =~ %r{deterministic/either/attempt_all.rb|deterministic/core_ext/either.rb}
25
+ end.take_while do |file|
26
+ file.match(%r{rspec-core-[^/]+/lib/rspec/core/example\.rb}).nil?
27
+ end
28
+ "Raised Error:\n #{@result.value.message}\n\t#{backtrace.join "\n\t"}"
29
+ else
30
+ "Error: #{@result.value.inspect}"
31
+ end
20
32
  end
21
33
 
22
34
  def failure_message_for_should_not
@@ -1,3 +1,3 @@
1
1
  module SolidUseCase
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -15,6 +15,18 @@ describe 'Custom RSpec Matchers' do
15
15
  end
16
16
  end
17
17
 
18
+ class ExceptionCase < SolidUseCase::Command
19
+ def run(val)
20
+ attempt_all do
21
+ try { raise_exception }
22
+ end
23
+ end
24
+
25
+ def raise_exception
26
+ raise NoMethodError.new 'oops'
27
+ end
28
+ end
29
+
18
30
  describe '#fail_with' do
19
31
 
20
32
  it "matches error messages" do
@@ -28,4 +40,20 @@ describe 'Custom RSpec Matchers' do
28
40
  expect(matcher.matches? SuccessCase.run).to eq(false)
29
41
  end
30
42
  end
43
+
44
+ describe 'exception handling' do
45
+ it "provides a proper error message for exceptions" do
46
+ matcher = be_a_success
47
+ expect(matcher.matches? ExceptionCase.run).to eq(false)
48
+
49
+ expect(matcher.failure_message_for_should).to include('oops')
50
+ expect(matcher.failure_message_for_should).to_not include(
51
+ 'deterministic/either/attempt_all.rb',
52
+ 'deterministic/core_ext/either.rb',
53
+ 'lib/rspec/core/example.rb'
54
+ )
55
+ # Useful for seeing the backtrace output yourself
56
+ # expect(ExceptionCase.run).to be_a_success
57
+ end
58
+ end
31
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_use_case
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deterministic