cucumber-in-the-yard 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/History.txt +24 -0
  2. data/Manifest +54 -41
  3. data/README.md +45 -1
  4. data/Rakefile +4 -3
  5. data/cucumber-in-the-yard.gemspec +5 -5
  6. data/example/{example.step.rb → step_definitions/example.step.rb} +0 -0
  7. data/example/step_definitions/support/env.rb +0 -0
  8. data/example/step_definitions/support/env_support.rb +0 -0
  9. data/example/step_definitions/support/support.rb +0 -0
  10. data/features/definitions/city_step.rb +89 -0
  11. data/features/definitions/test.setup.and.teardown.rb +27 -0
  12. data/features/features.feature +44 -0
  13. data/lib/city.rb +20 -11
  14. data/lib/cucumber/city_builder.rb +60 -55
  15. data/lib/templates/default/feature/html/background.erb +92 -0
  16. data/lib/templates/default/feature/html/feature.erb +22 -0
  17. data/lib/templates/default/feature/html/no_steps_defined.erb +1 -0
  18. data/lib/templates/default/feature/html/outline.erb +19 -0
  19. data/lib/templates/default/feature/html/pystring.erb +3 -0
  20. data/lib/templates/default/feature/html/scenario.erb +43 -0
  21. data/lib/templates/default/feature/html/steps.erb +34 -0
  22. data/lib/templates/default/feature/html/table.erb +20 -0
  23. data/lib/templates/default/feature/setup.rb +28 -0
  24. data/lib/{yard/templates → templates}/default/fulldoc/html/css/common.css +0 -0
  25. data/lib/{yard/templates → templates}/default/fulldoc/html/full_list.erb +0 -0
  26. data/lib/templates/default/fulldoc/html/full_list_features.erb +7 -0
  27. data/lib/templates/default/fulldoc/html/full_list_requirements.erb +1 -0
  28. data/lib/templates/default/fulldoc/html/full_list_scenarios.erb +8 -0
  29. data/lib/{yard/templates → templates}/default/fulldoc/html/full_list_stepdefinitions.erb +2 -2
  30. data/lib/{yard/templates → templates}/default/fulldoc/html/full_list_steps.erb +0 -0
  31. data/lib/templates/default/fulldoc/html/full_list_tags.erb +8 -0
  32. data/lib/{yard/templates → templates}/default/fulldoc/html/index.erb +0 -0
  33. data/lib/{yard/templates → templates}/default/fulldoc/html/js/cucumber.js +1 -1
  34. data/lib/templates/default/fulldoc/html/setup.rb +56 -0
  35. data/lib/{yard/templates → templates}/default/layout/html/headers.erb +0 -0
  36. data/lib/{yard/templates → templates}/default/layout/html/search.erb +0 -0
  37. data/lib/{yard/templates → templates}/default/scenario/html/scenario.erb +0 -0
  38. data/lib/{yard/templates → templates}/default/scenario/setup.rb +0 -0
  39. data/lib/templates/default/steptransformers/html/stepdefinition.erb +38 -0
  40. data/lib/templates/default/steptransformers/html/steptransformers.erb +7 -0
  41. data/lib/templates/default/steptransformers/setup.rb +17 -0
  42. data/lib/templates/default/tag/html/feature.erb +23 -0
  43. data/lib/templates/default/tag/html/scenario.erb +21 -0
  44. data/lib/templates/default/tag/html/tag.erb +18 -0
  45. data/lib/templates/default/tag/setup.rb +5 -0
  46. data/lib/yard/code_objects/{base.rb → cucumber/base.rb} +3 -9
  47. data/lib/yard/code_objects/{feature.rb → cucumber/feature.rb} +1 -1
  48. data/lib/yard/code_objects/cucumber/namespace_object.rb +18 -0
  49. data/lib/yard/code_objects/{scenario.rb → cucumber/scenario.rb} +1 -1
  50. data/lib/yard/code_objects/{step.rb → cucumber/step.rb} +0 -0
  51. data/lib/yard/code_objects/cucumber/tag.rb +27 -0
  52. data/lib/yard/{extensions.rb → code_objects/namespace_object.rb} +11 -2
  53. data/lib/yard/code_objects/step_definition.rb +38 -0
  54. data/lib/yard/code_objects/step_transform.rb +14 -0
  55. data/lib/yard/handlers/{base.rb → cucumber/base.rb} +0 -0
  56. data/lib/yard/handlers/{feature_handler.rb → cucumber/feature_handler.rb} +3 -2
  57. data/lib/yard/handlers/step_definition_handler.rb +57 -0
  58. data/lib/yard/handlers/step_transform_handler.rb +21 -0
  59. data/lib/yard/parser/{feature.rb → cucumber/feature.rb} +0 -0
  60. data/lib/yard/parser/source_parser.rb +54 -0
  61. data/lib/yard/rake/city_task.rb +1 -1
  62. data/lib/yard/templates/helpers/base_helper.rb +20 -0
  63. metadata +105 -77
  64. data/lib/yard/code_objects/tags.rb +0 -55
  65. data/lib/yard/rb_extensions.rb +0 -156
  66. data/lib/yard/templates/default/feature/html/feature.erb +0 -245
  67. data/lib/yard/templates/default/feature/setup.rb +0 -5
  68. data/lib/yard/templates/default/fulldoc/html/full_list_features.erb +0 -10
  69. data/lib/yard/templates/default/fulldoc/html/full_list_scenarios.erb +0 -10
  70. data/lib/yard/templates/default/fulldoc/html/full_list_tagusages.erb +0 -10
  71. data/lib/yard/templates/default/fulldoc/html/setup.rb +0 -73
  72. data/lib/yard/templates/default/module/html/step_transforms.erb +0 -23
  73. data/lib/yard/templates/default/module/setup.rb +0 -5
  74. data/lib/yard/templates/default/steptransformers/html/stepdefinition.erb +0 -50
  75. data/lib/yard/templates/default/steptransformers/setup.rb +0 -5
  76. data/lib/yard/templates/default/tagusage/html/tagusage.erb +0 -65
  77. data/lib/yard/templates/default/tagusage/setup.rb +0 -5
  78. data/spec/city/feature_parser_spec_examples.rb +0 -153
  79. data/spec/city/gherkin_loader_spec.rb +0 -39
  80. data/spec/city/test.feature +0 -36
  81. data/spec/city/yard_handlers_cucumber_spec.rb +0 -24
  82. data/spec/city/yard_namespace_object_spec.rb +0 -8
  83. data/spec/city/yard_parser_cucumber_spec.rb +0 -215
  84. data/spec/city/yard_rb_extensions_spec.rb +0 -128
  85. data/spec/spec_helper.rb +0 -5
