lib/lopata/condition.rb in lopata-0.1.22 vs lib/lopata/condition.rb in lopata-0.1.23
- old
+ new
@@ -1,16 +1,21 @@
module Lopata
# @private
class Condition
- attr_reader :condition, :positive
+ attr_reader :condition, :positive, :dynamic
def initialize(condition, positive: true)
@condition, @positive = condition, positive
+ @dynamic = @condition.is_a?(Proc)
end
alias positive? positive
+ alias dynamic? dynamic
+ # Match scenario on build-time.
def match?(scenario)
+ # dynamic steps match scenario in build-time: will be verified later
+ return true if dynamic?
matched = match_metadata?(scenario)
positive? ? matched : !matched
end
def match_metadata?(scenario)
@@ -31,7 +36,12 @@
else
metadata[condition]
end
end
+ def match_dynamic?(scenario_runtime)
+ return false unless dynamic?
+ matched = scenario_runtime.instance_exec(&condition)
+ positive? ? matched : !matched
+ end
end
end
\ No newline at end of file