lopata 0.1.22 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 594efeb814131537b5efdcd66d912bf4557038f47a85e3fad0fb9b17408586fb
4
- data.tar.gz: a63860ec22996bd77f569ad3e85060b208eefc392ec79f6e5d3be7dc56ac7418
3
+ metadata.gz: 54faa8989dbb2e3f1750b060fe05982116ba534a50e6be067d267d0bb7849fc9
4
+ data.tar.gz: 4b49ac34fa702f1784f4e23fde2d7da205474619c7ac6190cb0ce73fab1f9520
5
5
  SHA512:
6
- metadata.gz: 110b59071e44955f890c8df68c6cc1d5180b968d8c93556ddae4a3da29fe253951f9650a36dc7f5dc38ad04e9bbd9e770100332597512c267ae387cfca7b82f0
7
- data.tar.gz: f2300be4be7155921fdf1972fd5bc98832daccc3707d80c8f93d51fe806a130914349f978931c09317f629acc57561b564955a07521a66139234229e6b9a7bdc
6
+ metadata.gz: 5fb1d7e3ca67d547272e868cddbaa68e7c8ec6c2cc03c617e0e81cd3d6607fca1d914a11d0834fd0eeb259b36ccd80bc4b3e787fdb153abd94a86316f7315482
7
+ data.tar.gz: 4ce12c440f2e757f94863d9769a2b2532680d50942d24979ef5b6a49fb9cbb68647f388ca3ab648767a04683cce05484421bd2d2c550e758eaf8e85c353e0433
@@ -1,14 +1,19 @@
1
1
  module Lopata
2
2
  # @private
3
3
  class Condition
4
- attr_reader :condition, :positive
4
+ attr_reader :condition, :positive, :dynamic
5
5
  def initialize(condition, positive: true)
6
6
  @condition, @positive = condition, positive
7
+ @dynamic = @condition.is_a?(Proc)
7
8
  end
8
9
 
9
10
  alias positive? positive
11
+ alias dynamic? dynamic
10
12
 
13
+ # Match scenario on build-time.
11
14
  def match?(scenario)
15
+ # dynamic steps match scenario in build-time: will be verified later
16
+ return true if dynamic?
12
17
  matched = match_metadata?(scenario)
13
18
  positive? ? matched : !matched
14
19
  end
@@ -33,5 +38,10 @@ module Lopata
33
38
  end
34
39
  end
35
40
 
41
+ def match_dynamic?(scenario_runtime)
42
+ return false unless dynamic?
43
+ matched = scenario_runtime.instance_exec(&condition)
44
+ positive? ? matched : !matched
45
+ end
36
46
  end
37
47
  end
@@ -90,7 +90,17 @@ class Lopata::Scenario
90
90
  end
91
91
 
92
92
  def run_step(step)
93
- return if step.skipped?
93
+ return if step.skipped? || step.ignored?
94
+ groups = step.groups
95
+ if groups.length > 0 && groups != @current_groups
96
+ @current_groups = groups
97
+ condition = groups.last.condition
98
+ if condition&.dynamic? && !condition.match_dynamic?(scenario)
99
+ step.ignored!
100
+ ignore_groups(groups)
101
+ return
102
+ end
103
+ end
94
104
  @current_step = step
95
105
  step.run(scenario)
96
106
  skip_rest if step.failed? && step.skip_rest_on_failure?
@@ -113,6 +123,10 @@ class Lopata::Scenario
113
123
  steps.select { |s| s.status == :not_runned && !s.teardown? }.each(&:skip!)
114
124
  end
115
125
 
126
+ def ignore_groups(groups)
127
+ steps.select { _1.status == :not_runned && _1.groups.take(groups.length) == groups }.each(&:ignored!)
128
+ end
129
+
116
130
  def metadata
117
131
  if current_step
118
132
  @metadata.merge(current_step.metadata)
data/lib/lopata/step.rb CHANGED
@@ -25,7 +25,7 @@ module Lopata
25
25
  def execution_steps(scenario, groups: [])
26
26
  return [] if condition && !condition.match?(scenario)
