lopata 0.1.13 → 0.1.17
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 +4 -4
- data/README.md +25 -25
- data/exe/lopata +11 -11
- data/lib/lopata/active_record.rb +135 -135
- data/lib/lopata/condition.rb +30 -30
- data/lib/lopata/configuration.rb +125 -125
- data/lib/lopata/environment.rb +35 -35
- data/lib/lopata/factory_bot.rb +72 -72
- data/lib/lopata/generators/app.rb +42 -42
- data/lib/lopata/generators/templates/Gemfile +7 -7
- data/lib/lopata/generators/templates/Lopatafile +20 -20
- data/lib/lopata/generators/templates/config/environments/qa.yml +7 -7
- data/lib/lopata/generators/templates/config/initializers/capybara.rb +1 -1
- data/lib/lopata/id.rb +22 -22
- data/lib/lopata/loader.rb +31 -31
- data/lib/lopata/observers/backtrace_formatter.rb +103 -103
- data/lib/lopata/observers/base_observer.rb +33 -33
- data/lib/lopata/observers/console_output_observer.rb +100 -100
- data/lib/lopata/observers/web_logger.rb +130 -130
- data/lib/lopata/observers.rb +4 -4
- data/lib/lopata/role.rb +109 -109
- data/lib/lopata/runner.rb +80 -67
- data/lib/lopata/scenario.rb +136 -136
- data/lib/lopata/scenario_builder.rb +497 -497
- data/lib/lopata/shared_step.rb +38 -38
- data/lib/lopata/step.rb +191 -191
- data/lib/lopata/version.rb +6 -6
- data/lib/lopata/world.rb +24 -24
- data/lib/lopata.rb +123 -74
- metadata +4 -4
data/lib/lopata/scenario.rb
CHANGED
@@ -1,136 +1,136 @@
|
|
1
|
-
require 'rspec/expectations'
|
2
|
-
|
3
|
-
# Scenario runtime class.
|
4
|
-
#
|
5
|
-
# All the scenarios are running in context of separate Lopata::Scenario object.
|
6
|
-
#
|
7
|
-
class Lopata::Scenario
|
8
|
-
include RSpec::Matchers
|
9
|
-
|
10
|
-
# @private
|
11
|
-
attr_reader :execution
|
12
|
-
|
13
|
-
# @private
|
14
|
-
def initialize(execution)
|
15
|
-
@execution = execution
|
16
|
-
end
|
17
|
-
|
18
|
-
# Marks current step as pending
|
19
|
-
# @example
|
20
|
-
# it 'pending step' do
|
21
|
-
# pending
|
22
|
-
# expect(1).to eq 2
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# Pending steps wont be failed
|
26
|
-
def pending(message = nil)
|
27
|
-
execution.current_step.pending!(message)
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [Hash] metadata available for current step
|
31
|
-
# @note The metadata keys also availalbe as methods (via method_missing)
|
32
|
-
def metadata
|
33
|
-
execution.metadata
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
# @private
|
39
|
-
def method_missing(method, *args, &block)
|
40
|
-
if execution.let_methods.include?(method)
|
41
|
-
instance_exec(*args, &execution.let_methods[method])
|
42
|
-
elsif metadata.keys.include?(method)
|
43
|
-
metadata[method]
|
44
|
-
else
|
45
|
-
super
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# @private
|
50
|
-
def respond_to_missing?(method, *)
|
51
|
-
execution.let_methods.include?(method) or metadata.keys.include?(method) or super
|
52
|
-
end
|
53
|
-
|
54
|
-
# @private
|
55
|
-
# Scenario execution and live-cycle information
|
56
|
-
class Execution
|
57
|
-
attr_reader :scenario, :status, :steps, :title, :current_step
|
58
|
-
|
59
|
-
def initialize(title, options_title, metadata = {})
|
60
|
-
@title = [title, options_title].compact.reject(&:empty?).join(' ')
|
61
|
-
@metadata = metadata
|
62
|
-
@let_methods = {}
|
63
|
-
@status = :not_runned
|
64
|
-
@steps = []
|
65
|
-
@scenario = Lopata::Scenario.new(self)
|
66
|
-
end
|
67
|
-
|
68
|
-
def run
|
69
|
-
@status = :running
|
70
|
-
sort_steps
|
71
|
-
world.notify_observers(:scenario_started, self)
|
72
|
-
steps.each(&method(:run_step))
|
73
|
-
@status = steps.any?(&:failed?) ? :failed : :passed
|
74
|
-
world.notify_observers(:scenario_finished, self)
|
75
|
-
cleanup
|
76
|
-
end
|
77
|
-
|
78
|
-
def run_step(step)
|
79
|
-
return if step.skipped?
|
80
|
-
@current_step = step
|
81
|
-
step.run(scenario)
|
82
|
-
skip_rest if step.failed? && step.skip_rest_on_failure?
|
83
|
-
@current_step = nil
|
84
|
-
end
|
85
|
-
|
86
|
-
def world
|
87
|
-
Lopata.world
|
88
|
-
end
|
89
|
-
|
90
|
-
def failed?
|
91
|
-
status == :failed
|
92
|
-
end
|
93
|
-
|
94
|
-
def sort_steps
|
95
|
-
@steps = steps.reject(&:teardown_group?) + steps.select(&:teardown_group?)
|
96
|
-
end
|
97
|
-
|
98
|
-
def skip_rest
|
99
|
-
steps.select { |s| s.status == :not_runned && !s.teardown? }.each(&:skip!)
|
100
|
-
end
|
101
|
-
|
102
|
-
def metadata
|
103
|
-
if current_step
|
104
|
-
@metadata.merge(current_step.metadata)
|
105
|
-
else
|
106
|
-
@metadata
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def let_methods
|
111
|
-
if current_step
|
112
|
-
@let_methods.merge(current_step.let_methods)
|
113
|
-
else
|
114
|
-
@let_methods
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def let(method_name, &block)
|
119
|
-
# define_singleton_method method_name, &block
|
120
|
-
base =
|
121
|
-
if current_step && !current_step.groups.empty?
|
122
|
-
current_step.groups.last.let_methods
|
123
|
-
else
|
124
|
-
@let_methods
|
125
|
-
end
|
126
|
-
base[method_name] = block
|
127
|
-
end
|
128
|
-
|
129
|
-
def cleanup
|
130
|
-
@title = nil
|
131
|
-
@metadata = nil
|
132
|
-
@steps = nil
|
133
|
-
@scenario = nil
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
1
|
+
require 'rspec/expectations'
|
2
|
+
|
3
|
+
# Scenario runtime class.
|
4
|
+
#
|
5
|
+
# All the scenarios are running in context of separate Lopata::Scenario object.
|
6
|
+
#
|
7
|
+
class Lopata::Scenario
|
8
|
+
include RSpec::Matchers
|
9
|
+
|
10
|
+
# @private
|
11
|
+
attr_reader :execution
|
12
|
+
|
13
|
+
# @private
|
14
|
+
def initialize(execution)
|
15
|
+
@execution = execution
|
16
|
+
end
|
17
|
+
|
18
|
+
# Marks current step as pending
|
19
|
+
# @example
|
20
|
+
# it 'pending step' do
|
21
|
+
# pending
|
22
|
+
# expect(1).to eq 2
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# Pending steps wont be failed
|
26
|
+
def pending(message = nil)
|
27
|
+
execution.current_step.pending!(message)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Hash] metadata available for current step
|
31
|
+
# @note The metadata keys also availalbe as methods (via method_missing)
|
32
|
+
def metadata
|
33
|
+
execution.metadata
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# @private
|
39
|
+
def method_missing(method, *args, &block)
|
40
|
+
if execution.let_methods.include?(method)
|
41
|
+
instance_exec(*args, &execution.let_methods[method])
|
42
|
+
elsif metadata.keys.include?(method)
|
43
|
+
metadata[method]
|
44
|
+
else
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# @private
|
50
|
+
def respond_to_missing?(method, *)
|
51
|
+
execution.let_methods.include?(method) or metadata.keys.include?(method) or super
|
52
|
+
end
|
53
|
+
|
54
|
+
# @private
|
55
|
+
# Scenario execution and live-cycle information
|
56
|
+
class Execution
|
57
|
+
attr_reader :scenario, :status, :steps, :title, :current_step
|
58
|
+
|
59
|
+
def initialize(title, options_title, metadata = {})
|
60
|
+
@title = [title, options_title].compact.reject(&:empty?).join(' ')
|
61
|
+
@metadata = metadata
|
62
|
+
@let_methods = {}
|
63
|
+
@status = :not_runned
|
64
|
+
@steps = []
|
65
|
+
@scenario = Lopata::Scenario.new(self)
|
66
|
+
end
|
67
|
+
|
68
|
+
def run
|
69
|
+
@status = :running
|
70
|
+
sort_steps
|
71
|
+
world.notify_observers(:scenario_started, self)
|
72
|
+
steps.each(&method(:run_step))
|
73
|
+
@status = steps.any?(&:failed?) ? :failed : :passed
|
74
|
+
world.notify_observers(:scenario_finished, self)
|
75
|
+
cleanup
|
76
|
+
end
|
77
|
+
|
78
|
+
def run_step(step)
|
79
|
+
return if step.skipped?
|
80
|
+
@current_step = step
|
81
|
+
step.run(scenario)
|
82
|
+
skip_rest if step.failed? && step.skip_rest_on_failure?
|
83
|
+
@current_step = nil
|
84
|
+
end
|
85
|
+
|
86
|
+
def world
|
87
|
+
Lopata.world
|
88
|
+
end
|
89
|
+
|
90
|
+
def failed?
|
91
|
+
status == :failed
|
92
|
+
end
|
93
|
+
|
94
|
+
def sort_steps
|
95
|
+
@steps = steps.reject(&:teardown_group?) + steps.select(&:teardown_group?)
|
96
|
+
end
|
97
|
+
|
98
|
+
def skip_rest
|
99
|
+
steps.select { |s| s.status == :not_runned && !s.teardown? }.each(&:skip!)
|
100
|
+
end
|
101
|
+
|
102
|
+
def metadata
|
103
|
+
if current_step
|
104
|
+
@metadata.merge(current_step.metadata)
|
105
|
+
else
|
106
|
+
@metadata
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def let_methods
|
111
|
+
if current_step
|
112
|
+
@let_methods.merge(current_step.let_methods)
|
113
|
+
else
|
114
|
+
@let_methods
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def let(method_name, &block)
|
119
|
+
# define_singleton_method method_name, &block
|
120
|
+
base =
|
121
|
+
if current_step && !current_step.groups.empty?
|
122
|
+
current_step.groups.last.let_methods
|
123
|
+
else
|
124
|
+
@let_methods
|
125
|
+
end
|
126
|
+
base[method_name] = block
|
127
|
+
end
|
128
|
+
|
129
|
+
def cleanup
|
130
|
+
@title = nil
|
131
|
+
@metadata = nil
|
132
|
+
@steps = nil
|
133
|
+
@scenario = nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|