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
data/lib/lucid/ast.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'lucid/ast/comment'
2
+ require 'lucid/ast/specs'
3
+ require 'lucid/ast/feature'
4
+ require 'lucid/ast/background'
5
+ require 'lucid/ast/scenario'
6
+ require 'lucid/ast/scenario_outline'
7
+ require 'lucid/ast/step_invocation'
8
+ require 'lucid/ast/step_collection'
9
+ require 'lucid/ast/step'
10
+ require 'lucid/ast/table'
11
+ require 'lucid/ast/tags'
12
+ require 'lucid/ast/doc_string'
13
+ require 'lucid/ast/outline_table'
14
+ require 'lucid/ast/examples'
15
+ require 'lucid/ast/tdl_walker'
16
+
17
+ module Lucid
18
+ module AST
19
+ end
20
+ end
@@ -0,0 +1,116 @@
1
+ require 'lucid/ast/has_steps'
2
+ require 'lucid/ast/names'
3
+ require 'lucid/ast/location'
4
+
5
+ module Lucid
6
+ module AST
7
+ class Background #:nodoc:
8
+ include HasSteps
9
+ include Names
10
+ include HasLocation
11
+ attr_accessor :feature
12
+
13
+ def initialize(language, location, comment, keyword, title, description, raw_steps)
14
+ @language, @location, @comment, @keyword, @title, @description, @raw_steps = language, location, comment, keyword, title, description, raw_steps
15
+ @failed = nil
16
+ @first_collection_created = false
17
+ attach_steps(@raw_steps)
18
+ end
19
+
20
+ def feature_elements
21
+ feature.feature_elements
22
+ end
23
+
24
+ def step_invocations
25
+ @step_invocations ||= steps.step_invocations(true)
26
+ end
27
+
28
+ def step_collection(scenario_step_invocations)
29
+ if(@first_collection_created)
30
+ steps.step_invocations(true).dup(scenario_step_invocations)
31
+ else
32
+ @first_collection_created = true
33
+ step_invocations.dup(scenario_step_invocations)
34
+ end
35
+ end
36
+
37
+ def accept(visitor)
38
+ return if Lucid.wants_to_quit
39
+ visitor.visit_comment(@comment) unless @comment.empty?
40
+ visitor.visit_background_name(@keyword, name, file_colon_line, source_indent(first_line_length))
41
+ with_visitor(hook_context, visitor) do
42
+ visitor.runtime.before(hook_context)
43
+ skip_invoke! if failed?
44
+ visitor.visit_steps(step_invocations)
45
+ @failed = step_invocations.any? { |step_invocation| step_invocation.exception || step_invocation.status != :passed }
46
+ visitor.runtime.after(hook_context) if @failed || feature_elements.empty?
47
+ end
48
+ end
49
+
50
+ def with_visitor(scenario, visitor)
51
+ @current_visitor = visitor
52
+ if self != scenario && scenario.respond_to?(:with_visitor)
53
+ scenario.with_visitor(visitor) do
54
+ yield
55
+ end
56
+ else
57
+ yield
58
+ end
59
+ end
60
+
61
+ def accept_hook?(hook)
62
+ if hook_context != self
63
+ hook_context.accept_hook?(hook)
64
+ else
65
+ # We have no scenarios, just ask our feature
66
+ feature.accept_hook?(hook)
67
+ end
68
+ end
69
+
70
+ def skip_invoke!
71
+ step_invocations.each{|step_invocation| step_invocation.skip_invoke!}
72
+ end
73
+
74
+ def failed?
75
+ !!@failed
76
+ end
77
+
78
+ def hook_context
79
+ feature_elements.first || self
80
+ end
81
+
82
+ def to_sexp
83
+ sexp = [:background, line, @keyword]
84
+ sexp += [name] unless name.empty?
85
+ comment = @comment.to_sexp
86
+ sexp += [comment] if comment
87
+ sexp += steps.to_sexp if steps.any?
88
+ sexp
89
+ end
90
+
91
+ def fail!(exception)
92
+ @failed = true
93
+ @exception = exception
94
+ @current_visitor.visit_exception(@exception, :failed)
95
+ end
96
+
97
+ # Override this method, as there are situations where the background
98
+ # wind up being the one called fore Before scenarios, and
99
+ # backgrounds don't have tags.
100
+ def source_tags
101
+ []
102
+ end
103
+
104
+ def source_tag_names
105
+ source_tags.map { |tag| tag.name }
106
+ end
107
+
108
+ private
109
+
110
+ def steps
111
+ @steps ||= StepCollection.new(@raw_steps)
112
+ end
113
+
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,24 @@
1
+ module Lucid
2
+ module AST
3
+ class Comment #:nodoc:
4
+ def initialize(value)
5
+ @value = value
6
+ end
7
+
8
+ def empty?
9
+ @value.nil? || @value == ""
10
+ end
11
+
12
+ def accept(visitor)
13
+ return if Lucid.wants_to_quit
14
+ @value.strip.split("\n").each do |line|
15
+ visitor.visit_comment_line(line.strip)
16
+ end
17
+ end
18
+
19
+ def to_sexp
20
+ (@value.nil? || @value == '') ? nil : [:comment, @value]
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,44 @@
1
+ module Lucid
2
+ module AST
3
+ class DocString < String #:nodoc:
4
+ attr_accessor :file
5
+
6
+ def self.default_arg_name
7
+ "string"
8
+ end
9
+
10
+ attr_reader :content_type
11
+
12
+ def initialize(string, content_type)
13
+ @content_type = content_type
14
+ super string
15
+ end
16
+
17
+ def to_step_definition_arg
18
+ self
19
+ end
20
+
21
+ def accept(visitor)
22
+ return if Lucid.wants_to_quit
23
+ visitor.visit_doc_string(self)
24
+ end
25
+
26
+ def arguments_replaced(arguments) #:nodoc:
27
+ string = self
28
+ arguments.each do |name, value|
29
+ value ||= ''
30
+ string = string.gsub(name, value)
31
+ end
32
+ DocString.new(string, content_type)
33
+ end
34
+
35
+ def has_text?(text)
36
+ index(text)
37
+ end
38
+
39
+ def to_sexp #:nodoc:
40
+ [:doc_string, to_step_definition_arg]
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,33 @@
1
+ require 'lucid/ast/step_collection'
2
+
3
+ module Lucid
4
+ module AST
5
+ class EmptyBackground
6
+ attr_writer :file
7
+ attr_accessor :feature
8
+
9
+ def failed?
10
+ false
11
+ end
12
+
13
+ def feature_elements
14
+ []
15
+ end
16
+
17
+ def step_collection(step_invocations)
18
+ StepCollection.new(step_invocations)
19
+ end
20
+
21
+ def step_invocations
22
+ []
23
+ end
24
+
25
+ def init
26
+ end
27
+
28
+ def accept(visitor)
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,49 @@
1
+ require 'lucid/ast/names'
2
+
3
+ module Lucid
4
+ module AST
5
+ class Examples #:nodoc:
6
+ include Names
7
+ include HasLocation
8
+ attr_writer :outline_table
9
+
10
+ def initialize(location, comment, keyword, title, description, outline_table)
11
+ @location, @comment, @keyword, @title, @description, @outline_table = location, comment, keyword, title, description, outline_table
12
+ raise ArgumentError unless @location.is_a?(Location)
13
+ raise ArgumentError unless @comment.is_a?(Comment)
14
+ end
15
+
16
+ attr_reader :gherkin_statement
17
+ def gherkin_statement(statement=nil)
18
+ @gherkin_statement ||= statement
19
+ end
20
+
21
+ def accept(visitor)
22
+ return if Lucid.wants_to_quit
23
+ visitor.visit_comment(@comment) unless @comment.empty?
24
+ visitor.visit_examples_name(@keyword, name)
25
+ visitor.visit_outline_table(@outline_table)
26
+ end
27
+
28
+ def skip_invoke!
29
+ @outline_table.skip_invoke!
30
+ end
31
+
32
+ def each_example_row(&proc)
33
+ @outline_table.cells_rows[1..-1].each(&proc)
34
+ end
35
+
36
+ def failed?
37
+ @outline_table.cells_rows[1..-1].select{|row| row.failed?}.any?
38
+ end
39
+
40
+ def to_sexp
41
+ sexp = [:examples, @keyword, name]
42
+ comment = @comment.to_sexp
43
+ sexp += [comment] if comment
44
+ sexp += [@outline_table.to_sexp]
45
+ sexp
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,99 @@
1
+ require 'lucid/ast/names'
2
+ require 'lucid/ast/location'
3
+ require 'lucid/ast/location'
4
+
5
+ module Lucid
6
+ module AST
7
+
8
+ class Feature #:nodoc:
9
+ include Names
10
+ include HasLocation
11
+
12
+ attr_accessor :language
13
+ attr_reader :feature_elements
14
+
15
+ def initialize(location, background, comment, tags, keyword, title, description, feature_elements)
16
+ @background, @comment, @tags, @keyword, @title, @description, @feature_elements = background, comment, tags, keyword, title, description, feature_elements
17
+ @background.feature = self
18
+ @location = location
19
+ @feature_elements.each { |e| e.feature = self }
20
+ end
21
+
22
+ attr_reader :gherkin_statement
23
+ def gherkin_statement(statement=nil)
24
+ @gherkin_statement ||= statement
25
+ end
26
+
27
+ def step_count
28
+ units.inject(0) { |total, unit| total += unit.step_count }
29
+ end
30
+
31
+ def accept(visitor)
32
+ return if Lucid.wants_to_quit
33
+ visitor.visit_comment(@comment) unless @comment.empty?
34
+ visitor.visit_tags(@tags)
35
+ visitor.visit_feature_name(@keyword, indented_name)
36
+ visitor.visit_background(@background) if !@background.is_a?(EmptyBackground)
37
+ @feature_elements.each do |feature_element|
38
+ visitor.visit_feature_element(feature_element)
39
+ end
40
+ end
41
+
42
+ def indented_name
43
+ indent = ""
44
+ name.split("\n").map do |l|
45
+ s = "#{indent}#{l}"
46
+ indent = " "
47
+ s
48
+ end.join("\n")
49
+ end
50
+
51
+ def source_tags
52
+ @tags.tags
53
+ end
54
+
55
+ def source_tag_names
56
+ source_tags.map { |tag| tag.name }
57
+ end
58
+
59
+ def accept_hook?(hook)
60
+ @tags.accept_hook?(hook)
61
+ end
62
+
63
+ def backtrace_line(step_name, line)
64
+ "#{location.on_line(line)}:in `#{step_name}'"
65
+ end
66
+
67
+ def short_name
68
+ first_line = name.split(/\n/)[0]
69
+ if first_line =~ /#{language.keywords('feature')}:(.*)/
70
+ $1.strip
71
+ else
72
+ first_line
73
+ end
74
+ end
75
+
76
+ def to_sexp
77
+ sexp = [:feature, file, name]
78
+ comment = @comment.to_sexp
79
+ sexp += [comment] if comment
80
+ tags = @tags.to_sexp
81
+ sexp += tags if tags.any?
82
+ sexp += [@background.to_sexp] if @background
83
+ sexp += @feature_elements.map{|fe| fe.to_sexp}
84
+ sexp
85
+ end
86
+
87
+ private
88
+
89
+ attr_reader :background
90
+
91
+ def units
92
+ @units ||= @feature_elements.map do |element|
93
+ element.to_units(background)
94
+ end.flatten
95
+ end
96
+
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,74 @@
1
+ require 'enumerator'
2
+ require 'gherkin/tag_expression'
3
+
4
+ module Lucid
5
+ module AST
6
+ module HasSteps #:nodoc:
7
+ attr_reader :gherkin_statement, :raw_steps, :title, :description
8
+ def gherkin_statement(statement=nil)
9
+ @gherkin_statement ||= statement
10
+ end
11
+
12
+ def attach_steps(steps)
13
+ steps.each do |step|
14
+ step.feature_element = self
15
+ end
16
+ end
17
+
18
+ def first_line_length
19
+ name_line_lengths[0]
20
+ end
21
+
22
+ def text_length
23
+ name_line_lengths.max
24
+ end
25
+
26
+ def name_line_lengths
27
+ if name.strip.empty?
28
+ [AST::Step::INDENT + @keyword.unpack('U*').length + ': '.length]
29
+ else
30
+ name.split("\n").enum_for(:each_with_index).map do |line, line_number|
31
+ if line_number == 0
32
+ AST::Step::INDENT + @keyword.unpack('U*').length + ': '.length + line.unpack('U*').length
33
+ else
34
+ AST::Step::INDENT + AST::Step::INDENT + line.unpack('U*').length
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ def matches_scenario_names?(scenario_name_regexps)
41
+ scenario_name_regexps.detect{|n| n =~ name}
42
+ end
43
+
44
+ def backtrace_line(step_name = "#{@keyword}: #{name}", line = self.line)
45
+ "#{location.on_line(line)}:in `#{step_name}'"
46
+ end
47
+
48
+ def source_indent(text_length)
49
+ max_line_length - text_length
50
+ end
51
+
52
+ def max_line_length
53
+ steps.max_line_length(self)
54
+ end
55
+
56
+ def accept_hook?(hook)
57
+ Gherkin::TagExpression.new(hook.tag_expressions).evaluate(source_tags)
58
+ end
59
+
60
+ def source_tag_names
61
+ source_tags.map { |tag| tag.name }
62
+ end
63
+
64
+ def source_tags
65
+ @tags.tags.to_a + feature_tags.tags.to_a
66
+ end
67
+
68
+ def language
69
+ @language || raise("Language is required for a #{self.class}")
70
+ end
71
+
72
+ end
73
+ end
74
+ end