@@ -0,0 +1,7 @@
1
+ <% n = 1 %>
2
+ <% @items.each do |feature| %>
3
+ <li class="r<%= n %>">
4
+ <%= linkify feature, feature.value %>
5
+ </li>
6
+ <% n = n == 2 ? 1 : 2 %>
7
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= class_list %>
@@ -0,0 +1,8 @@
1
+ <% n = 1 %>
2
+ <% @items.each do |scenario| %>
3
+ <li class="r<%= n %>">
4
+ <%= linkify scenario.feature, scenario.value %>
5
+ <small><%= h(scenario.location) %></small>
6
+ </li>
7
+ <% n = n == 2 ? 1 : 2 %>
8
+ <% end %>
@@ -3,9 +3,9 @@
3
3
  <li class="r<%= n %>">
4
4
  <span class='object_link'>
5
5
  <span class="pre"><%= stepdef.keyword %></span>
6
- <a href="steptransformers.html#<%= stepdef.name %>"><span class="name"><%= h(stepdef.value) %></span></a>&nbsp;&nbsp;
6
+ <a href="<%= url_for stepdef %>"><span class="name"><%= h(stepdef.value) %></span></a>&nbsp;&nbsp;
7
7
  </span>
8
- <span class="">(<%= h(stepdef.location) %>)<span>
8
+ <small><%= h(stepdef.location) %></small>
9
9
  </li>
10
10
  <% n = n == 2 ? 1 : 2 %>
11
11
  <% end %>
@@ -0,0 +1,8 @@
1
+ <% n = 1 %>
2
+ <% @items.each do |tag| %>
3
+ <li class="r<%= n %>">
4
+ <%= linkify tag, tag.value %>
5
+ <small><%= tag.all_scenarios.size %></small>
6
+ </li>
7
+ <% n = n == 2 ? 1 : 2 %>
8
+ <% end %>
@@ -3,7 +3,7 @@ function cucumberSearchFrameLinks() {
3
3
  toggleSearchFrame(this, relpath + 'feature_list.html');
4
4
  });
