yard-cucumber 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.rspec +3 -0
  2. data/History.txt +190 -0
  3. data/README.md +145 -0
  4. data/Rakefile +17 -0
  5. data/city.gemspec +66 -0
  6. data/example/README.md +8 -0
  7. data/example/child_feature/README.md +21 -0
  8. data/example/child_feature/child.feature +11 -0
  9. data/example/child_feature/grandchild_feature/grandchild.feature +12 -0
  10. data/example/empty.feature +2 -0
  11. data/example/scenario.feature +63 -0
  12. data/example/scenario_outline.feature +80 -0
  13. data/example/step_definitions/example.step.rb +109 -0
  14. data/example/step_definitions/first.step.rb +21 -0
  15. data/example/step_definitions/support/env.rb +7 -0
  16. data/example/step_definitions/support/env_support.rb +12 -0
  17. data/example/step_definitions/support/support.rb +6 -0
  18. data/example/tags.feature +18 -0
  19. data/example/transform.feature +13 -0
  20. data/lib/cucumber/city_builder.rb +209 -0
  21. data/lib/docserver/default/fulldoc/html/js/cucumber.js +85 -0
  22. data/lib/docserver/default/layout/html/headers.erb +13 -0
  23. data/lib/docserver/doc_server/full_list/html/full_list.erb +37 -0
  24. data/lib/docserver/doc_server/full_list/html/setup.rb +18 -0
  25. data/lib/templates/default/feature/html/feature.erb +39 -0
  26. data/lib/templates/default/feature/html/no_steps_defined.erb +1 -0
  27. data/lib/templates/default/feature/html/outline.erb +42 -0
  28. data/lib/templates/default/feature/html/pystring.erb +3 -0
  29. data/lib/templates/default/feature/html/scenario.erb +55 -0
  30. data/lib/templates/default/feature/html/setup.rb +55 -0
  31. data/lib/templates/default/feature/html/steps.erb +39 -0
  32. data/lib/templates/default/feature/html/table.erb +20 -0
  33. data/lib/templates/default/featuredirectory/html/alpha_table.erb +26 -0
  34. data/lib/templates/default/featuredirectory/html/directory.erb +32 -0
  35. data/lib/templates/default/featuredirectory/html/setup.rb +41 -0
  36. data/lib/templates/default/featuretags/html/namespace.erb +131 -0
  37. data/lib/templates/default/featuretags/html/setup.rb +34 -0
  38. data/lib/templates/default/fulldoc/html/css/common.css +214 -0
  39. data/lib/templates/default/fulldoc/html/full_list.erb +36 -0
  40. data/lib/templates/default/fulldoc/html/full_list_features.erb +28 -0
  41. data/lib/templates/default/fulldoc/html/full_list_stepdefinitions.erb +11 -0
  42. data/lib/templates/default/fulldoc/html/full_list_steps.erb +13 -0
  43. data/lib/templates/default/fulldoc/html/full_list_tags.erb +12 -0
  44. data/lib/templates/default/fulldoc/html/index.erb +24 -0
  45. data/lib/templates/default/fulldoc/html/js/cucumber.js +314 -0
  46. data/lib/templates/default/fulldoc/html/setup.rb +72 -0
  47. data/lib/templates/default/layout/html/headers.erb +14 -0
  48. data/lib/templates/default/layout/html/search.erb +7 -0
  49. data/lib/templates/default/requirements/html/alpha_table.erb +26 -0
  50. data/lib/templates/default/requirements/html/requirements.erb +50 -0
  51. data/lib/templates/default/requirements/html/setup.rb +51 -0
  52. data/lib/templates/default/steptransformers/html/header.erb +12 -0
  53. data/lib/templates/default/steptransformers/html/index.erb +10 -0
  54. data/lib/templates/default/steptransformers/html/setup.rb +94 -0
  55. data/lib/templates/default/steptransformers/html/transformers.erb +74 -0
  56. data/lib/templates/default/steptransformers/html/undefinedsteps.erb +26 -0
  57. data/lib/templates/default/tag/html/alpha_table.erb +32 -0
  58. data/lib/templates/default/tag/html/setup.rb +27 -0
  59. data/lib/templates/default/tag/html/tag.erb +35 -0
  60. data/lib/yard/code_objects/cucumber/base.rb +32 -0
  61. data/lib/yard/code_objects/cucumber/feature.rb +18 -0
  62. data/lib/yard/code_objects/cucumber/namespace_object.rb +45 -0
  63. data/lib/yard/code_objects/cucumber/scenario.rb +26 -0
  64. data/lib/yard/code_objects/cucumber/scenario_outline.rb +66 -0
  65. data/lib/yard/code_objects/cucumber/step.rb +35 -0
  66. data/lib/yard/code_objects/cucumber/tag.rb +27 -0
  67. data/lib/yard/code_objects/step_definition.rb +7 -0
  68. data/lib/yard/code_objects/step_transform.rb +7 -0
  69. data/lib/yard/code_objects/step_transformer.rb +51 -0
  70. data/lib/yard/handlers/cucumber/base.rb +22 -0
  71. data/lib/yard/handlers/cucumber/feature_handler.rb +93 -0
  72. data/lib/yard/handlers/legacy/step_definition_handler.rb +46 -0
  73. data/lib/yard/handlers/legacy/step_transform_handler.rb +24 -0
  74. data/lib/yard/handlers/step_definition_handler.rb +22 -0
  75. data/lib/yard/handlers/step_transform_handler.rb +23 -0
  76. data/lib/yard/parser/cucumber/feature.rb +46 -0
  77. data/lib/yard/parser/source_parser.rb +54 -0
  78. data/lib/yard/rake/city_task.rb +12 -0
  79. data/lib/yard/server/adapter.rb +29 -0
  80. data/lib/yard/server/commands/list_command.rb +25 -0
  81. data/lib/yard/server/router.rb +31 -0
  82. data/lib/yard/templates/helpers/base_helper.rb +26 -0
  83. data/lib/yard-cucumber.rb +53 -0
  84. metadata +173 -0
