solid_use_case 1.0.1 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/solid_use_case/rspec_matchers.rb +13 -1
- data/lib/solid_use_case/version.rb +1 -1
- data/spec/rspec_matchers_spec.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc73aaa654b2bb9094f89bdc59eadb2c6e6850ad
|
4
|
+
data.tar.gz: daf146af027dca257b571f6ee43487a1a30343cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a18e3f021309842f666d8c8ee25d95468aa68c23d8c8d0bae297dbbe0a0868a125f23c436c7207ad3536b4aa1bfe645b51fa50069d246628f9eaa4e1f9b74fde
|
7
|
+
data.tar.gz: cfca654335a96807e4e95351981643a6e0a1dff902a604fadda53905b85da1c52a3e955981700a11344400499d6d25524f1eb34b688fce5d299c23481cc48d35
|
data/README.md
CHANGED
@@ -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\
|
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
|
data/spec/rspec_matchers_spec.rb
CHANGED
@@ -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.
|
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
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deterministic
|