5
5
  $('#tagusage_list_link').click(function() {
6
- toggleSearchFrame(this, relpath + 'tagusage_list.html');
6
+ toggleSearchFrame(this, relpath + 'tag_list.html');
7
7
  });
8
8
  $('#scenario_list_link').click(function() {
9
9
  toggleSearchFrame(this, relpath + 'scenario_list.html');
@@ -0,0 +1,56 @@
1
+ include YARD::Templates::Helpers::HtmlHelper
2
+
3
+ def init
4
+ super
5
+ asset("js/cucumber.js",file("js/cucumber.js",true))
6
+
7
+ @features = Registry.all(:feature)
8
+
9
+ if @features
10
+ @features.each {|feature| serialize(feature) }
11
+ generate_full_list(@features)
12
+ end
13
+
14
+
15
+
16
+ @tags = Registry.all(:tag)
17
+
18
+ if @tags
19
+ @tags.each {|tag| serialize(tag) }
20
+ generate_full_list @tags.sort {|x,y| y.all_scenarios.size <=> x.all_scenarios.size }
21
+ end
22
+
23
+ @scenarios = Registry.all(:scenario).find_all {|scenario| !scenario.background? }
24
+ generate_full_list(@scenarios) if @scenarios
25
+
26
+ @steps = Registry.all(:step)
27
+ generate_full_list(@steps) if @steps
28
+
29
+ Templates::Engine.with_serializer(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, options[:serializer]) do
30
+ options[:object] = YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE
31
+ T('layout').run(options)
32
+ end
33
+
34
+ end
35
+
36
+
37
+ def generate_full_list(objects,friendly_name=nil)
38
+ if !objects.empty?
39
+ @items = objects
40
+ @list_type = "#{objects.first.type.to_s}s"
41
+ @list_title = "#{friendly_name || objects.first.type.to_s.capitalize} List"
42
+ asset("#{objects.first.type}_list.html",erb(:full_list))
43
+ else
44
+ log.warn "Full List: Failed to create a list because the objects array is empty."
45
+ end
46
+ end
47
+
48
+ #
49
+ # Remove CUCUMBER namespace from the class list
50
+ #
51
+ def class_list(root = Registry.root)
52
+ root.instance_eval { children.delete YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE } if root == Registry.root
53
+ out = super(root)
54
+ root.instance_eval { children << YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE } if root == Registry.root
55
+ out
56
+ end
@@ -0,0 +1,38 @@
1
+ <div class="stepdef">
2
+ <a name="<%= anchor_for @stepdefinition %>">
3
+ <div class="title">
4
+ <span class="pre"><%= @stepdefinition.keyword %></span>
5
+ <span class="name"><%= @stepdefinition.value %></span>
6
+ <div style="float: right;"><%= h( @stepdefinition.location ) %></div>
7
+ </div>
8
+
9
+
10
+ <div class="steps">
11
+ <% if @stepdefinition.steps && !@stepdefinition.steps.empty? %>
12
+ <% @stepdefinition.steps.each_with_index do |step,step_index| %>
13
+ <div class="step <%= (step_index + 1) % 2 == 0 ? 'even' : 'odd' %>">
14
+ <%= h("#{step.keyword} #{step.value}") %>
15
+ <div class="details"><a href="<%= url_for step.scenario.feature %>"><%= h(step.location) %></a></div>
16
+ </div>
17
+ <% end %>
18
+ <% else %>
19
+ <span class="undefined">No steps were found to match this step definition.</span>
20
+ <% end%>
21
+ </div>
22
+
23
+ <div class="source">
24
+ <span class="showSource">
25
+ [ <a href="#" class="toggleSource">View source</a> ]
26
+ </span>
27
+ <table class="source_code">
28
+ <tr>
29
+ <td>
30
+ <pre class="lines"><%= "" %><%= h format_lines(@stepdefinition) %></pre>
31
+ </td>
32
+ <td>
33
+ <pre class="code"><%= "" %><%= html_syntax_highlight @stepdefinition.source %></pre>
34
+ </td>
35
+ </tr>
36
+ </table>
37
+ </div>
38
+ </div>
@@ -0,0 +1,7 @@
1
+ <div class="title">
2
+ <div class="name">Step Definitions</div>
3
+ </div>
4
+
5
+ <div style="margin: 10px;">&nbsp;</div>
6
+
7
+ <%= yieldall %>
@@ -0,0 +1,17 @@
1
+ def init
2
+ super
3
+ sections.push :steptransformers, [:stepdefinitions, :steptransforms]
4
+ end
5
+
6
+ def stepdefinitions
7
+
8
+ object.children.find_all {|child| child.is_a?(YARD::CodeObjects::StepDefinitionObject)}.collect do |stepdefinition|
9
+ @stepdefinition = stepdefinition
10
+ erb(:stepdefinition)
11
+ end.join("\n")
12
+
13
+ end
14
+
15
+ def steptransforms
16
+
17
+ end
@@ -0,0 +1,23 @@
1
+ <% object.features.each do |feature| %>
2
+ <div class="feature direct">
3
+ <div class="title">
4
+ <span class="pre">Feature:</span>
5
+ <span class="name">
6
+ <a href="<%= url_for feature %>"><%= feature.value %></a>
7
+ </span>
8
+ </div>
9
+ <div class="description"><%= feature.description %></div>
10
+
11
+ <% feature.scenarios.each do |scenario| %>
12
+ <div class="scenario indirect">
13
+ <div class="title">
14
+ <span class="pre">Scenario:</span>
15
+ <span class="name">
16
+ <a href="<%= url_for feature %>"><%= scenario.value %></a>
17
+ </span>
18
+ </div>
19
+ <div class="description"><%= scenario.description %></div>
20
+ </div>
21
+ <% end %>
22
+
23
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <% object.scenarios.each do |scenario| %>
2
+ <div class="feature indirect">
3
+ <div class="title">
4
+ <span class="pre">Feature:</span>
5
+ <span class="name">
6
+ <a href="<%= url_for scenario.feature %>"><%= scenario.feature.value %></a>
7
+ </span>
8
+ </div>
9
+ <div class="description"><%= scenario.feature.description %></div>
10
+ </div>
11
+
12
+ <div class="scenario direct">
13
+ <div class="title">
14
+ <span class="pre">Scenario:</span>
15
+ <span class="name">
16
+ <a href="<%= url_for scenario.feature %>"><%= scenario.value %></a>
17
+ </span>
18
+ </div>
19
+ <div class="description"><%= scenario.description %></div>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <div class="tag">
2
+ <div class="title">
3
+ <span class="pre">Tag:</span>
4
+ <span class="name"><%= @tag.value %></span>
5
+
6
+ </div>
7
+
8
+ <div class="meta">
9
+ <div class="file">Usage:
10
+ <%= @tag.features.size > 0 ? "#{@tag.features.size} feature#{@tag.features.size > 1 ? 's' : ''} (with #{@tag.indirect_scenarios.size} scenario#{@tag.indirect_scenarios.size > 1 ? 's' : ''})" : "" %>
11
+ <%= " and " if @tag.features.size > 0 && @tag.scenarios.size > 0 %>
12
+ <%= @tag.scenarios.size > 0 ? "#{@tag.scenarios.size} scenario#{@tag.scenarios.size > 1 ? 's' : ''}" : "" %>
13
+ </div>
14
+ </div>
15
+
16
+ <%= yieldall :object => @tag %>
17
+
18
+ </div>
@@ -0,0 +1,5 @@
1
+ def init
2
+ super
3
+ @tag = object
4
+ sections.push :tag, [:feature, :scenario]
5
+ end
@@ -20,15 +20,9 @@ module YARD::CodeObjects::Cucumber
20
20
  class Base < YARD::CodeObjects::Base
21
21
  include LocationHelper
22
22
 
23
- # def sep ; '/' ; end
24
-
25
- # def path
26
- # if parent && !parent.root?
27
- # [ "Cucumber$", name.to_s ].join(sep)
28
- # else
29
- # name.to_s
30
- # end
31
- # end
23
+ def path
24
+ @value || super
25
+ end
32
26
 
33
27
  end
34
28
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module YARD::CodeObjects::Cucumber
4
4
 
5
- class Feature < Base
5
+ class Feature < NamespaceObject
6
6
 
7
7
  attr_accessor :background, :comments, :description, :keyword, :scenarios, :tags, :value
8
8
 
@@ -0,0 +1,18 @@
1
+
2
+ module YARD::CodeObjects::Cucumber
3
+
4
+ class NamespaceObject < YARD::CodeObjects::NamespaceObject
5
+ include LocationHelper
6
+
7
+ def value ; nil ; end
8
+ end
9
+
10
+ CUCUMBER_NAMESPACE = NamespaceObject.new(:root, "requirements")
11
+ CUCUMBER_TAG_NAMESPACE = NamespaceObject.new(CUCUMBER_NAMESPACE, "tags")
12
+
13
+ class StepTransformersObject < NamespaceObject ; end
14
+
15
+ CUCUMBER_STEPTRANSFORM_NAMESPACE = StepTransformersObject.new(CUCUMBER_NAMESPACE, "step_transformers")
16
+
17
+
18
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module YARD::CodeObjects::Cucumber
4
4
 
5
- class Scenario < Base
5
+ class Scenario < NamespaceObject
6
6
 
7
7
  attr_accessor :value, :description, :steps, :tags, :feature, :examples
8
8
 
File without changes
@@ -0,0 +1,27 @@
1
+
2
+
3
+ module YARD::CodeObjects::Cucumber
4
+
5
+ class Tag < NamespaceObject
6
+
7
+ attr_accessor :value, :owners
8
+
9
+ def features
10
+ @owners.find_all{|owner| owner.is_a?(Feature) }
11
+ end
12
+
13
+ def scenarios
14
+ @owners.find_all{|owner| owner.is_a?(Scenario) }
15
+ end
16
+
17
+ def indirect_scenarios
18
+ @owners.find_all{|owner| owner.is_a?(Feature) }.collect {|feature| feature.scenarios }.flatten
19
+ end
20
+
21
+ def all_scenarios
22
+ scenarios + indirect_scenarios
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -2,7 +2,16 @@
2
2
  module YARD::CodeObjects
3
3
 
4
4
  NamespaceObject.class_eval do
5
-
5
+
6
+ def remove_child(child)
7
+ children.delete(child)
8
+ end
9
+
10
+ def add_child(child)
11
+ children << child
12
+ end
13
+
14
+
6
15
  attr_accessor :features
7
16
 
8
17
  def features(opts = {})
@@ -34,5 +43,5 @@ module YARD::CodeObjects
34
43
  end
35
44
 
36
45
  end
37
-
46
+
38
47
  end
@@ -0,0 +1,38 @@
1
+
2
+
3
+ module YARD::CodeObjects
4
+
5
+ class StepDefinitionObject < Base
6
+ include Cucumber::LocationHelper
7
+
8
+ attr_reader :keyword, :value, :compare_value, :source
9
+ attr_accessor :constants, :steps
10
+
11
+ def value=(value)
12
+ @value = format_source(value)
13
+ @constants = {}
14
+ @steps = []
15
+ end
16
+
17
+ def compare_value
18
+ base_value = value.gsub(/^\/|\/$/,'')
19
+ @constants.each do |name,value|
20
+ base_value.gsub!(/\#\{\s*#{name.to_s}\s*\}/,value.gsub(/^\/|\/$/,''))
21
+ end
22
+ base_value
23
+ end
24
+
25
+ def _value_constants(data=@value)
26
+ #Hash[*data.scan(/\#\{([^\}]+)\}/).flatten.collect {|value| [value.strip,nil]}.flatten]
27
+ data.scan(/\#\{([^\}]+)\}/).flatten.collect { |value| value.strip }
28
+ end
29
+
30
+ def constants=(value)
31
+ value.each do |val|
32
+ @constants[val.name.to_s] = val if val.respond_to?(:name) && val.respond_to?(:value)
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,14 @@
1
+
2
+ module YARD::CodeObjects
3
+
4
+ class StepTransformObject < Base
5
+ include Cucumber::LocationHelper
6
+
7
+ attr_reader :value
8
+
9
+ def value=(value)
10
+ @value = format_source(value)
11
+ end
12
+ end
13
+
14
+ end