27
27
  return [] unless block
28
- [StepExecution.new(self, groups, &block)]
28
+ [StepExecution.new(self, groups, condition: condition, &block)]
29
29
  end
30
30
  end
31
31
 
@@ -42,10 +42,10 @@ module Lopata
42
42
  steps += shared_step.execution_steps(scenario, groups: groups)
43
43
  end
44
44
  elsif step.is_a?(Proc)
45
- steps << StepExecution.new(self, groups, &step)
45
+ steps << StepExecution.new(self, groups, condition: condition, &step)
46
46
  end
47
47
  end
48
- steps << StepExecution.new(self, groups, &block) if block
48
+ steps << StepExecution.new(self, groups, condition: condition, &block) if block
49
49
  steps.reject { |s| !s.block }
50
50
  end
51
51
 
@@ -105,18 +105,19 @@ module Lopata
105
105
 
106
106
  #@private
107
107
  class StepExecution
108
- attr_reader :step, :status, :exception, :block, :pending_message, :groups
108
+ attr_reader :step, :status, :exception, :block, :pending_message, :groups, :condition
109
109
  extend Forwardable
110
110
  def_delegators :step, :method_name
111
111
 
112
112
  class PendingStepFixedError < StandardError; end
113
113
 
114
- def initialize(step, groups, &block)
114
+ def initialize(step, groups, condition: nil, &block)
115
115
  @step = step
116
116
  @status = :not_runned
117
117
  @exception = nil
118
118
  @block = block
119
119
  @groups = groups
120
+ @condition = condition
120
121
  end
121
122
 
122
123
  def title
@@ -130,6 +131,10 @@ module Lopata
130
131
  def run(scenario)
131
132
  @status = :running
132
133
  begin
134
+ unless check_dynamic_condition?(scenario)
135
+ @status = :ignored
136
+ return
137
+ end
133
138
  run_step(scenario)
134
139
  if pending?
135
140
  @status = :failed
@@ -148,6 +153,22 @@ module Lopata
148
153
  scenario.instance_exec(&block)
149
154
  end
150
155
 
156
+ def check_dynamic_condition?(scenario)
157
+ dynamic_conditions.each do
158
+ return false unless _1.match_dynamic?(scenario)
159
+ end
160
+ true
161
+ end
162
+
163
+ def dynamic_conditions
164
+ conds = []
165
+ conds << condition if condition&.dynamic?
166
+ groups.each do
167
+ conds << _1.condition if _1.condition&.dynamic?
168
+ end
169
+ conds
170
+ end
171
+
151
172
  def failed?
152
173
  status == :failed
153
174
  end
@@ -160,6 +181,14 @@ module Lopata
160
181
  status == :skipped
161
182
  end
162
183
 
184
+ def ignored?
185
+ status == :ignored
186
+ end
187
+
188
+ def ignored!
189
+ status == :ignored
190
+ end
191
+
163
192
  def skip!
164
193
  @status = :skipped
165
194
  end
@@ -175,6 +204,7 @@ module Lopata
175
204
 
176
205
  # Need log this step.
177
206
  def loggable?
207
+ return false if ignored?
178
208
  not %i{ let let! }.include?(method_name)
179
209
  end
180
210
 
@@ -186,6 +216,10 @@ module Lopata
186
216
  teardown? && self.groups.last == group
187
217
  end
188
218
 
219
+ def in_group?(group)
220
+ groups.include?(group)
221
+ end
222
+
189
223
  def skip_rest_on_failure?
190
224
  %i{ setup action }.include?(method_name)
191
225
  end
@@ -1,6 +1,6 @@
1
1
  module Lopata
2
2
  # @private
3
3
  module Version
4
- STRING = '0.1.22'
4
+ STRING = '0.1.24'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lopata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Volochnev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-18 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -139,5 +139,5 @@ requirements: []
139
139
  rubygems_version: 3.2.15
140
140
  signing_key:
141
141
  specification_version: 4
142
- summary: lopata-0.1.22
142
+ summary: lopata-0.1.24
143
143
  test_files: []