lucid 0.0.6 → 0.0.7
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/HISTORY.md +13 -0
- data/lib/lucid/ast.rb +1 -0
- data/lib/lucid/ast/background.rb +11 -8
- data/lib/lucid/ast/comment.rb +6 -2
- data/lib/lucid/ast/examples.rb +8 -4
- data/lib/lucid/ast/feature.rb +9 -6
- data/lib/lucid/ast/outline_table.rb +21 -35
- data/lib/lucid/ast/scenario.rb +11 -7
- data/lib/lucid/ast/scenario_outline.rb +16 -13
- data/lib/lucid/ast/specs.rb +9 -4
- data/lib/lucid/ast/step.rb +7 -2
- data/lib/lucid/ast/step_collection.rb +6 -2
- data/lib/lucid/ast/step_invocation.rb +46 -15
- data/lib/lucid/ast/step_result.rb +34 -0
- data/lib/lucid/ast/table.rb +9 -4
- data/lib/lucid/ast/tags.rb +4 -2
- data/lib/lucid/ast/tdl_walker.rb +99 -104
- data/lib/lucid/cli/app.rb +1 -1
- data/lib/lucid/cli/configuration.rb +19 -41
- data/lib/lucid/cli/options.rb +18 -11
- data/lib/lucid/formatter/gherkin_formatter_adapter.rb +5 -4
- data/lib/lucid/formatter/html.rb +12 -12
- data/lib/lucid/formatter/progress.rb +3 -3
- data/lib/lucid/formatter/standard.rb +6 -6
- data/lib/lucid/formatter/{stepdefs.rb → testdefs.rb} +1 -1
- data/lib/lucid/formatter/usage.rb +6 -6
- data/lib/lucid/interface_rb/rb_world.rb +0 -6
- data/lib/lucid/platform.rb +1 -1
- data/lib/lucid/runtime.rb +5 -5
- metadata +6 -5
@@ -0,0 +1,34 @@
|
|
1
|
+
module Lucid
|
2
|
+
module AST
|
3
|
+
class StepResult
|
4
|
+
attr_reader :keyword, :step_match, :exception, :status, :background
|
5
|
+
attr_reader :step_multiline_class, :file_colon_line
|
6
|
+
|
7
|
+
def initialize(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
|
8
|
+
@keyword, @step_match, @multiline_arg, @status, @exception, @source_indent, @background, @file_colon_line = keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line
|
9
|
+
end
|
10
|
+
|
11
|
+
def accept(visitor)
|
12
|
+
visitor.visit_step_name(@keyword, @step_match, @status, @source_indent, @background, @file_colon_line)
|
13
|
+
visitor.visit_multiline_arg(@multiline_arg) if @multiline_arg
|
14
|
+
visitor.visit_exception(@exception, @status) if @exception
|
15
|
+
end
|
16
|
+
|
17
|
+
def args
|
18
|
+
[@keyword, @step_match, @multiline_arg, @status, @exception, @source_indent, @background, @file_colon_line]
|
19
|
+
end
|
20
|
+
|
21
|
+
def step_name
|
22
|
+
@step_match.name
|
23
|
+
end
|
24
|
+
|
25
|
+
def step_definition
|
26
|
+
@step_match.step_definition
|
27
|
+
end
|
28
|
+
|
29
|
+
def step_arguments
|
30
|
+
@step_match.step_arguments
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/lucid/ast/table.rb
CHANGED
@@ -179,7 +179,7 @@ module Lucid
|
|
179
179
|
def accept(visitor) #:nodoc:
|
180
180
|
return if Lucid.wants_to_quit
|
181
181
|
cells_rows.each do |row|
|
182
|
-
|
182
|
+
row.accept(visitor)
|
183
183
|
end
|
184
184
|
nil
|
185
185
|
end
|
@@ -631,8 +631,10 @@ module Lucid
|
|
631
631
|
|
632
632
|
def accept(visitor)
|
633
633
|
return if Lucid.wants_to_quit
|
634
|
-
|
635
|
-
|
634
|
+
visitor.visit_table_row(self) do
|
635
|
+
each do |cell|
|
636
|
+
cell.accept(visitor)
|
637
|
+
end
|
636
638
|
end
|
637
639
|
nil
|
638
640
|
end
|
@@ -687,7 +689,10 @@ module Lucid
|
|
687
689
|
|
688
690
|
def accept(visitor)
|
689
691
|
return if Lucid.wants_to_quit
|
690
|
-
|
692
|
+
|
693
|
+
visitor.visit_table_cell(self) do
|
694
|
+
visitor.visit_table_cell_value(value, status)
|
695
|
+
end
|
691
696
|
end
|
692
697
|
|
693
698
|
def inspect!
|
data/lib/lucid/ast/tags.rb
CHANGED
data/lib/lucid/ast/tdl_walker.rb
CHANGED
@@ -11,7 +11,7 @@ module Lucid
|
|
11
11
|
def execute(scenario, skip_hooks)
|
12
12
|
runtime.with_hooks(scenario, skip_hooks) do
|
13
13
|
scenario.skip_invoke! if scenario.failed?
|
14
|
-
|
14
|
+
scenario.steps.accept(self)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,108 +20,100 @@ module Lucid
|
|
20
20
|
# are initially the same concept. When the spec is visited, the high
|
21
21
|
# level construct (feature, ability) is determined.
|
22
22
|
# @see Lucid::Runtime.run
|
23
|
-
def visit_features(features)
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
23
|
+
#def visit_features(features, &block)
|
24
|
+
# broadcast(features, &block)
|
25
|
+
#end
|
28
26
|
|
29
|
-
def visit_feature(feature)
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
27
|
+
#def visit_feature(feature, &block)
|
28
|
+
# broadcast(feature, &block)
|
29
|
+
#end
|
34
30
|
|
35
|
-
def visit_comment(comment)
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
31
|
+
#def visit_comment(comment, &block)
|
32
|
+
# broadcast(comment, &block)
|
33
|
+
#end
|
40
34
|
|
41
|
-
def visit_comment_line(comment_line)
|
42
|
-
|
43
|
-
end
|
35
|
+
#def visit_comment_line(comment_line)
|
36
|
+
# broadcast(comment_line)
|
37
|
+
#end
|
44
38
|
|
45
|
-
def visit_tags(tags)
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
39
|
+
#def visit_tags(tags, &block)
|
40
|
+
# broadcast(tags, &block)
|
41
|
+
#end
|
50
42
|
|
51
|
-
def visit_tag_name(tag_name)
|
52
|
-
|
53
|
-
end
|
43
|
+
#def visit_tag_name(tag_name)
|
44
|
+
# broadcast(tag_name)
|
45
|
+
#end
|
54
46
|
|
55
|
-
def visit_feature_name(keyword, name)
|
56
|
-
|
57
|
-
end
|
47
|
+
#def visit_feature_name(keyword, name)
|
48
|
+
# broadcast(keyword, name)
|
49
|
+
#end
|
58
50
|
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
51
|
+
# Note that a feature_element refers to either a Scenario or
|
52
|
+
# a ScenarioOutline.
|
53
|
+
#def visit_feature_element(feature_element, &block)
|
54
|
+
# broadcast(feature_element, &block)
|
55
|
+
#end
|
65
56
|
|
66
|
-
def visit_background(background)
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
57
|
+
#def visit_background(background, &block)
|
58
|
+
# broadcast(background, &block)
|
59
|
+
#end
|
71
60
|
|
72
|
-
def visit_background_name(keyword, name, file_colon_line, source_indent)
|
73
|
-
|
74
|
-
end
|
61
|
+
#def visit_background_name(keyword, name, file_colon_line, source_indent)
|
62
|
+
# broadcast(keyword, name, file_colon_line, source_indent)
|
63
|
+
#end
|
75
64
|
|
76
|
-
def visit_examples_array(examples_array)
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
65
|
+
#def visit_examples_array(examples_array, &block)
|
66
|
+
# broadcast(examples_array, &block)
|
67
|
+
#end
|
81
68
|
|
82
|
-
def visit_examples(examples)
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
69
|
+
#def visit_examples(examples, &block)
|
70
|
+
# broadcast(examples, &block)
|
71
|
+
#end
|
87
72
|
|
88
|
-
def visit_examples_name(keyword, name)
|
89
|
-
|
90
|
-
end
|
73
|
+
#def visit_examples_name(keyword, name)
|
74
|
+
# broadcast(keyword, name)
|
75
|
+
#end
|
91
76
|
|
92
|
-
def visit_outline_table(outline_table)
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
77
|
+
#def visit_outline_table(outline_table, &block)
|
78
|
+
# broadcast(outline_table, &block)
|
79
|
+
#end
|
97
80
|
|
98
|
-
def visit_scenario_name(keyword, name, file_colon_line, source_indent)
|
99
|
-
|
100
|
-
end
|
81
|
+
#def visit_scenario_name(keyword, name, file_colon_line, source_indent)
|
82
|
+
# broadcast(keyword, name, file_colon_line, source_indent)
|
83
|
+
#end
|
101
84
|
|
102
|
-
def visit_steps(steps)
|
103
|
-
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
85
|
+
#def visit_steps(steps, &block)
|
86
|
+
# broadcast(steps, &block)
|
87
|
+
#end
|
107
88
|
|
108
|
-
def visit_step(step)
|
109
|
-
|
110
|
-
|
111
|
-
|
89
|
+
#def visit_step(step, &block)
|
90
|
+
# broadcast(step, &block)
|
91
|
+
#end
|
92
|
+
|
93
|
+
# This is being used to forward on messages from the AST to
|
94
|
+
# the formatters. This is being done in lieu of the explicit
|
95
|
+
# forwarding that was previously done.
|
96
|
+
def method_missing(message, *args, &block)
|
97
|
+
broadcast_message(message, *args, &block)
|
112
98
|
end
|
113
99
|
|
114
|
-
def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
100
|
+
#def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
|
101
|
+
# broadcast(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) do
|
102
|
+
# visit_step_name(keyword, step_match, status, source_indent, background, file_colon_line)
|
103
|
+
# visit_multiline_arg(multiline_arg) if multiline_arg
|
104
|
+
# visit_exception(exception, status) if exception
|
105
|
+
# end
|
106
|
+
#end
|
107
|
+
|
108
|
+
def visit_step_result(step_result)
|
109
|
+
broadcast(step_result) do
|
110
|
+
step_result.accept(self)
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|
122
|
-
def visit_step_name(keyword, step_match, status, source_indent, background, file_colon_line) #:nodoc:
|
123
|
-
|
124
|
-
end
|
114
|
+
#def visit_step_name(keyword, step_match, status, source_indent, background, file_colon_line) #:nodoc:
|
115
|
+
# broadcast(keyword, step_match, status, source_indent, background, file_colon_line)
|
116
|
+
#end
|
125
117
|
|
126
118
|
def visit_multiline_arg(multiline_arg) #:nodoc:
|
127
119
|
broadcast(multiline_arg) do
|
@@ -129,29 +121,25 @@ module Lucid
|
|
129
121
|
end
|
130
122
|
end
|
131
123
|
|
132
|
-
def visit_exception(exception, status) #:nodoc:
|
133
|
-
|
134
|
-
end
|
124
|
+
#def visit_exception(exception, status) #:nodoc:
|
125
|
+
# broadcast(exception, status)
|
126
|
+
#end
|
135
127
|
|
136
|
-
def visit_doc_string(string)
|
137
|
-
|
138
|
-
end
|
128
|
+
#def visit_doc_string(string)
|
129
|
+
# broadcast(string)
|
130
|
+
#end
|
139
131
|
|
140
|
-
def visit_table_row(table_row)
|
141
|
-
|
142
|
-
|
143
|
-
end
|
144
|
-
end
|
132
|
+
#def visit_table_row(table_row, &block)
|
133
|
+
# broadcast(table_row, &block)
|
134
|
+
#end
|
145
135
|
|
146
|
-
def visit_table_cell(table_cell)
|
147
|
-
|
148
|
-
|
149
|
-
end
|
150
|
-
end
|
136
|
+
#def visit_table_cell(table_cell, &block)
|
137
|
+
# broadcast(table_cell, &block)
|
138
|
+
#end
|
151
139
|
|
152
|
-
def visit_table_cell_value(value, status)
|
153
|
-
|
154
|
-
end
|
140
|
+
#def visit_table_cell_value(value, status)
|
141
|
+
# broadcast(value, status)
|
142
|
+
#end
|
155
143
|
|
156
144
|
# Print +messages+. This method can be called from within StepDefinitions.
|
157
145
|
def puts(*messages)
|
@@ -167,8 +155,13 @@ module Lucid
|
|
167
155
|
private
|
168
156
|
|
169
157
|
def broadcast(*args, &block)
|
170
|
-
message = extract_method_name_from(caller)
|
171
|
-
message
|
158
|
+
message = extract_method_name_from(caller[0])
|
159
|
+
broadcast_message message, *args, &block
|
160
|
+
self
|
161
|
+
end
|
162
|
+
|
163
|
+
def broadcast_message(message, *args, &block)
|
164
|
+
message = message.to_s.gsub('visit_', '')
|
172
165
|
if block_given?
|
173
166
|
send_to_all("before_#{message}", *args)
|
174
167
|
yield if block_given?
|
@@ -187,7 +180,9 @@ module Lucid
|
|
187
180
|
end
|
188
181
|
end
|
189
182
|
def extract_method_name_from(call_stack)
|
190
|
-
call_stack[0].match(/in `(.*)'/).captures[0]
|
183
|
+
#call_stack[0].match(/in `(.*)'/).captures[0]
|
184
|
+
match = call_stack.match(/in `(.*)'/)
|
185
|
+
match.captures[0]
|
191
186
|
end
|
192
187
|
|
193
188
|
end
|
data/lib/lucid/cli/app.rb
CHANGED
@@ -34,7 +34,7 @@ module Lucid
|
|
34
34
|
log.debug("Runtime: #{runtime.inspect}")
|
35
35
|
|
36
36
|
runtime.run
|
37
|
-
runtime.
|
37
|
+
runtime.write_testdefs_json
|
38
38
|
failure = runtime.results.failure? || Lucid.wants_to_quit
|
39
39
|
@kernel.exit(failure ? 1 : 0)
|
40
40
|
rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e
|
@@ -80,14 +80,7 @@ module Lucid
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
|
84
|
-
# "spec source" location. This location defaults to 'specs' but can
|
85
|
-
# be changed via a command line option. The spec repo will remove
|
86
|
-
# any directory names and, perhaps counter-intuitively, any spec
|
87
|
-
# files. The reason for this is that, by default, the "spec repo"
|
88
|
-
# contains everything that Lucid will need, whether that be
|
89
|
-
# test spec files or code files to support them.
|
90
|
-
def spec_repo
|
83
|
+
def spec_requires
|
91
84
|
requires = @options[:require].empty? ? require_dirs : @options[:require]
|
92
85
|
|
93
86
|
files = requires.map do |path|
|
@@ -101,35 +94,30 @@ module Lucid
|
|
101
94
|
files.reject! {|f| !File.file?(f)}
|
102
95
|
files.reject! {|f| File.extname(f) == ".#{spec_type}" }
|
103
96
|
files.reject! {|f| f =~ /^http/}
|
97
|
+
|
104
98
|
files.sort
|
105
99
|
end
|
106
100
|
|
107
|
-
# The definition context refers to any files that are found in the spec
|
108
|
-
# repository that are not spec files and that are not contained in the
|
109
|
-
# library path.
|
110
101
|
# @see Lucid::Runtime.load_execution_context
|
111
102
|
def definition_context
|
112
|
-
|
103
|
+
spec_requires.reject { |f| f=~ %r{#{library_path}} }
|
113
104
|
end
|
114
105
|
|
115
|
-
# The library context will store an array of all files that are found
|
116
|
-
# in the library_path. This path defaults to 'lucid' but can be changed
|
117
|
-
# via a command line option.
|
118
106
|
# @see Lucid::Runtime.load_execution_context
|
119
107
|
def library_context
|
120
|
-
library_files =
|
121
|
-
|
122
|
-
|
108
|
+
library_files = spec_requires.select { |f| f =~ %r{#{library_path}} }
|
109
|
+
driver = library_files.select {|f| f =~ %r{#{driver_file}} }
|
110
|
+
|
111
|
+
log.info("Driver File Found: #{driver}")
|
112
|
+
|
113
|
+
non_driver_files = library_files - driver
|
123
114
|
|
124
|
-
@options[:dry_run] ? non_driver_files :
|
115
|
+
@options[:dry_run] ? non_driver_files : driver + non_driver_files
|
125
116
|
end
|
126
117
|
|
127
|
-
# The spec files refer to any files found within the spec repository
|
128
|
-
# that match the specification file type. Note that this method is
|
129
|
-
# called from the specs action in a Runtime instance.
|
130
118
|
# @see Lucid::Runtime.specs
|
131
119
|
def spec_files
|
132
|
-
files =
|
120
|
+
files = specs_path(spec_source).map do |path|
|
133
121
|
path = path.gsub(/\\/, '/') # convert \ to /
|
134
122
|
path = path.chomp('/') # removing trailing /
|
135
123
|
if File.directory?(path)
|
@@ -142,33 +130,27 @@ module Lucid
|
|
142
130
|
end
|
143
131
|
end.flatten.uniq
|
144
132
|
|
145
|
-
log.info("Spec Files: #{files}")
|
146
|
-
|
147
133
|
extract_excluded_files(files)
|
148
134
|
files
|
149
135
|
end
|
150
136
|
|
151
|
-
# A call to spec_location will return the location of a spec repository.
|
152
137
|
def spec_location
|
153
138
|
dirs = spec_source.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
|
154
139
|
dirs.delete('.') unless spec_source.include?('.')
|
155
140
|
|
156
|
-
|
141
|
+
specs_path(dirs)
|
157
142
|
end
|
158
143
|
|
159
|
-
# The "spec_type" refers to the file type (or extension) of spec files.
|
160
|
-
# This is how Lucid will recognize the files that should be treated as
|
161
|
-
# specs within a spec repository.
|
162
144
|
def spec_type
|
163
145
|
@options[:spec_type].empty? ? 'spec' : @options[:spec_type]
|
164
146
|
end
|
165
147
|
|
166
|
-
# The "library_path" refers to the location within the spec repository
|
167
|
-
# that holds the logic that supports the basic operations of the
|
168
|
-
# execution. This value will default to 'lucid' but the value of
|
169
|
-
# library_path can be changed via a command line option.
|
170
148
|
def library_path
|
171
|
-
@options[:library_path].empty? ? '
|
149
|
+
@options[:library_path].empty? ? 'common' : @options[:library_path]
|
150
|
+
end
|
151
|
+
|
152
|
+
def driver_file
|
153
|
+
@options[:driver_file].empty? ? 'driver' : @options[:driver_file]
|
172
154
|
end
|
173
155
|
|
174
156
|
def log
|
@@ -192,17 +174,13 @@ module Lucid
|
|
192
174
|
@options[:formats]
|
193
175
|
end
|
194
176
|
|
195
|
-
# The "spec_source" refers to the location of the spec repository. This
|
196
|
-
# value will default to 'specs' but the value of spec_source can be
|
197
|
-
# changed if a repository location is specified on the command line when
|
198
|
-
# calling Lucid.
|
199
177
|
def spec_source
|
200
178
|
@options[:spec_source]
|
201
179
|
end
|
202
180
|
|
203
181
|
private
|
204
182
|
|
205
|
-
def
|
183
|
+
def specs_path(paths)
|
206
184
|
return ['specs'] if paths.empty?
|
207
185
|
paths
|
208
186
|
end
|
@@ -252,7 +230,7 @@ module Lucid
|
|
252
230
|
end
|
253
231
|
|
254
232
|
def require_dirs
|
255
|
-
spec_location + Dir[
|
233
|
+
spec_location + Dir["#{library_path}", 'pages', 'steps']
|
256
234
|
end
|
257
235
|
|
258
236
|
end
|