use_case 0.9.1 → 0.10.0
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.
- data/lib/use_case/outcome.rb +2 -3
- data/lib/use_case/version.rb +1 -1
- data/test/use_case/outcome_test.rb +12 -0
- metadata +1 -1
data/lib/use_case/outcome.rb
CHANGED
@@ -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 ==
|
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
|
-
|
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
|
data/lib/use_case/version.rb
CHANGED
@@ -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
|
|