use_case 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,7 +84,7 @@ module UseCase
84
84
 
85
85
  def when(symbol, &block)
86
86
  raise Exception.new("Cannot call when after otherwise") if @otherwise
87
- if symbol == class_symbol
87
+ if symbol == self.symbol
88
88
  @called = true
89
89
  yield(@pre_condition)
90
90
  end
@@ -95,8 +95,7 @@ module UseCase
95
95
  yield(@pre_condition) if !@called
96
96
  end
97
97
 
98
- private
99
- def class_symbol
98
+ def symbol
100
99
  klass = @pre_condition.class
101
100
  return klass.symbol if klass.respond_to?(:symbol)
102
101
  klass.name.gsub(/([^A-Z])([A-Z])/, '\1_\2').gsub(/[:_]+/, "_").downcase.to_sym
@@ -24,5 +24,5 @@
24
24
  #++
25
25
 
26
26
  module UseCase
27
- VERSION = "0.9.1"
27
+ VERSION = "0.10.0"
28
28
  end
@@ -166,6 +166,18 @@ describe UseCase::Outcome do
166
166
  end
167
167
  end
168
168
  end
169
+
170
+ it "accesses pre-condition symbol" do
171
+ pre_condition = MyPreCondition.new
172
+ outcome = UseCase::PreConditionFailed.new(nil, pre_condition)
173
+ failure = nil
174
+
175
+ outcome.pre_condition_failed do |f|
176
+ failure = f
177
+ end
178
+
179
+ assert_equal :something, failure.symbol
180
+ end
169
181
  end
170
182
  end
171
183
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: use_case
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: