caze 0.2.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43eeb61fade546b7defd563a4213927a4c2259e2
4
- data.tar.gz: 77a3de82def4f7d885ff4f1195e24841f5887ccb
3
+ metadata.gz: 3b2bb9ec264807b18d2af5846a4c66316f2f1854
4
+ data.tar.gz: b4f5fff37ac8572f2d80c1ea2e7132f1fa625823
5
5
  SHA512:
6
- metadata.gz: b61f32601639b4bec51770350468c58f49740327d2df99bf8d7b9ca9700cd4585a2952c864a8d449b4d0a4e73f2fdbe7e05aaf46c38f4d8544ac6785cc770648
7
- data.tar.gz: e38452d8574ed90ad1a8a94c9adc63ad9af91f3b69c832ea0dd7ca0fffb1bb403b8ebc1a91eb387a5a128eeba4070414647ac8ca44ff3e9b654a1bf5248cb76c
6
+ metadata.gz: a93472e3a66c94d6b22437c1db6d0c818336f1eedf57974ed664b1dc18ae469e3851b42dfabfbfab895362f36e655f345d27dd5855eb9967ec69fa43f82bf5ee
7
+ data.tar.gz: 2af9f0ed062310c5f61352837197012b64552569e24103d64bbb19d4d9724cebcae54537cd11bcee6f512f541c4a3fb2060e07a001e74f017520c353abdc99cd
@@ -1,5 +1,11 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  rvm:
3
- - 2.0.0
4
- - 2.1.0
5
- - 2.2.2
5
+ - 2.3.6
6
+ - 2.4.3
7
+ - ruby-head
8
+
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## Unreleased
7
+
8
+ ## [0.2.1] - 2017-12-19
9
+
10
+ - Fixed how the exceptions constants are created when `raise_use_case_exception`
11
+ is on. The exceptions will inherit from `StandardError`, live under the
12
+ use case constant and won't throw any already initialized constant warnings.
13
+
6
14
  ## [0.2.1] - 2016-02-29
7
15
 
8
16
  ### Change
@@ -30,6 +30,8 @@ module Caze
30
30
  else
31
31
  use_case.send(use_case_name, *args)
32
32
  end
33
+ rescue NoTransactionMethodError
34
+ raise
33
35
  rescue => e
34
36
  if raise_use_case_exception
35
37
  raise raise_use_case_error(use_case, e)
@@ -62,17 +64,21 @@ module Caze
62
64
  # This method intends to inject the error inside the context of the use case,
63
65
  # so we can identify the use case from it was raised
64
66
  def raise_use_case_error(use_case, error)
65
- demodulized_error_class = error.class.name.split('::').last
67
+ name = error.class.name.split('::').last
66
68
 
67
- base_class = Class.new(error.class)
69
+ klass = define_use_case_error(use_case, name)
70
+ wrapped = klass.new(error.message)
71
+ wrapped.set_backtrace(error.backtrace)
68
72
 
69
- error_class = use_case.const_set(demodulized_error_class, base_class)
73
+ raise wrapped
74
+ end
70
75
 
71
- error.define_singleton_method(:class) do
72
- error_class
76
+ def define_use_case_error(use_case, name)
77
+ unless use_case.const_defined?(name, false)
78
+ klass = Class.new(StandardError)
79
+ use_case.const_set(name, klass)
73
80
  end
74
-
75
- raise error
81
+ use_case.const_get(name)
76
82
  end
77
83
  end
78
84
  end
@@ -1,3 +1,3 @@
1
1
  module Caze
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -140,7 +140,11 @@ describe Caze do
140
140
  it 'raises with the namespace of the use case' do
141
141
  expect {
142
142
  namespaced_use_case.the_question
143
- }.to raise_error(DummyUseCaseTest::DummyError)
143
+ }.to raise_error do |error|
144
+ expect(error).to be_a(DummyUseCaseTest::DummyError)
145
+ expect(error.cause).to be_a(::DummyError)
146
+ expect(error.backtrace.first).to match(/in `the_question'/)
147
+ end
144
148
  end
145
149
  end
146
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Sampaio
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-29 00:00:00.000000000 Z
12
+ date: 2017-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.4.5.1
124
+ rubygems_version: 2.6.10
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: A DSL to define use cases