lucid 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/.gitignore +30 -10
  2. data/.rspec +1 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +15 -0
  6. data/Gemfile +4 -2
  7. data/HISTORY.md +22 -0
  8. data/{LICENSE.txt → LICENSE} +6 -3
  9. data/README.md +22 -8
  10. data/Rakefile +2 -1
  11. data/bin/lucid +10 -10
  12. data/bin/lucid-gen +4 -0
  13. data/lib/autotest/discover.rb +11 -0
  14. data/lib/autotest/lucid.rb +6 -0
  15. data/lib/autotest/lucid_mixin.rb +135 -0
  16. data/lib/autotest/lucid_rails.rb +6 -0
  17. data/lib/autotest/lucid_rails_rspec.rb +6 -0
  18. data/lib/autotest/lucid_rails_rspec2.rb +6 -0
  19. data/lib/autotest/lucid_rspec.rb +6 -0
  20. data/lib/autotest/lucid_rspec2.rb +6 -0
  21. data/lib/lucid.rb +32 -1
  22. data/lib/lucid/ast.rb +20 -0
  23. data/lib/lucid/ast/background.rb +116 -0
  24. data/lib/lucid/ast/comment.rb +24 -0
  25. data/lib/lucid/ast/doc_string.rb +44 -0
  26. data/lib/lucid/ast/empty_background.rb +33 -0
  27. data/lib/lucid/ast/examples.rb +49 -0
  28. data/lib/lucid/ast/feature.rb +99 -0
  29. data/lib/lucid/ast/has_steps.rb +74 -0
  30. data/lib/lucid/ast/location.rb +41 -0
  31. data/lib/lucid/ast/multiline_argument.rb +31 -0
  32. data/lib/lucid/ast/names.rb +13 -0
  33. data/lib/lucid/ast/outline_table.rb +194 -0
  34. data/lib/lucid/ast/scenario.rb +103 -0
  35. data/lib/lucid/ast/scenario_outline.rb +144 -0
  36. data/lib/lucid/ast/specs.rb +38 -0
  37. data/lib/lucid/ast/step.rb +122 -0
  38. data/lib/lucid/ast/step_collection.rb +92 -0
  39. data/lib/lucid/ast/step_invocation.rb +196 -0
  40. data/lib/lucid/ast/table.rb +730 -0
  41. data/lib/lucid/ast/tags.rb +28 -0
  42. data/lib/lucid/ast/tdl_walker.rb +195 -0
  43. data/lib/lucid/cli/app.rb +78 -0
  44. data/lib/lucid/cli/configuration.rb +261 -0
  45. data/lib/lucid/cli/options.rb +463 -0
  46. data/lib/lucid/cli/profile.rb +101 -0
  47. data/lib/lucid/configuration.rb +53 -0
  48. data/lib/lucid/core_ext/disable_autorunners.rb +15 -0
  49. data/lib/lucid/core_ext/instance_exec.rb +70 -0
  50. data/lib/lucid/core_ext/proc.rb +36 -0
  51. data/lib/lucid/core_ext/string.rb +9 -0
  52. data/lib/lucid/errors.rb +40 -0
  53. data/lib/lucid/factory.rb +43 -0
  54. data/lib/lucid/formatter/ansicolor.rb +168 -0
  55. data/lib/lucid/formatter/console.rb +218 -0
  56. data/lib/lucid/formatter/debug.rb +33 -0
  57. data/lib/lucid/formatter/duration.rb +11 -0
  58. data/lib/lucid/formatter/gherkin_formatter_adapter.rb +94 -0
  59. data/lib/lucid/formatter/gpretty.rb +24 -0
  60. data/lib/lucid/formatter/html.rb +610 -0
  61. data/lib/lucid/formatter/interceptor.rb +66 -0
  62. data/lib/lucid/formatter/io.rb +31 -0
  63. data/lib/lucid/formatter/jquery-min.js +154 -0
  64. data/lib/lucid/formatter/json.rb +19 -0
  65. data/lib/lucid/formatter/json_pretty.rb +10 -0
  66. data/lib/lucid/formatter/junit.rb +177 -0
  67. data/lib/lucid/formatter/lucid.css +283 -0
  68. data/lib/lucid/formatter/lucid.sass +244 -0
  69. data/lib/lucid/formatter/ordered_xml_markup.rb +24 -0
  70. data/lib/lucid/formatter/progress.rb +95 -0
  71. data/lib/lucid/formatter/rerun.rb +91 -0
  72. data/lib/lucid/formatter/standard.rb +235 -0
  73. data/lib/lucid/formatter/stepdefs.rb +14 -0
  74. data/lib/lucid/formatter/steps.rb +49 -0
  75. data/lib/lucid/formatter/summary.rb +35 -0
  76. data/lib/lucid/formatter/unicode.rb +53 -0
  77. data/lib/lucid/formatter/usage.rb +132 -0
  78. data/lib/lucid/generator.rb +21 -0
  79. data/lib/lucid/generators/project.rb +70 -0
  80. data/lib/lucid/generators/project/Gemfile.tt +6 -0
  81. data/lib/lucid/generators/project/browser-symbiont.rb +24 -0
  82. data/lib/lucid/generators/project/driver-symbiont.rb +4 -0
  83. data/lib/lucid/generators/project/errors.rb +26 -0
  84. data/lib/lucid/generators/project/events-symbiont.rb +36 -0
  85. data/lib/lucid/generators/project/lucid-symbiont.yml +6 -0
  86. data/lib/lucid/interface.rb +8 -0
  87. data/lib/lucid/interface_methods.rb +125 -0
  88. data/lib/lucid/interface_rb/matcher.rb +108 -0
  89. data/lib/lucid/interface_rb/rb_hook.rb +18 -0
  90. data/lib/lucid/interface_rb/rb_language.rb +190 -0
  91. data/lib/lucid/interface_rb/rb_lucid.rb +119 -0
  92. data/lib/lucid/interface_rb/rb_step_definition.rb +122 -0
  93. data/lib/lucid/interface_rb/rb_transform.rb +57 -0
  94. data/lib/lucid/interface_rb/rb_world.rb +136 -0
  95. data/lib/lucid/interface_rb/regexp_argument_matcher.rb +21 -0
  96. data/lib/lucid/load_path.rb +13 -0
  97. data/lib/lucid/parser.rb +2 -126
  98. data/lib/lucid/platform.rb +27 -0
  99. data/lib/lucid/rspec/allow_doubles.rb +20 -0
  100. data/lib/lucid/rspec/disallow_options.rb +27 -0
  101. data/lib/lucid/runtime.rb +200 -0
  102. data/lib/lucid/runtime/facade.rb +60 -0
  103. data/lib/lucid/runtime/interface_io.rb +60 -0
  104. data/lib/lucid/runtime/orchestrator.rb +218 -0
  105. data/lib/lucid/runtime/results.rb +64 -0
  106. data/lib/lucid/runtime/specs_loader.rb +79 -0
  107. data/lib/lucid/spec_file.rb +112 -0
  108. data/lib/lucid/step_definition_light.rb +20 -0
  109. data/lib/lucid/step_definitions.rb +13 -0
  110. data/lib/lucid/step_match.rb +99 -0
  111. data/lib/lucid/tdl_builder.rb +282 -0
  112. data/lib/lucid/term/ansicolor.rb +118 -0
  113. data/lib/lucid/unit.rb +11 -0
  114. data/lib/lucid/wire_support/configuration.rb +38 -0
  115. data/lib/lucid/wire_support/connection.rb +61 -0
  116. data/lib/lucid/wire_support/request_handler.rb +32 -0
  117. data/lib/lucid/wire_support/wire_exception.rb +32 -0
  118. data/lib/lucid/wire_support/wire_language.rb +54 -0
  119. data/lib/lucid/wire_support/wire_packet.rb +34 -0
  120. data/lib/lucid/wire_support/wire_protocol.rb +43 -0
  121. data/lib/lucid/wire_support/wire_protocol/requests.rb +125 -0
  122. data/lib/lucid/wire_support/wire_step_definition.rb +26 -0
  123. data/lucid.gemspec +25 -14
  124. metadata +220 -12
  125. data/lib/lucid/app.rb +0 -103
  126. data/lib/lucid/options.rb +0 -168
  127. data/lib/lucid/version.rb +0 -3
  128. data/lucid.yml +0 -8
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'builder'
3
+ rescue LoadError
4
+ gem 'builder'
5
+ require 'builder'
6
+ end
7
+
8
+ module Lucid
9
+ module Formatter
10
+ # Emits attributes ordered alphabetically, so that we can predicatbly test output.
11
+ class OrderedXmlMarkup < Builder::XmlMarkup #:nodoc:
12
+ def _insert_attributes(attrs, order=[])
13
+ return if attrs.nil?
14
+ keys = attrs.keys.map{|k| k.to_s}
15
+ keys.sort!
16
+ keys.reverse! if (attrs.keys - [:version, :encoding] == []) #HACK to ensure the 'version' attribute is first in xml declaration.
17
+ keys.each do |k|
18
+ v = attrs[k.to_sym] || attrs[k]
19
+ @target << %{ #{k}="#{_attr_value(v)}"} if v
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,95 @@
1
+ require 'lucid/formatter/console'
2
+ require 'lucid/formatter/io'
3
+
4
+ module Lucid
5
+ module Formatter
6
+ class Progress
7
+ include Console
8
+ include Io
9
+ attr_reader :runtime
10
+
11
+ def initialize(runtime, path_or_io, options)
12
+ @runtime, @io, @options = runtime, ensure_io(path_or_io, "progress"), options
13
+ end
14
+
15
+ def before_features(features)
16
+ print_profile_information
17
+ end
18
+
19
+ def after_features(features)
20
+ @io.puts
21
+ @io.puts
22
+ print_summary(features)
23
+ end
24
+
25
+ def before_feature_element(*args)
26
+ @exception_raised = false
27
+ end
28
+
29
+ def after_feature_element(*args)
30
+ progress(:failed) if (defined? @exception_raised) and (@exception_raised)
31
+ @exception_raised = false
32
+ end
33
+
34
+ def before_steps(*args)
35
+ progress(:failed) if (defined? @exception_raised) and (@exception_raised)
36
+ @exception_raised = false
37
+ end
38
+
39
+ def after_steps(*args)
40
+ @exception_raised = false
41
+ end
42
+
43
+ def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
44
+ progress(status)
45
+ @status = status
46
+ end
47
+
48
+ def before_outline_table(outline_table)
49
+ @outline_table = outline_table
50
+ end
51
+
52
+ def after_outline_table(outline_table)
53
+ @outline_table = nil
54
+ end
55
+
56
+ def table_cell_value(value, status)
57
+ return unless @outline_table
58
+ status ||= @status
59
+ progress(status) unless table_header_cell?(status)
60
+ end
61
+
62
+ def exception(*args)
63
+ @exception_raised = true
64
+ end
65
+
66
+ private
67
+
68
+ def print_summary(features)
69
+ print_steps(:pending)
70
+ print_steps(:failed)
71
+ print_stats(features, @options)
72
+ print_matchers(@options)
73
+ print_passing_wip(@options)
74
+ end
75
+
76
+ CHARS = {
77
+ :passed => '.',
78
+ :failed => 'F',
79
+ :undefined => 'U',
80
+ :pending => 'P',
81
+ :skipped => '-'
82
+ }
83
+
84
+ def progress(status)
85
+ char = CHARS[status]
86
+ @io.print(format_string(char, status))
87
+ @io.flush
88
+ end
89
+
90
+ def table_header_cell?(status)
91
+ status == :skipped_param
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,91 @@
1
+ require 'lucid/formatter/io'
2
+
3
+ module Lucid
4
+ module Formatter
5
+ # The formatter used for <tt>--format rerun</tt>
6
+ #
7
+ # This formatter keeps track of all failing features and print out their location.
8
+ # Example:
9
+ #
10
+ # features/foo.feature:34 features/bar.feature:11:76:81
11
+ #
12
+ # This formatter is used by AutoTest - it will use the output to decide what
13
+ # to run the next time, simply passing the output string on the command line.
14
+ #
15
+ class Rerun
16
+ include Io
17
+
18
+ def initialize(runtime, path_or_io, options)
19
+ @io = ensure_io(path_or_io, "rerun")
20
+ @options = options
21
+ @file_names = []
22
+ @file_colon_lines = Hash.new{|h,k| h[k] = []}
23
+ end
24
+
25
+ def before_feature(feature_element)
26
+ @lines = []
27
+ @file = feature_element.file
28
+ end
29
+
30
+ def after_feature(*)
31
+ unless @lines.empty?
32
+ after_first_time do
33
+ @io.print ' '
34
+ end
35
+ @io.print "#{@file}:#{@lines.join(':')}"
36
+ @io.flush
37
+ end
38
+ end
39
+
40
+ def after_features(features)
41
+ @io.close
42
+ end
43
+
44
+ def before_feature_element(feature_element)
45
+ @rerun = false
46
+ end
47
+
48
+ def after_feature_element(feature_element)
49
+ if (@rerun || feature_element.failed?) && !(AST::ScenarioOutline === feature_element)
50
+ @lines << feature_element.line
51
+ end
52
+ end
53
+
54
+ def after_table_row(table_row)
55
+ return unless @in_examples and Lucid::AST::OutlineTable::ExampleRow === table_row
56
+ unless @header_row
57
+ if table_row.failed?
58
+ @rerun = true
59
+ @lines << table_row.line
60
+ end
61
+ end
62
+
63
+ @header_row = false if @header_row
64
+ end
65
+
66
+ def before_examples(*args)
67
+ @header_row = true
68
+ @in_examples = true
69
+ end
70
+
71
+ def after_examples(*args)
72
+ @in_examples = false
73
+ end
74
+
75
+ def before_table_row(table_row)
76
+ return unless @in_examples
77
+ end
78
+
79
+ def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
80
+ @rerun = true if [:failed, :pending, :undefined].index(status)
81
+ end
82
+
83
+ private
84
+
85
+ def after_first_time
86
+ yield if @not_first_time
87
+ @not_first_time = true
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,235 @@
1
+ require 'fileutils'
2
+ require 'lucid/formatter/console'
3
+ require 'lucid/formatter/io'
4
+ require 'gherkin/formatter/escaping'
5
+
6
+ module Lucid
7
+ module Formatter
8
+ class Standard
9
+ include FileUtils
10
+ include Console
11
+ include Io
12
+ include Gherkin::Formatter::Escaping
13
+
14
+ attr_writer :indent
15
+ attr_reader :runtime
16
+
17
+ def initialize(runtime, path_or_io, options)
18
+ @runtime, @io, @options = runtime, ensure_io(path_or_io, "standard"), options
19
+ @exceptions = []
20
+ @indent = 0
21
+ @prefixes = options[:prefixes] || {}
22
+ @delayed_messages = []
23
+ end
24
+
25
+ def before_features(features)
26
+ print_profile_information
27
+ end
28
+
29
+ def after_features(features)
30
+ print_summary(features) unless @options[:autoformat]
31
+ end
32
+
33
+ def before_feature(feature)
34
+ @exceptions = []
35
+ @indent = 0
36
+ if @options[:autoformat]
37
+ file = File.join(@options[:autoformat], feature.file)
38
+ dir = File.dirname(file)
39
+ mkdir_p(dir) unless File.directory?(dir)
40
+ @io = ensure_file(file, "standard")
41
+ end
42
+ end
43
+
44
+ def comment_line(comment_line)
45
+ @io.puts(comment_line.indent(@indent))
46
+ @io.flush
47
+ end
48
+
49
+ def after_tags(tags)
50
+ if @indent == 1
51
+ @io.puts
52
+ @io.flush
53
+ end
54
+ end
55
+
56
+ def tag_name(tag_name)
57
+ tag = format_string(tag_name, :tag).indent(@indent)
58
+ @io.print(tag)
59
+ @io.flush
60
+ @indent = 1
61
+ end
62
+
63
+ def feature_name(keyword, name)
64
+ @io.puts("#{keyword}: #{name}")
65
+ @io.puts
66
+ @io.flush
67
+ end
68
+
69
+ def before_feature_element(feature_element)
70
+ @indent = 2
71
+ @scenario_indent = 2
72
+ end
73
+
74
+ def after_feature_element(feature_element)
75
+ @io.puts
76
+ @io.flush
77
+ end
78
+
79
+ def before_background(background)
80
+ @indent = 2
81
+ @scenario_indent = 2
82
+ @in_background = true
83
+ end
84
+
85
+ def after_background(background)
86
+ @in_background = nil
87
+ @io.puts
88
+ @io.flush
89
+ end
90
+
91
+ def background_name(keyword, name, file_colon_line, source_indent)
92
+ print_feature_element_name(keyword, name, file_colon_line, source_indent)
93
+ end
94
+
95
+ def before_examples_array(examples_array)
96
+ @indent = 4
97
+ @io.puts
98
+ @visiting_first_example_name = true
99
+ end
100
+
101
+ def examples_name(keyword, name)
102
+ @io.puts unless @visiting_first_example_name
103
+ @visiting_first_example_name = false
104
+ names = name.strip.empty? ? [name.strip] : name.split("\n")
105
+ @io.puts(" #{keyword}: #{names[0]}")
106
+ names[1..-1].each {|s| @io.puts " #{s}" } unless names.empty?
107
+ @io.flush
108
+ @indent = 6
109
+ @scenario_indent = 6
110
+ end
111
+
112
+ def before_outline_table(outline_table)
113
+ @table = outline_table
114
+ end
115
+
116
+ def after_outline_table(outline_table)
117
+ @table = nil
118
+ @indent = 4
119
+ end
120
+
121
+ def scenario_name(keyword, name, file_colon_line, source_indent)
122
+ print_feature_element_name(keyword, name, file_colon_line, source_indent)
123
+ end
124
+
125
+ def before_step(step)
126
+ @current_step = step
127
+ @indent = 6
128
+ end
129
+
130
+ def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
131
+ @hide_this_step = false
132
+ if exception
133
+ if @exceptions.include?(exception)
134
+ @hide_this_step = true
135
+ return
136
+ end
137
+ @exceptions << exception
138
+ end
139
+ if status != :failed && @in_background ^ background
140
+ @hide_this_step = true
141
+ return
142
+ end
143
+ @status = status
144
+ end
145
+
146
+ def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
147
+ return if @hide_this_step
148
+ source_indent = nil unless @options[:source]
149
+ name_to_report = format_step(keyword, step_match, status, source_indent)
150
+ @io.puts(name_to_report.indent(@scenario_indent + 2))
151
+ print_messages
152
+ end
153
+
154
+ def doc_string(string)
155
+ return if @options[:no_multiline] || @hide_this_step
156
+ s = %{"""\n#{string}\n"""}.indent(@indent)
157
+ s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
158
+ @io.puts(format_string(s, @current_step.status))
159
+ @io.flush
160
+ end
161
+
162
+ def exception(exception, status)
163
+ return if @hide_this_step
164
+ print_exception(exception, status, @indent)
165
+ @io.flush
166
+ end
167
+
168
+ def before_multiline_arg(multiline_arg)
169
+ return if @options[:no_multiline] || @hide_this_step
170
+ @table = multiline_arg
171
+ end
172
+
173
+ def after_multiline_arg(multiline_arg)
174
+ @table = nil
175
+ end
176
+
177
+ def before_table_row(table_row)
178
+ return if !@table || @hide_this_step
179
+ @col_index = 0
180
+ @io.print ' |'.indent(@indent-2)
181
+ end
182
+
183
+ def after_table_row(table_row)
184
+ return if !@table || @hide_this_step
185
+ print_table_row_messages
186
+ @io.puts
187
+ if table_row.exception && !@exceptions.include?(table_row.exception)
188
+ print_exception(table_row.exception, table_row.status, @indent)
189
+ end
190
+ end
191
+
192
+ def after_table_cell(cell)
193
+ return unless @table
194
+ @col_index += 1
195
+ end
196
+
197
+ def table_cell_value(value, status)
198
+ return if !@table || @hide_this_step
199
+ status ||= @status || :passed
200
+ width = @table.col_width(@col_index)
201
+ cell_text = escape_cell(value.to_s || '')
202
+ padded = cell_text + (' ' * (width - cell_text.unpack('U*').length))
203
+ prefix = cell_prefix(status)
204
+ @io.print(' ' + format_string("#{prefix}#{padded}", status) + ::Lucid::Term::ANSIColor.reset(" |"))
205
+ @io.flush
206
+ end
207
+
208
+ private
209
+
210
+ def print_feature_element_name(keyword, name, file_colon_line, source_indent)
211
+ @io.puts if @scenario_indent == 6
212
+ names = name.empty? ? [name] : name.split("\n")
213
+ line = "#{keyword}: #{names[0]}".indent(@scenario_indent)
214
+ @io.print(line)
215
+ if @options[:source]
216
+ line_comment = " # #{file_colon_line}".indent(source_indent)
217
+ @io.print(format_string(line_comment, :comment))
218
+ end
219
+ @io.puts
220
+ names[1..-1].each {|s| @io.puts " #{s}"}
221
+ @io.flush
222
+ end
223
+
224
+ def cell_prefix(status)
225
+ @prefixes[status]
226
+ end
227
+
228
+ def print_summary(features)
229
+ print_stats(features, @options)
230
+ print_matchers(@options)
231
+ print_passing_wip(@options)
232
+ end
233
+ end
234
+ end
235
+ end