yard-cucumber 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +4 -2
- data/History.txt +10 -5
- data/README.md +1 -1
- data/Rakefile +11 -2
- data/example/step_definitions/first.step.rb +1 -1
- data/lib/templates/default/fulldoc/html/css/cucumber.css +5 -0
- data/lib/templates/default/fulldoc/html/directories.erb +53 -0
- data/lib/templates/default/fulldoc/html/full_list_featuredirectories.erb +11 -0
- data/lib/templates/default/fulldoc/html/setup.rb +112 -69
- data/lib/templates/default/layout/html/setup.rb +2 -1
- data/lib/templates/default/steptransformers/html/transformers.erb +8 -3
- data/lib/yard-cucumber/version.rb +1 -1
- data/lib/yard/code_objects/step_transformer.rb +1 -1
- data/lib/yard/handlers/cucumber/base.rb +2 -2
- data/lib/yard/handlers/cucumber/feature_handler.rb +9 -9
- data/lib/yard/handlers/legacy/step_definition_handler.rb +9 -9
- data/lib/yard/handlers/legacy/step_transform_handler.rb +6 -6
- data/lib/yard/handlers/step_definition_handler.rb +65 -34
- data/lib/yard/handlers/step_transform_handler.rb +14 -6
- metadata +9 -6
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm gemset use yard-cucumber
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yard-cucumber (2.2.
|
4
|
+
yard-cucumber (2.2.2)
|
5
5
|
cucumber (>= 0.7.5)
|
6
6
|
gherkin (>= 2.2.9)
|
7
7
|
yard (>= 0.8.1)
|
@@ -19,10 +19,12 @@ GEM
|
|
19
19
|
gherkin (2.10.0)
|
20
20
|
json (>= 1.4.6)
|
21
21
|
json (1.7.3)
|
22
|
-
|
22
|
+
redcarpet (2.2.2)
|
23
|
+
yard (0.8.3)
|
23
24
|
|
24
25
|
PLATFORMS
|
25
26
|
ruby
|
26
27
|
|
27
28
|
DEPENDENCIES
|
29
|
+
redcarpet
|
28
30
|
yard-cucumber!
|
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
=== 2.2.3/ 2013-02-15
|
2
|
+
|
3
|
+
* Step Definitions that are marked as 'pending' will now appear as pending
|
4
|
+
on the step definition and transforms page.
|
5
|
+
|
1
6
|
=== 2.2.2/ 2012-10-07
|
2
7
|
|
3
8
|
* Steps and Definitions have links to step transformer page
|
@@ -72,7 +77,7 @@
|
|
72
77
|
|
73
78
|
* 'All Features' lands you on the root features directory; 'Requirements'
|
74
79
|
is still accessible through the breadcrumbs.
|
75
|
-
* Feature directory pages will display all the features in all subdirectories
|
80
|
+
* Feature directory pages will display all the features in all subdirectories
|
76
81
|
* Better sorting for features, tags, and step transformers.
|
77
82
|
|
78
83
|
- FIX Feature-Scenario links and Cursors
|
@@ -89,7 +94,7 @@
|
|
89
94
|
=== 1.7.5 / 2010-12-14
|
90
95
|
|
91
96
|
* FIX Step Transforms were colliding with Step Definitions in Ruby 1.9.2
|
92
|
-
|
97
|
+
|
93
98
|
=== 1.7.4 / 2010-12-11
|
94
99
|
|
95
100
|
* Ruby 1.9.2 Support
|
@@ -101,7 +106,7 @@
|
|
101
106
|
* Shortcut Keys (t) for tags and (r) for features (f was taken)
|
102
107
|
* Step definitions/transforms consolidate steps for easier viewing
|
103
108
|
and when they have no steps they are colored differently
|
104
|
-
* Tag filtering supports inverse (~) of tags
|
109
|
+
* Tag filtering supports inverse (~) of tags
|
105
110
|
|
106
111
|
* FIX Scenario Outlines without examples will not crash the parser
|
107
112
|
* FIX Features, Scenarios, and Directories should display in alphabetic order
|
@@ -207,7 +212,7 @@
|
|
207
212
|
* Cleaned up all references in the fulldoc, full list to references tags
|
208
213
|
|
209
214
|
* Moved Cucumber CodeObjects, Handlers, and Parsers to a Cucumber sub-directory
|
210
|
-
* Moved StepDefinition and StepTransforms form extensions.rb to individual StepObject and Handlers files
|
215
|
+
* Moved StepDefinition and StepTransforms form extensions.rb to individual StepObject and Handlers files
|
211
216
|
|
212
217
|
* (lsegal advice) Created Cucumber Namespace and sub namespaces for features, tags, and step transformers.
|
213
218
|
* (lsegal advice) Started to break apart the feature.erb into smaller digestable erb sections
|
@@ -220,7 +225,7 @@
|
|
220
225
|
* Changed document parsing to mirror the order imposed by Cucumber, this is to stop features being loaded before step definitions.
|
221
226
|
This should hopefully address the issue where steps were not being mapped correctly to step definitions. This fixed the issue
|
222
227
|
in the small and large test suite I ran it against.
|
223
|
-
|
228
|
+
|
224
229
|
|
225
230
|
=== 1.3 / 2010-10-13
|
226
231
|
|
data/README.md
CHANGED
@@ -101,7 +101,7 @@ add or remove these search fields.
|
|
101
101
|
:safe_mode: false
|
102
102
|
|
103
103
|
:"yard-cucumber":
|
104
|
-
menus: [ 'features', 'tags', 'steps', 'step definitions' ]
|
104
|
+
menus: [ 'features', 'directories', 'tags', 'steps', 'step definitions' ]
|
105
105
|
```
|
106
106
|
|
107
107
|
By default the configuration, yaml format, that is generate by the `yard config`
|
data/Rakefile
CHANGED
@@ -2,15 +2,24 @@ require 'rake'
|
|
2
2
|
|
3
3
|
task :default => :gendoc
|
4
4
|
|
5
|
+
desc "Clean out any existing documentation"
|
5
6
|
task :clean do
|
6
7
|
`rm -rf doc`
|
7
8
|
`rm -rf .yardoc`
|
8
9
|
end
|
9
10
|
|
11
|
+
desc "Generate documentation from the example data"
|
10
12
|
task :gendoc => :clean do
|
11
|
-
`yardoc -e ./lib/yard-cucumber.rb 'example/**/*' --debug`
|
13
|
+
puts `yardoc -e ./lib/yard-cucumber.rb 'example/**/*' --debug`
|
12
14
|
end
|
13
15
|
|
16
|
+
desc "Run the YARD Server"
|
17
|
+
task :server => :gendoc do
|
18
|
+
puts `yard server -e ./lib/yard-cucumber.rb`
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Create the yard-cucumber gem"
|
14
22
|
task :gem do
|
15
|
-
`gem build city.gemspec`
|
23
|
+
puts `gem build city.gemspec`
|
16
24
|
end
|
25
|
+
|
@@ -56,6 +56,11 @@
|
|
56
56
|
.nodefinitions .title {
|
57
57
|
background-color: #F5EADD; border: 1px solid #d8d8e5; -moz-border-radius: 3px; -webkit-border-radius: 3px;
|
58
58
|
}
|
59
|
+
.pending .title {
|
60
|
+
background-color: #ffffc0; border: 1px solid #d8d8e5; -moz-border-radius: 3px; -webkit-border-radius: 3px;
|
61
|
+
}
|
62
|
+
|
63
|
+
|
59
64
|
|
60
65
|
.scenario .title { border: none; }
|
61
66
|
.background .title { background: #cbddeb; }
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<% n = 1 %>
|
2
|
+
|
3
|
+
|
4
|
+
<% if @directory.children %>
|
5
|
+
<ul>
|
6
|
+
<% @directory.children.sort {|x,y| x.value.to_s <=> y.value.to_s }.each_with_index do |child,index| %>
|
7
|
+
<% if child.is_a?(YARD::CodeObjects::Cucumber::Feature) %>
|
8
|
+
<li class="r<%= n %>">
|
9
|
+
<%= linkify child, child.value %>
|
10
|
+
<!--
|
11
|
+
<span class='object_link'>
|
12
|
+
<a href="<%= url_for(child,"scenario_#{index}") %>"
|
13
|
+
title="<%= h child.value %>">
|
14
|
+
<%= h child.value %>
|
15
|
+
</a>
|
16
|
+
</span>
|
17
|
+
-->
|
18
|
+
<small><%= child.location %></small>
|
19
|
+
</li>
|
20
|
+
<% end %>
|
21
|
+
<% if child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory) %>
|
22
|
+
<li class="r<%= n %>">
|
23
|
+
<%= "<a class='toggle'></a>" unless child.features.empty? && child.subdirectories.empty? %>
|
24
|
+
<%= linkify child, child.value.to_s.capitalize %>
|
25
|
+
<small><%= child.location %></small>
|
26
|
+
</li>
|
27
|
+
<%= directory_node child %>
|
28
|
+
<% end %>
|
29
|
+
<% n = n == 2 ? 1 : 2 %>
|
30
|
+
<% end %>
|
31
|
+
</ul>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<!-- YARD::CodeObjects::Cucumber::FeatureDirectory -->
|
35
|
+
|
36
|
+
<!--
|
37
|
+
<% if @directory.subdirectories %>
|
38
|
+
<ul>
|
39
|
+
<% @directory.subdirectories.each_with_index do |subdir,index| %>
|
40
|
+
<li class="r<%= n %>">
|
41
|
+
<span class='object_link'>
|
42
|
+
<a href="<%= url_for(subdir,"scenario_#{index}") %>"
|
43
|
+
title="<%= h subdir.value %>">
|
44
|
+
<%= h subdir.value %>
|
45
|
+
</a>
|
46
|
+
</span>
|
47
|
+
<small><%= subdir.location %></small>
|
48
|
+
</li>
|
49
|
+
<% n = n == 2 ? 1 : 2 %>
|
50
|
+
<% end %>
|
51
|
+
</ul>
|
52
|
+
<% end %>
|
53
|
+
-->
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% n = 1 %>
|
2
|
+
<% n = n == 2 ? 1 : 2 %>
|
3
|
+
<% @items.each do |directory| %>
|
4
|
+
<li class="r<%= n %>">
|
5
|
+
<%= "<a class='toggle'></a>" unless directory.features.empty? && directory.subdirectories.empty? %>
|
6
|
+
<%= linkify directory, directory.value %>
|
7
|
+
<small><%= directory.location %></small>
|
8
|
+
</li>
|
9
|
+
<% n = n == 2 ? 1 : 2 %>
|
10
|
+
<%= directory_node directory %>
|
11
|
+
<% end %>
|
@@ -2,131 +2,174 @@ include YARD::Templates::Helpers::HtmlHelper
|
|
2
2
|
|
3
3
|
def init
|
4
4
|
super
|
5
|
-
|
6
|
-
# Additional javascript that power the additional menus, collapsing, etc.
|
7
|
-
asset("js/cucumber.js",file("js/cucumber.js",true))
|
8
5
|
|
9
|
-
#
|
10
|
-
|
11
|
-
# generate the page which is the full list of features
|
12
|
-
#
|
6
|
+
# Additional javascript that power the additional menus, collapsing, etc.
|
7
|
+
asset "js/cucumber.js", file("js/cucumber.js",true)
|
13
8
|
|
14
|
-
|
9
|
+
serialize_object_type :feature
|
15
10
|
|
16
|
-
|
17
|
-
@features.each {|feature| serialize(feature) }
|
18
|
-
#generate_full_list @features.sort {|x,y| x.value.to_s <=> y.value.to_s }, :feature
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# Generate pages for each tag, with the 'tag' template and then generate the
|
23
|
-
# page which is the full list of tags. Tags are ordered in descending order
|
24
|
-
# by the size of how many scenarios that the affect
|
25
|
-
#
|
26
|
-
|
27
|
-
@tags = Registry.all(:tag)
|
28
|
-
|
29
|
-
if @tags
|
30
|
-
@tags.each {|tag| serialize(tag) }
|
31
|
-
#generate_full_list @tags.sort {|x,y| y.all_scenarios.size <=> x.all_scenarios.size }, :tag
|
32
|
-
end
|
11
|
+
serialize_object_type :tag
|
33
12
|
|
34
13
|
# Generates the requirements splash page with the 'requirements' template
|
35
14
|
serialize(YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE)
|
36
15
|
|
37
16
|
# Generates a page for step definitions and step transforms with the 'steptransformers' template
|
38
17
|
serialize(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE)
|
39
|
-
|
18
|
+
|
40
19
|
# Generates the tags page with the 'featuretags' template
|
41
20
|
serialize(YARD::CodeObjects::Cucumber::CUCUMBER_TAG_NAMESPACE)
|
42
|
-
|
43
|
-
# Generate pages for each of the directories with features with the 'featuredirectory' template
|
44
|
-
feature_directories = YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory) }
|
45
|
-
serialize_feature_directories(feature_directories)
|
46
21
|
|
22
|
+
serialize_feature_directories
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# The top-level feature directories. This is affected by the directories that YARD is told to parse.
|
27
|
+
# All other features in sub-directories are contained under each of these top-level directories.
|
28
|
+
#
|
29
|
+
# @example Generating one feature directory
|
30
|
+
#
|
31
|
+
# `yardoc 'example/**/*'`
|
32
|
+
#
|
33
|
+
# @example Generating two feature directories
|
34
|
+
#
|
35
|
+
# `yardoc 'example/**/*' 'example2/**/*'`
|
36
|
+
#
|
37
|
+
# @return the feature directories at the root of the Cucumber Namespace.
|
38
|
+
#
|
39
|
+
def root_feature_directories
|
40
|
+
@root_feature_directories ||= YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory)}
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Generate pages for the objects if there are objects of this type contained
|
45
|
+
# within the Registry.
|
46
|
+
#
|
47
|
+
def serialize_object_type(type)
|
48
|
+
objects = Registry.all(type.to_sym)
|
49
|
+
Array(objects).each {|object| serialize(object) }
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Generates pages for the feature directories found. Starting with all root-level feature
|
54
|
+
# directories and then recursively finding all child feature directories.
|
55
|
+
#
|
56
|
+
def serialize_feature_directories
|
57
|
+
serialize_feature_directories_recursively(root_feature_directories)
|
58
|
+
root_feature_directories.each {|directory| serialize(directory) }
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Generate a page for each Feature Directory. This is called recursively to
|
63
|
+
# ensure that all feature directories contained as children are rendered to
|
64
|
+
# pages.
|
65
|
+
#
|
66
|
+
def serialize_feature_directories_recursively(namespaces)
|
67
|
+
namespaces.each do |namespace|
|
68
|
+
Templates::Engine.with_serializer(namespace, options[:serializer]) do
|
69
|
+
options[:object] = namespace
|
70
|
+
T('layout').run(options)
|
71
|
+
end
|
72
|
+
serialize_feature_directories_recursively(namespace.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory)})
|
73
|
+
end
|
47
74
|
end
|
48
75
|
|
49
76
|
|
50
77
|
# Generate feature list
|
51
|
-
# @note this method is called
|
78
|
+
# @note this method is called automatically by YARD based on the menus defined in the layout
|
52
79
|
def generate_feature_list
|
53
|
-
|
54
|
-
|
80
|
+
features = Registry.all(:feature)
|
81
|
+
features_ordered_by_name = features.sort {|x,y| x.value.to_s <=> y.value.to_s }
|
82
|
+
generate_full_list features_ordered_by_name, :features
|
55
83
|
end
|
56
84
|
|
57
85
|
# Generate tag list
|
58
|
-
# @note this method is called
|
86
|
+
# @note this method is called automatically by YARD based on the menus defined in the layout
|
59
87
|
def generate_tag_list
|
60
|
-
|
61
|
-
|
88
|
+
tags = Registry.all(:tag)
|
89
|
+
tags_ordered_by_use = Array(tags).sort {|x,y| y.all_scenarios.size <=> x.all_scenarios.size }
|
90
|
+
|
91
|
+
generate_full_list tags_ordered_by_use, :tags
|
62
92
|
end
|
63
93
|
|
64
94
|
# Generate a step definition list
|
65
95
|
# @note this menu is not automatically added until yard configuration has this menu added
|
66
96
|
# See the layout template method that loads the menus
|
67
97
|
def generate_stepdefinition_list
|
68
|
-
generate_full_list YARD::Registry.all(:stepdefinition), :
|
98
|
+
generate_full_list YARD::Registry.all(:stepdefinition), :stepdefinitions,
|
99
|
+
:list_title => "Step Definitions List"
|
69
100
|
end
|
70
101
|
|
71
102
|
# Generate a step list
|
72
103
|
# @note this menu is not automatically added until yard configuration has this menu added
|
73
104
|
# See the layout template method that loads the menus
|
74
105
|
def generate_step_list
|
75
|
-
generate_full_list YARD::Registry.all(:step), :
|
106
|
+
generate_full_list YARD::Registry.all(:step), :steps
|
107
|
+
end
|
108
|
+
|
109
|
+
# Generate feature list
|
110
|
+
# @note this menu is not automatically added until yard configuration has this menu added
|
111
|
+
# See the layout template method that loads the menus
|
112
|
+
def generate_featuredirectories_list
|
113
|
+
directories_ordered_by_name = root_feature_directories.sort {|x,y| x.value.to_s <=> y.value.to_s }
|
114
|
+
generate_full_list directories_ordered_by_name, :featuredirectories,
|
115
|
+
:list_title => "Features by Directory",
|
116
|
+
:list_filename => "featuredirectories_list.html"
|
76
117
|
end
|
77
118
|
|
78
|
-
|
119
|
+
|
120
|
+
# Helpler method to generate a full_list page of the specified objects with the
|
79
121
|
# specified type.
|
80
|
-
def generate_full_list(objects,
|
122
|
+
def generate_full_list(objects,type,options = {})
|
123
|
+
defaults = { :list_title => "#{type.to_s.capitalize} List",
|
124
|
+
:css_class => "class",
|
125
|
+
:list_filename => "#{type.to_s.gsub(/s$/,'')}_list.html" }
|
126
|
+
|
127
|
+
options = defaults.merge(options)
|
128
|
+
|
81
129
|
@items = objects
|
82
|
-
@list_type =
|
83
|
-
@list_title =
|
84
|
-
@list_class =
|
85
|
-
asset
|
130
|
+
@list_type = type
|
131
|
+
@list_title = options[:list_title]
|
132
|
+
@list_class = options[:css_class]
|
133
|
+
asset options[:list_filename], erb(:full_list)
|
86
134
|
end
|
87
135
|
|
88
136
|
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
137
|
+
# @note This method overrides YARD's default template class_list method.
|
138
|
+
#
|
139
|
+
# The existing YARD 'Class List' search field contains all the YARD namespace objects.
|
140
|
+
# We, however, do not want the Cucumber Namespace YARD Object (which holds the features,
|
141
|
+
# tags, etc.) as it is a meta-object.
|
142
|
+
#
|
143
|
+
# This method removes the namespace from the root node, generates the class list,
|
144
|
+
# and then adds it back into the root node.
|
93
145
|
#
|
94
146
|
def class_list(root = Registry.root)
|
95
|
-
|
147
|
+
return super unless root == Registry.root
|
148
|
+
|
149
|
+
cucumber_namespace = YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE
|
150
|
+
root.instance_eval { children.delete cucumber_namespace }
|
96
151
|
out = super(root)
|
97
|
-
root.instance_eval { children
|
152
|
+
root.instance_eval { children.push cucumber_namespace }
|
98
153
|
out
|
99
154
|
end
|
100
155
|
|
101
|
-
#
|
102
|
-
# Generate a page for each Feature Directory. This is called recursively to
|
103
|
-
# ensure that all feature directories contained as children are rendered to
|
104
|
-
# pages.
|
105
|
-
#
|
106
|
-
def serialize_feature_directories(namespaces)
|
107
|
-
namespaces.each do |namespace|
|
108
|
-
Templates::Engine.with_serializer(namespace, options[:serializer]) do
|
109
|
-
options[:object] = namespace
|
110
|
-
T('layout').run(options)
|
111
|
-
end
|
112
|
-
serialize_feature_directories(namespace.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory)})
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
156
|
#
|
117
157
|
# Generate a link to the 'All Features' in the features_list.html
|
118
158
|
#
|
119
|
-
# When there are no feature directories or multiple top-level feature directories
|
159
|
+
# When there are no feature directories or multiple top-level feature directories
|
120
160
|
# then we want to link to the 'Requirements' page
|
121
161
|
#
|
122
162
|
# When there are is just one feature directory then we want to link to that directory
|
123
163
|
#
|
124
164
|
def all_features_link
|
125
|
-
root_feature_directories = YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory)}
|
126
|
-
|
127
165
|
if root_feature_directories.length == 0 || root_feature_directories.length > 1
|
128
166
|
linkify YARD::CodeObjects::Cucumber::CUCUMBER_NAMESPACE, "All Features"
|
129
167
|
else
|
130
168
|
linkify root_feature_directories.first, "All Features"
|
131
169
|
end
|
132
|
-
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def directory_node(directory)
|
173
|
+
@directory = directory
|
174
|
+
erb(:directories)
|
175
|
+
end
|
@@ -27,7 +27,7 @@ end
|
|
27
27
|
# @example `~/.yard.config`
|
28
28
|
#
|
29
29
|
# yard-cucumber:
|
30
|
-
# menus: [ 'features', 'tags', 'step definitions', 'steps' ]
|
30
|
+
# menus: [ 'features', 'directories', 'tags', 'step definitions', 'steps' ]
|
31
31
|
#
|
32
32
|
def menu_lists
|
33
33
|
|
@@ -49,6 +49,7 @@ end
|
|
49
49
|
#
|
50
50
|
def yard_cucumber_menus
|
51
51
|
{ "features" => { :type => 'feature', :title => 'Features', :search_title => 'Features' },
|
52
|
+
"directories" => { :type => 'featuredirectories', :title => 'Features by Directory', :search_title => 'Features by Directory' },
|
52
53
|
"tags" => { :type => 'tag', :title => 'Tags', :search_title => 'Tags' },
|
53
54
|
"step definitions" => { :type => 'stepdefinition', :title => 'Step Definitions', :search_title => 'Step Defs' },
|
54
55
|
"steps" => { :type => 'step', :title => 'Steps', :search_title => 'Steps' } }
|
@@ -1,11 +1,17 @@
|
|
1
1
|
<% @items.each do |item| %>
|
2
2
|
|
3
|
-
<div class="transformer <%= @item_type.gsub(/\s/,'') %>
|
3
|
+
<div class="transformer <%= @item_type.gsub(/\s/,'') %>
|
4
|
+
<%= "nodefinitions" if item.steps.nil? || item.steps.empty? %>
|
5
|
+
<%= "pending" if item.pending %>">
|
4
6
|
<a name="<%= anchor_for item %>"></a>
|
5
7
|
<div class="title">
|
6
8
|
<span class="pre"><%= h item.keyword %></span>
|
7
9
|
<span class="name"><%= item.value %></span>
|
8
|
-
<
|
10
|
+
<div style="float: right;">
|
11
|
+
<a href="http://rubular.com/?regex=<%= urlencode item.value %>" target="_blank">Rubular</a>
|
12
|
+
<%= "| PENDING" if item.pending %>
|
13
|
+
<%= "| UNUSED" if item.steps.nil? || item.steps.empty? %>
|
14
|
+
</div>
|
9
15
|
<div style="clear: both;"></div>
|
10
16
|
</div>
|
11
17
|
|
@@ -14,7 +20,6 @@
|
|
14
20
|
<div class="meta" style="clear: right;">
|
15
21
|
<div class="file"><%= h item.location %></div>
|
16
22
|
</div>
|
17
|
-
|
18
23
|
|
19
24
|
<!-- Comments -->
|
20
25
|
<div>
|
@@ -5,7 +5,7 @@ module YARD::CodeObjects
|
|
5
5
|
|
6
6
|
include Cucumber::LocationHelper
|
7
7
|
|
8
|
-
attr_reader :constants, :keyword, :source, :value, :literal_value
|
8
|
+
attr_reader :constants, :keyword, :source, :value, :literal_value, :pending
|
9
9
|
attr_accessor :steps
|
10
10
|
|
11
11
|
# This defines an escape pattern within a string or regex:
|
@@ -14,19 +14,19 @@ module YARD
|
|
14
14
|
# files were were assured to be processed last which was accomplished
|
15
15
|
# by overriding YARD::SourceParser to make it load file in a similar
|
16
16
|
# order as Cucumber.
|
17
|
-
#
|
17
|
+
#
|
18
18
|
# As of YARD 0.7.0 this is no longer necessary as there are callbacks
|
19
19
|
# that can be registered after all the files have been loaded. That
|
20
20
|
# callback _after_parse_list_ is defined below and performs the
|
21
21
|
# functionality described above.
|
22
|
-
#
|
22
|
+
#
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
#
|
26
26
|
# Register, once, when that when all files are finished to perform
|
27
27
|
# the final matching of feature steps to step definitions and step
|
28
28
|
# definitions to step transforms.
|
29
|
-
#
|
29
|
+
#
|
30
30
|
YARD::Parser::SourceParser.after_parse_list do |files,globals|
|
31
31
|
# For every feature found in the Registry, find their steps and step
|
32
32
|
# definitions...
|
@@ -34,7 +34,7 @@ module YARD
|
|
34
34
|
log.debug "Finding #{feature.file} - steps, step definitions, and step transforms"
|
35
35
|
FeatureHandler.match_steps_to_step_definitions(feature)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
end
|
39
39
|
|
40
40
|
class << self
|
@@ -77,9 +77,9 @@ module YARD
|
|
77
77
|
#
|
78
78
|
# Store all comparable items with their compare_value as the key and the item as the value
|
79
79
|
# - Reject any compare values that contain escapes #{} as that means they have unpacked constants
|
80
|
-
#
|
80
|
+
#
|
81
81
|
def cache(type)
|
82
|
-
YARD::Registry.all(type).inject({}) do |hash,item|
|
82
|
+
YARD::Registry.all(type).inject({}) do |hash,item|
|
83
83
|
hash[item.regex] = item if item.regex
|
84
84
|
hash
|
85
85
|
end
|
@@ -96,9 +96,9 @@ module YARD
|
|
96
96
|
end
|
97
97
|
|
98
98
|
#
|
99
|
-
# Given a step object, attempt to match that step to a step
|
99
|
+
# Given a step object, attempt to match that step to a step
|
100
100
|
# transformation
|
101
|
-
#
|
101
|
+
#
|
102
102
|
def match_step_to_step_definition_and_transforms(step)
|
103
103
|
@@step_definitions.each_pair do |stepdef,stepdef_object|
|
104
104
|
stepdef_matches = step.value.match(stepdef)
|
@@ -9,19 +9,19 @@ class YARD::Handlers::Ruby::Legacy::StepDefinitionHandler < YARD::Handlers::Ruby
|
|
9
9
|
step_definition = statement.tokens.to_s[STEP_DEFINITION_MATCH,3]
|
10
10
|
|
11
11
|
@@unique_name = @@unique_name + 1
|
12
|
-
|
13
|
-
stepdef_instance = StepDefinitionObject.new(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "definition_#{@@unique_name}") do |o|
|
12
|
+
|
13
|
+
stepdef_instance = StepDefinitionObject.new(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "definition_#{@@unique_name}") do |o|
|
14
14
|
o.source = "#{keyword} #{step_definition} do #{statement.block.to_s =~ /^\s*\|.+/ ? '' : "\n "}#{statement.block.to_s}\nend"
|
15
15
|
o.value = step_definition
|
16
16
|
o.keyword = keyword
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
obj = register stepdef_instance
|
20
20
|
parse_block :owner => obj
|
21
|
-
|
21
|
+
|
22
22
|
rescue YARD::Handlers::NamespaceMissingError
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
#
|
26
26
|
# Step Definitions can contain defined steps within them. While it is likely that they could not
|
27
27
|
# very easily be parsed because of variables that are only calculated at runtime, it would be nice
|
@@ -32,14 +32,14 @@ class YARD::Handlers::Ruby::Legacy::StepDefinitionHandler < YARD::Handlers::Ruby
|
|
32
32
|
#log.debug "#{block} #{block.class}"
|
33
33
|
block.each_with_index do |token,index|
|
34
34
|
#log.debug "Token #{token.class} #{token.text}"
|
35
|
-
if token.is_a?(YARD::Parser::Ruby::Legacy::RubyToken::TkCONSTANT) &&
|
35
|
+
if token.is_a?(YARD::Parser::Ruby::Legacy::RubyToken::TkCONSTANT) &&
|
36
36
|
token.text =~ /^(given|when|then|and)$/i &&
|
37
37
|
block[index + 2].is_a?(YARD::Parser::Ruby::Legacy::RubyToken::TkSTRING)
|
38
38
|
log.debug "Step found in Step Definition: #{block[index + 2].text} "
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
end
|
@@ -3,22 +3,22 @@ class YARD::Handlers::Ruby::Legacy::StepTransformHandler < YARD::Handlers::Ruby:
|
|
3
3
|
handles STEP_TRANSFORM_MATCH
|
4
4
|
|
5
5
|
@@unique_name = 0
|
6
|
-
|
6
|
+
|
7
7
|
def process
|
8
8
|
transform = statement.tokens.to_s[STEP_TRANSFORM_MATCH,2]
|
9
9
|
@@unique_name = @@unique_name + 1
|
10
|
-
|
11
|
-
instance = StepTransformObject.new(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "transform_#{@@unique_name}") do |o|
|
10
|
+
|
11
|
+
instance = StepTransformObject.new(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "transform_#{@@unique_name}") do |o|
|
12
12
|
o.source = "Transform #{transform} do #{statement.block.to_s}\nend"
|
13
13
|
o.value = transform
|
14
14
|
o.keyword = "Transform"
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
obj = register instance
|
18
18
|
parse_block :owner => obj
|
19
|
-
|
19
|
+
|
20
20
|
rescue YARD::Handlers::NamespaceMissingError
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
end
|
24
24
|
|
@@ -1,58 +1,89 @@
|
|
1
1
|
#
|
2
2
|
# Finds and processes all the step definitions defined in the ruby source
|
3
3
|
# code. By default the english gherkin language will be parsed.
|
4
|
-
#
|
5
|
-
# To override the language you can define the step definitions in the YARD
|
4
|
+
#
|
5
|
+
# To override the language you can define the step definitions in the YARD
|
6
6
|
# configuration file `~./yard/config`:
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# @example `~/.yard/config` with LOLCatz step definitions
|
9
|
-
#
|
10
|
-
# :"yard-cucumber":
|
11
|
-
# language:
|
9
|
+
#
|
10
|
+
# :"yard-cucumber":
|
11
|
+
# language:
|
12
12
|
# step_definitions: [ 'WEN', 'I CAN HAZ', 'AN', 'DEN' ]
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# @example `~/.yard/config` with French step definitions
|
15
|
-
#
|
16
|
-
# :"yard-cucumber":
|
17
|
-
# language:
|
15
|
+
#
|
16
|
+
# :"yard-cucumber":
|
17
|
+
# language:
|
18
18
|
# step_definitions: [ 'Soit', 'Etantdonné', 'Lorsque', 'Lorsqu', 'Alors', 'Et' ]
|
19
|
-
#
|
19
|
+
#
|
20
20
|
class YARD::Handlers::Ruby::StepDefinitionHandler < YARD::Handlers::Ruby::Base
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
|
22
|
+
def self.default_step_definitions
|
23
|
+
[ "When", "Given", "And", "Then" ]
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.custom_step_definitions
|
27
|
+
YARD::Config.options["yard-cucumber"]["language"]["step_definitions"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.custom_step_definitions_defined?
|
31
|
+
YARD::Config.options["yard-cucumber"] and
|
29
32
|
YARD::Config.options["yard-cucumber"]["language"] and
|
30
33
|
YARD::Config.options["yard-cucumber"]["language"]["step_definitions"]
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.step_definitions
|
37
|
+
if custom_step_definitions_defined?
|
38
|
+
custom_step_definitions
|
39
|
+
else
|
40
|
+
default_step_definitions
|
34
41
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@@unique_name = 0
|
42
|
-
|
42
|
+
end
|
43
|
+
|
44
|
+
step_definitions.each { |step_def| handles method_call(step_def) }
|
45
|
+
|
43
46
|
process do
|
44
|
-
@@unique_name += 1
|
45
47
|
|
46
|
-
instance = YARD::CodeObjects::StepDefinitionObject.new(
|
48
|
+
instance = YARD::CodeObjects::StepDefinitionObject.new(step_transform_namespace,step_definition_name) do |o|
|
47
49
|
o.source = statement.source
|
48
50
|
o.comments = statement.comments
|
51
|
+
# o.keyword = statement.method_name.source
|
49
52
|
o.keyword = statement[0].source
|
53
|
+
# o.value = statement.parameters.source
|
50
54
|
o.value = statement[1].source
|
55
|
+
o.pending = pending_keyword_used(statement.block)
|
51
56
|
end
|
52
57
|
|
53
58
|
obj = register instance
|
54
59
|
parse_block(statement[2],:owner => obj)
|
55
|
-
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def pending_keyword
|
64
|
+
"pending"
|
65
|
+
end
|
66
|
+
|
67
|
+
def pending_command_statement?(line)
|
68
|
+
puts "#{line.type} #{line.source}"
|
69
|
+
(line.type == :command || line.type == :vcall) && line.first.source == pending_keyword
|
70
|
+
end
|
71
|
+
|
72
|
+
def pending_keyword_used(block)
|
73
|
+
code_in_block = block.last
|
74
|
+
code_in_block.find { |line| pending_command_statement?(line) }
|
56
75
|
end
|
57
|
-
|
76
|
+
|
77
|
+
def step_transform_namespace
|
78
|
+
YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE
|
79
|
+
end
|
80
|
+
|
81
|
+
def step_definition_name
|
82
|
+
"step_definition#{self.class.generate_unique_id}"
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.generate_unique_id
|
86
|
+
@step_definition_count = @step_definition_count.to_i + 1
|
87
|
+
end
|
88
|
+
|
58
89
|
end
|
@@ -1,13 +1,10 @@
|
|
1
1
|
|
2
2
|
class YARD::Handlers::Ruby::StepTransformHandler < YARD::Handlers::Ruby::Base
|
3
3
|
handles method_call(:Transform)
|
4
|
-
|
5
|
-
@@unique_name = 0
|
6
4
|
|
7
5
|
process do
|
8
|
-
|
9
|
-
|
10
|
-
instance = YARD::CodeObjects::StepTransformObject.new(YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE,"step_transform#{@@unique_name}") do |o|
|
6
|
+
|
7
|
+
instance = YARD::CodeObjects::StepTransformObject.new(step_transform_namespace,step_transformer_name) do |o|
|
11
8
|
o.source = statement.source
|
12
9
|
o.comments = statement.comments
|
13
10
|
o.keyword = statement[0].source
|
@@ -19,5 +16,16 @@ class YARD::Handlers::Ruby::StepTransformHandler < YARD::Handlers::Ruby::Base
|
|
19
16
|
|
20
17
|
end
|
21
18
|
|
22
|
-
|
19
|
+
def step_transform_namespace
|
20
|
+
YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE
|
21
|
+
end
|
22
|
+
|
23
|
+
def step_transformer_name
|
24
|
+
"step_transform#{self.class.generate_unique_id}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.generate_unique_id
|
28
|
+
@step_transformer_count = @step_transformer_count.to_i + 1
|
29
|
+
end
|
23
30
|
|
31
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gherkin
|
@@ -73,6 +73,7 @@ extra_rdoc_files:
|
|
73
73
|
files:
|
74
74
|
- .gitignore
|
75
75
|
- .rspec
|
76
|
+
- .rvmrc
|
76
77
|
- Gemfile
|
77
78
|
- Gemfile.lock
|
78
79
|
- History.txt
|
@@ -116,6 +117,8 @@ files:
|
|
116
117
|
- lib/templates/default/featuretags/html/namespace.erb
|
117
118
|
- lib/templates/default/featuretags/html/setup.rb
|
118
119
|
- lib/templates/default/fulldoc/html/css/cucumber.css
|
120
|
+
- lib/templates/default/fulldoc/html/directories.erb
|
121
|
+
- lib/templates/default/fulldoc/html/full_list_featuredirectories.erb
|
119
122
|
- lib/templates/default/fulldoc/html/full_list_features.erb
|
120
123
|
- lib/templates/default/fulldoc/html/full_list_stepdefinitions.erb
|
121
124
|
- lib/templates/default/fulldoc/html/full_list_steps.erb
|
@@ -160,10 +163,10 @@ files:
|
|
160
163
|
homepage: http://github.com/burtlo/yard-cucumber
|
161
164
|
licenses: []
|
162
165
|
post_install_message: ! "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
163
|
-
(::) (::) (::) (::)\n\n Thank you for installing yard-cucumber 2.2.
|
164
|
-
\ Changes:\n \n *
|
165
|
-
\
|
166
|
-
(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
166
|
+
(::) (::) (::) (::)\n\n Thank you for installing yard-cucumber 2.2.3 / 2013-02-15.\n\n
|
167
|
+
\ Changes:\n \n * Step Definitions that are marked as 'pending' will now appear
|
168
|
+
as pending\n on the step definition and transforms page.\n \n\n(::) (::) (::)
|
169
|
+
(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n"
|
167
170
|
rdoc_options:
|
168
171
|
- --charset=UTF-8
|
169
172
|
require_paths:
|