@@ -0,0 +1,55 @@
1
+ <div class="scenario <%= @id %>">
2
+ <a name="<%= @id %>" />
3
+ <div class="title">
4
+ <div style="float: left;">
5
+ <a class="toggle"> - </a>
6
+ <span class="pre"><%= @scenario.keyword %>:</span>
7
+ <span class="name"><%= h @scenario.value %></span>
8
+ </div>
9
+ <a class="link" style="float:right; clear:right;" href="<%= url_for(@scenario.feature, @id) %>">link</a>
10
+ </div>
11
+
12
+ <% if @scenario.description.length > 0 %>
13
+ <div class="description">
14
+ <%= htmlify_with_newlines @scenario.description %>
15
+ </div>
16
+ <% end %>
17
+
18
+ <% if @scenario.comments.length > 0 %>
19
+ <div class="comments developer">
20
+ <%= htmlify_with_newlines @scenario.comments %>
21
+ </div>
22
+ <% end %>
23
+
24
+ <div class="details">
25
+ <div class="meta developer">
26
+ <div class="file"><%= @scenario.location %></div>
27
+ <% unless @scenario.tags.empty? %>
28
+ <div style="clear:right;"></div>
29
+ <div class="tags">
30
+ <% @scenario.tags.each do |tag| %>
31
+ <a href="<%= url_for tag %>"><%= tag.value %></a>
32
+ <% end %>
33
+ </div>
34
+ <% end%>
35
+ <div style="clear: both;"></div>
36
+ </div>
37
+
38
+ <div class="steps">
39
+ <% if @scenario.steps.empty? %>
40
+ <%= erb(:no_steps_defined) %>
41
+ <% else %>
42
+ <%= @steps = @scenario.steps ; erb(:steps) %>
43
+ <% end %>
44
+ </div>
45
+
46
+
47
+ <%= erb(:outline) if @scenario.outline? %>
48
+
49
+ </div>
50
+
51
+ <div class="attributes" style="display:none;">
52
+ <input type="hidden" name="collapsed" value="false">
53
+ </div>
54
+
55
+ </div>
@@ -0,0 +1,55 @@
1
+ def init
2
+ super
3
+ @feature = object
4
+
5
+ sections.push :feature
6
+
7
+ sections.push :scenarios if object.scenarios
8
+
9
+ end
10
+
11
+ def background
12
+ @scenario = @feature.background
13
+ @id = "background"
14
+ erb(:scenario)
15
+ end
16
+
17
+ def scenarios
18
+ scenarios = ""
19
+
20
+ if @feature.background
21
+ @scenario = @feature.background
22
+ @id = "background"
23
+ scenarios += erb(:scenario)
24
+ end
25
+
26
+ @feature.scenarios.each_with_index do |scenario,index|
27
+ @scenario = scenario
28
+ @id = "scenario_#{index}"
29
+ scenarios += erb(:scenario)
30
+ end
31
+
32
+ scenarios
33
+ end
34
+
35
+
36
+ def highlight_matches(step)
37
+ value = step.value.dup
38
+
39
+ if step.definition
40
+ matches = step.value.match(step.definition.regex)
41
+
42
+ if matches
43
+ matches[1..-1].reverse.each_with_index do |match,index|
44
+ next if match == nil
45
+ value[matches.begin((matches.size - 1) - index)..(matches.end((matches.size - 1) - index) - 1)] = "<span class='match'>#{h(match)}</span>"
46
+ end
47
+ end
48
+ end
49
+
50
+ value
51
+ end
52
+
53
+ def htmlify_with_newlines(text)
54
+ text.split("\n").collect {|c| h(c).gsub(/\s/,'&nbsp;') }.join("<br/>")
55
+ end
@@ -0,0 +1,39 @@
1
+ <% @steps.each_with_index do |step,index| %>
2
+ <% @step = step %>
3
+
4
+ <% if step.comments && step.comments.length > 0 %>
5
+ <div class="comments developer"><%= htmlify_with_newlines step.comments %></div>
6
+ <% end %>
7
+ <div class="step <%= (index + 1) % 2 == 0 ? 'even' : 'odd' %>">
8
+ <span class="predicate"><%= step.keyword %></span>
9
+
10
+ <% if @scenario.outline? %>
11
+ <%= h step.value %>
12
+ <% else %>
13
+
14
+ <% if step.definition %>
15
+ <span class="defined">
16
+ <%= highlight_matches(step) %>
17
+ <div class="definition developer">
18
+ <a href="<%= url_for step.definition %>"><div class="valid">&nbsp;</div></a>
19
+ </div>
20
+ </span>
21
+ <% else %>
22
+ <span class="undefined">
23
+ <%= h step.value %>
24
+ <div class="definition developer">
25
+ <a href="<%= url_for YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE %>#undefined_steps">
26
+ <div class="invalid">&nbsp;</div>
27
+ </a>
28
+ </div>
29
+ </span>
30
+ <% end %>
31
+
32
+ <% end %>
33
+ </div>
34
+
35
+ <%= erb(:table) if step.has_table? %>
36
+ <%= erb(:pystring) if step.has_text? %>
37
+
38
+
39
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <div class="multiline">
2
+ <table style="">
3
+
4
+ <thead>
5
+ <tr>
6
+ <% @step.table.first.each_with_index do |column,column_index| %>
7
+ <th class="<%= (column_index + 1) % 2 == 0 ? 'even' : 'odd' %>"><%= h(column.strip) %></th>
8
+ <% end %>
9
+ </tr>
10
+ </thead>
11
+
12
+ <% @step.table[1..-1].each_with_index do |row,row_index| %>
13
+ <tr class="<%= (row_index + 1) % 2 == 0 ? 'even' : 'odd' %>">
14
+ <% row.each_with_index do |column,column_index| %>
15
+ <td><%= h(column.strip) %></td>
16
+ <% end %>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+ </div>
@@ -0,0 +1,26 @@
1
+ <% if @elements && !@elements.empty? %>
2
+ <% i = (@elements.length % 2 == 0 ? 1 : 0) %>
3
+ <table style="margin-left: 10px; width: 100%;">
4
+ <tr>
5
+ <td valign='top' width="50%">
6
+ <% @elements.each do |letter, objects| %>
7
+ <% if (i += 1) > (@elements.length / 2 + 1) %>
8
+ </td><td valign='top' width="50%">
9
+ <% i = 0 %>
10
+ <% end %>
11
+ <ul id="alpha_<%= letter %>" class="alpha">
12
+ <li class="letter"><%= letter %></li>
13
+ <ul>
14
+ <% objects.each do |obj| %>
15
+ <li>
16
+ <%= linkify obj, obj.value %>
17
+ <small>(<%= obj.file %>)</small>
18
+ </li>
19
+ <% end %>
20
+ </ul>
21
+ </ul>
22
+ <% end %>
23
+ </td>
24
+ </tr>
25
+ </table>
26
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <% if @directory %>
2
+
3
+ <div class="requirements">
4
+ <div class="title">
5
+ <span class="pre">Directory:</span>
6
+ <span class="name"><%= h @directory.name.to_s.capitalize %></span>
7
+ </div>
8
+
9
+ <div class="readme">
10
+ <%= markdown @directory.description %>
11
+ </div>
12
+
13
+ <% if features && !features.empty? %>
14
+ <%= alpha_table(features) %>
15
+ <% end %>
16
+
17
+ <div id="directory">
18
+ <div class="title"><span class="name">Tags</span></div>
19
+ </div>
20
+ <div class="tags">
21
+ <%= tags.collect {|tag| linkify(tag,tag.value) }.join(",\n") %>
22
+ </div>
23
+
24
+ <% if directories && !directories.empty? %>
25
+ <div id="directory">
26
+ <div class="title"><span class="name">Subdirectories</span></div>
27
+ </div>
28
+ <%= alpha_table(directories) %>
29
+ <% end %>
30
+ </div>
31
+
32
+ <% end %>
@@ -0,0 +1,41 @@
1
+ def init
2
+ super
3
+ sections.push :directory
4
+ @directory = object
5
+ end
6
+
7
+ def markdown(text)
8
+ htmlify(text,:markdown) rescue h(text)
9
+ end
10
+
11
+ def htmlify_with_newlines(text)
12
+ text.split("\n").collect {|c| h(c).gsub(/\s/,'&nbsp;') }.join("<br/>")
13
+ end
14
+
15
+ def directories
16
+ @directories ||= @directory.subdirectories
17
+ end
18
+
19
+ def features
20
+ @features ||= @directory.features + directories.collect {|d| d.features }.flatten
21
+ end
22
+
23
+ def scenarios
24
+ @scenarios ||= features.collect {|feature| feature.scenarios }.flatten
25
+ end
26
+
27
+ def tags
28
+ @tags ||= (features.collect{|feature| feature.tags } + scenarios.collect {|scenario| scenario.tags }).flatten.uniq.sort_by {|l,o| l.value.to_s }
29
+ end
30
+
31
+ def alpha_table(objects)
32
+ @elements = Hash.new
33
+
34
+ objects = run_verifier(objects)
35
+ objects.each {|o| (@elements[o.value.to_s[0,1].upcase] ||= []) << o }
36
+ @elements.values.each {|v| v.sort! {|a,b| b.value.to_s <=> a.value.to_s } }
37
+ @elements = @elements.sort_by {|l,o| l.to_s }
38
+
39
+ @elements.each {|letter,objects| objects.sort! {|a,b| b.value.to_s <=> a.value.to_s }}
40
+ erb(:alpha_table)
41
+ end
@@ -0,0 +1,131 @@
1
+ <% if @namespace %>
2
+ <div id="tags" class="requirements">
3
+ <script type="text/javascript" charset="utf-8">
4
+ var tag_list = [ <%= tags.collect{|t| "'#{t.value}'" }.join(',') %> ];
5
+
6
+ $(function() {
7
+
8
+ // On focus, remove all the shortcut keys
9
+ $("#tag_search").focus(function() {
10
+ $(document).unbind('keypress');
11
+ });
12
+
13
+ // On blur, return all the shortcut keys
14
+ $("#tag_search").blur(function() {
15
+ $(document).bind('keypress',keyboardShortcuts);
16
+ $(document).bind('keypress',cucumberKeyboardShortcuts);
17
+ });
18
+
19
+ $("#tag_search").keyup(function(evt) {
20
+ updateTagFiltering($("#tag_search")[0].value);
21
+ });
22
+
23
+
24
+ $("#tag_search").keyup(function(evt) {
25
+ updateTagFiltering($("#tag_search")[0].value);
26
+ });
27
+
28
+ $(".tag").click(function(evt) {
29
+ if (typeof evt !== "undefined") {
30
+
31
+ if (evt.shiftKey === true) {
32
+ window.location = $(this).attr("href");
33
+ return true;
34
+ }
35
+
36
+ var tagSearchElement = $("#tag_search")[0];
37
+
38
+ var tagToAdd = this.innerHTML;
39
+ var tagModifer = "";
40
+
41
+ if (evt.altKey === true ) {
42
+ tagToAdd = "~" + tagToAdd;
43
+ }
44
+
45
+ if (evt.ctrlKey === true ) {
46
+ tagModifier = ",";
47
+ } else {
48
+ tagModifier = " ";
49
+ }
50
+
51
+ tagSearchElement.value = (tagSearchElement.value != "" ? tagSearchElement.value + tagModifier : "") + tagToAdd;
52
+ updateTagFiltering(tagSearchElement.value);
53
+
54
+ }
55
+ });
56
+ });
57
+ </script>
58
+
59
+ <div class="title">
60
+ <span class="name">Tags</span>
61
+ </div>
62
+
63
+ <div id="tag_filtering" >
64
+ <span style="font-size: 18px;">Tag Filtering <a href="https://github.com/aslakhellesoy/cucumber/wiki/Tags" target="_blank">?</a></span>
65
+
66
+ <div style="clear: both"></div>
67
+
68
+ <div style="float: left; margin-top: 10px; padding-left: 5px; line-height: 1.5; font-size: 10px; font-style: italic;">
69
+ Type in tags with spaces between to 'AND' and commas between to 'OR'<br/>
70
+ LEFT CLICK to AND tags; CTRL+LEFT CLICK to OR tags; hold ALT for inverse (~) tags
71
+ </div>
72
+
73
+ <div style="clear: both;"></div>
74
+
75
+ <div style="float: right;">
76
+ <a href="#" onclick="clearTagFiltering(); $('#tag_search')[0].value = ''; return true;">clear</a>
77
+ </div>
78
+
79
+ <div style="clear: both"></div>
80
+
81
+ <input id="tag_search" type="text" />
82
+ <span>Example command line execution:</span>
83
+ <div id="command_example">cucumber</div>
84
+ </div>
85
+
86
+ <div class="tags" style="margin-top: 20px;"><span class="name">Tags:</span>
87
+ <%= tags.collect {|tag| tagify(tag) }.join(",\n") %>
88
+ </div>
89
+
90
+ <div id="features">
91
+ <div class="title">
92
+ <span class="name">Features</span>
93
+ </div>
94
+ <% n = 1 %>
95
+ <ul style="padding-left: 0px;">
96
+ <% features.each do |feature| %>
97
+ <li class="feature <%= n % 2 == 0 ? 'even' : 'odd' %> <%= feature.tags.collect {|t| t.value}.join(" ") %>">
98
+ <%= linkify feature, feature.value %>
99
+ <% ftags = feature.tags.collect{|t| tagify(t) }.join(", ") %>
100
+ <% if ftags && ftags != "" %>
101
+ - <small><%= ftags %></small>
102
+ <% end %>
103
+ </li>
104
+ <% n = n == 2 ? 1 : 2 %>
105
+ <% if feature.scenarios %>
106
+ <ul style="padding-left: 20px;">
107
+ <% feature.scenarios.each do |scenario| %>
108
+ <li class="scenario <%= n % 2 == 0 ? 'even' : 'odd' %> <%= feature.tags.collect{|t| t.value }.join(" ") %> <%= scenario.tags.collect{|t| t.value }.join(" ") %>">
109
+ <span class='object_link'>
110
+ <a href="<%= url_for(scenario.feature,"scenario#{scenario.feature.scenarios.index(scenario) }") %>">
111
+ <%= h scenario.value %>
112
+ </a>
113
+ </span>
114
+ <% stags = scenario.tags.collect{|t| tagify(t) }.join(", ") %>
115
+ <% if stags && stags != "" %>
116
+ - <small><%= stags %></small>
117
+ <% end %>
118
+ </li>
119
+ <% n = n == 2 ? 1 : 2 %>
120
+ <% end %>
121
+ </ul>
122
+ <% end %>
123
+ <% end %>
124
+ </ul>
125
+ <div class="undefined" style="display:none;">No Features or Scenarios match the Tag Expression</div>
126
+ </div>
127
+
128
+ </div>
129
+ <% end %>
130
+
131
+
@@ -0,0 +1,34 @@
1
+ def init
2
+ super
3
+ sections.push :namespace
4
+ @namespace = object
5
+ end
6
+
7
+ def namespace
8
+ erb(:namespace)
9
+ end
10
+
11
+ def all_tags_by_letter
12
+ hash = {}
13
+ objects = tags
14
+ objects = run_verifier(objects)
15
+ objects.each {|o| (hash[o.value.to_s[1,1].upcase] ||= []) << o }
16
+ hash
17
+ end
18
+
19
+ def tags
20
+ @tags ||= Registry.all(:tag).sort_by {|l,o| l.value.to_s }
21
+ end
22
+
23
+ def features
24
+ @features ||= Registry.all(:feature).sort {|x,y| x.value.to_s <=> y.value.to_s }
25
+ end
26
+
27
+ def feature_tags_with_all_scenario_tags(feature)
28
+ feature.tags.collect {|t| t.value} + feature.scenarios.collect {|s| s.tags.collect {|t| t.value} }.flatten.uniq
29
+ end
30
+
31
+
32
+ def tagify(tag)
33
+ %{<span class="tag" href="#{url_for tag}">#{tag.value}</span>}
34
+ end