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.
- data/History.txt +24 -0
- data/Manifest +54 -41
- data/README.md +45 -1
- data/Rakefile +4 -3
- data/cucumber-in-the-yard.gemspec +5 -5
- data/example/{example.step.rb → step_definitions/example.step.rb} +0 -0
- data/example/step_definitions/support/env.rb +0 -0
- data/example/step_definitions/support/env_support.rb +0 -0
- data/example/step_definitions/support/support.rb +0 -0
- data/features/definitions/city_step.rb +89 -0
- data/features/definitions/test.setup.and.teardown.rb +27 -0
- data/features/features.feature +44 -0
- data/lib/city.rb +20 -11
- data/lib/cucumber/city_builder.rb +60 -55
- data/lib/templates/default/feature/html/background.erb +92 -0
- data/lib/templates/default/feature/html/feature.erb +22 -0
- data/lib/templates/default/feature/html/no_steps_defined.erb +1 -0
- data/lib/templates/default/feature/html/outline.erb +19 -0
- data/lib/templates/default/feature/html/pystring.erb +3 -0
- data/lib/templates/default/feature/html/scenario.erb +43 -0
- data/lib/templates/default/feature/html/steps.erb +34 -0
- data/lib/templates/default/feature/html/table.erb +20 -0
- data/lib/templates/default/feature/setup.rb +28 -0
- data/lib/{yard/templates → templates}/default/fulldoc/html/css/common.css +0 -0
- data/lib/{yard/templates → templates}/default/fulldoc/html/full_list.erb +0 -0
- data/lib/templates/default/fulldoc/html/full_list_features.erb +7 -0
- data/lib/templates/default/fulldoc/html/full_list_requirements.erb +1 -0
- data/lib/templates/default/fulldoc/html/full_list_scenarios.erb +8 -0
- data/lib/{yard/templates → templates}/default/fulldoc/html/full_list_stepdefinitions.erb +2 -2
- data/lib/{yard/templates → templates}/default/fulldoc/html/full_list_steps.erb +0 -0
- data/lib/templates/default/fulldoc/html/full_list_tags.erb +8 -0
- data/lib/{yard/templates → templates}/default/fulldoc/html/index.erb +0 -0
- data/lib/{yard/templates → templates}/default/fulldoc/html/js/cucumber.js +1 -1
- data/lib/templates/default/fulldoc/html/setup.rb +56 -0
- data/lib/{yard/templates → templates}/default/layout/html/headers.erb +0 -0
- data/lib/{yard/templates → templates}/default/layout/html/search.erb +0 -0
- data/lib/{yard/templates → templates}/default/scenario/html/scenario.erb +0 -0
- data/lib/{yard/templates → templates}/default/scenario/setup.rb +0 -0
- data/lib/templates/default/steptransformers/html/stepdefinition.erb +38 -0
- data/lib/templates/default/steptransformers/html/steptransformers.erb +7 -0
- data/lib/templates/default/steptransformers/setup.rb +17 -0
- data/lib/templates/default/tag/html/feature.erb +23 -0
- data/lib/templates/default/tag/html/scenario.erb +21 -0
- data/lib/templates/default/tag/html/tag.erb +18 -0
- data/lib/templates/default/tag/setup.rb +5 -0
- data/lib/yard/code_objects/{base.rb → cucumber/base.rb} +3 -9
- data/lib/yard/code_objects/{feature.rb → cucumber/feature.rb} +1 -1
- data/lib/yard/code_objects/cucumber/namespace_object.rb +18 -0
- data/lib/yard/code_objects/{scenario.rb → cucumber/scenario.rb} +1 -1
- data/lib/yard/code_objects/{step.rb → cucumber/step.rb} +0 -0
- data/lib/yard/code_objects/cucumber/tag.rb +27 -0
- data/lib/yard/{extensions.rb → code_objects/namespace_object.rb} +11 -2
- data/lib/yard/code_objects/step_definition.rb +38 -0
- data/lib/yard/code_objects/step_transform.rb +14 -0
- data/lib/yard/handlers/{base.rb → cucumber/base.rb} +0 -0
- data/lib/yard/handlers/{feature_handler.rb → cucumber/feature_handler.rb} +3 -2
- data/lib/yard/handlers/step_definition_handler.rb +57 -0
- data/lib/yard/handlers/step_transform_handler.rb +21 -0
- data/lib/yard/parser/{feature.rb → cucumber/feature.rb} +0 -0
- data/lib/yard/parser/source_parser.rb +54 -0
- data/lib/yard/rake/city_task.rb +1 -1
- data/lib/yard/templates/helpers/base_helper.rb +20 -0
- metadata +105 -77
- data/lib/yard/code_objects/tags.rb +0 -55
- data/lib/yard/rb_extensions.rb +0 -156
- data/lib/yard/templates/default/feature/html/feature.erb +0 -245
- data/lib/yard/templates/default/feature/setup.rb +0 -5
- data/lib/yard/templates/default/fulldoc/html/full_list_features.erb +0 -10
- data/lib/yard/templates/default/fulldoc/html/full_list_scenarios.erb +0 -10
- data/lib/yard/templates/default/fulldoc/html/full_list_tagusages.erb +0 -10
- data/lib/yard/templates/default/fulldoc/html/setup.rb +0 -73
- data/lib/yard/templates/default/module/html/step_transforms.erb +0 -23
- data/lib/yard/templates/default/module/setup.rb +0 -5
- data/lib/yard/templates/default/steptransformers/html/stepdefinition.erb +0 -50
- data/lib/yard/templates/default/steptransformers/setup.rb +0 -5
- data/lib/yard/templates/default/tagusage/html/tagusage.erb +0 -65
- data/lib/yard/templates/default/tagusage/setup.rb +0 -5
- data/spec/city/feature_parser_spec_examples.rb +0 -153
- data/spec/city/gherkin_loader_spec.rb +0 -39
- data/spec/city/test.feature +0 -36
- data/spec/city/yard_handlers_cucumber_spec.rb +0 -24
- data/spec/city/yard_namespace_object_spec.rb +0 -8
- data/spec/city/yard_parser_cucumber_spec.rb +0 -215
- data/spec/city/yard_rb_extensions_spec.rb +0 -128
- data/spec/spec_helper.rb +0 -5
@@ -1,23 +0,0 @@
|
|
1
|
-
<% if object.step_transforms %>
|
2
|
-
<h2>Step Transforms</h2>
|
3
|
-
<dl class="constants">
|
4
|
-
<% object.step_transforms.each do |step| %>
|
5
|
-
<dt>
|
6
|
-
<span style="font-weight: normal;">Transform</span>
|
7
|
-
<span style="constants"><%= step.value %></span>
|
8
|
-
</dt>
|
9
|
-
<dd><pre class="code"><%= step.source %></pre></dd>
|
10
|
-
<% end %>
|
11
|
-
</dl>
|
12
|
-
<table class="source_code">
|
13
|
-
<tr>
|
14
|
-
<td>
|
15
|
-
<pre class="lines"><%= "\n\n\n" %><%= h format_lines(object) %></pre>
|
16
|
-
</td>
|
17
|
-
<td>
|
18
|
-
<pre class="code"><span class="info file"># File '<%= h object.file %>'<% if object.line %>, line <%= object.line %><% end %></span><%= "\n\n" %><%= html_syntax_highlight object.source %></pre>
|
19
|
-
</td>
|
20
|
-
</tr>
|
21
|
-
</table>
|
22
|
-
|
23
|
-
<% end %>
|
@@ -1,50 +0,0 @@
|
|
1
|
-
<div class="title">
|
2
|
-
<div class="name">Step Definitions</div>
|
3
|
-
</div>
|
4
|
-
|
5
|
-
<div style="margin: 10px;"> </div>
|
6
|
-
|
7
|
-
<% if @step_transformers.definitions %>
|
8
|
-
<% @step_transformers.definitions.each_with_index do |stepdef,index| %>
|
9
|
-
|
10
|
-
<div class="stepdef">
|
11
|
-
<a name="<%= stepdef.name %>">
|
12
|
-
<div class="title">
|
13
|
-
<span class="pre"><%= stepdef.keyword %></span>
|
14
|
-
<span class="name"><%= stepdef.value %></span>
|
15
|
-
<div style="float: right;"><%= h( stepdef.location ) %></div>
|
16
|
-
</div>
|
17
|
-
|
18
|
-
|
19
|
-
<div class="steps">
|
20
|
-
<% if stepdef.steps && !stepdef.steps.empty? %>
|
21
|
-
<% stepdef.steps.each_with_index do |step,step_index| %>
|
22
|
-
<div class="step <%= (step_index + 1) % 2 == 0 ? 'even' : 'odd' %>">
|
23
|
-
<%= h("#{step.keyword} #{step.value}") %>
|
24
|
-
<div class="details"><a href="<%= "#{step.scenario.feature.name}.html" %>"><%= h(step.location) %></a></div>
|
25
|
-
</div>
|
26
|
-
<% end %>
|
27
|
-
<% else %>
|
28
|
-
<span class="undefined">No steps were found to match this step definition.</span>
|
29
|
-
<% end%>
|
30
|
-
</div>
|
31
|
-
|
32
|
-
<div class="source">
|
33
|
-
<span class="showSource">
|
34
|
-
[ <a href="#" class="toggleSource">View source</a> ]
|
35
|
-
</span>
|
36
|
-
<table class="source_code">
|
37
|
-
<tr>
|
38
|
-
<td>
|
39
|
-
<pre class="lines"><%= "" %><%= h format_lines(stepdef) %></pre>
|
40
|
-
</td>
|
41
|
-
<td>
|
42
|
-
<pre class="code"><%= "" %><%= html_syntax_highlight stepdef.source %></pre>
|
43
|
-
</td>
|
44
|
-
</tr>
|
45
|
-
</table>
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
|
49
|
-
<% end %>
|
50
|
-
<% end %>
|
@@ -1,65 +0,0 @@
|
|
1
|
-
<div class="tag">
|
2
|
-
<div class="title">
|
3
|
-
<span class="pre">Tag:</span>
|
4
|
-
<span class="name"><%= @tags.value %></span>
|
5
|
-
|
6
|
-
</div>
|
7
|
-
|
8
|
-
<div class="meta">
|
9
|
-
<div class="file">Usage:
|
10
|
-
<%= @tags.feature_count > 0 ? "#{@tags.feature_count} feature#{@tags.feature_count > 1 ? 's' : ''} (with #{@tags.indirect_scenario_count} scenario#{@tags.indirect_scenario_count > 1 ? 's' : ''})" : "" %>
|
11
|
-
<%= " and " if @tags.feature_count > 0 && @tags.scenario_count > 0 %>
|
12
|
-
<%= @tags.scenario_count > 0 ? "#{@tags.scenario_count} scenario#{@tags.scenario_count > 1 ? 's' : ''}" : "" %>
|
13
|
-
</div>
|
14
|
-
</div>
|
15
|
-
|
16
|
-
<% if @tags.tags %>
|
17
|
-
<% @tags.tags.each do |tag| %>
|
18
|
-
|
19
|
-
<% if tag.scenario %>
|
20
|
-
<div class="feature indirect">
|
21
|
-
<div class="title">
|
22
|
-
<span class="pre">Feature:</span>
|
23
|
-
<span class="name">
|
24
|
-
<a href="<%= "#{tag.scenario.feature.name}.html" %>"><%= tag.scenario.feature.value %></a>
|
25
|
-
</span>
|
26
|
-
</div>
|
27
|
-
<div class="description"><%= tag.scenario.feature.description %></div>
|
28
|
-
</div>
|
29
|
-
|
30
|
-
<div class="scenario direct">
|
31
|
-
<div class="title">
|
32
|
-
<span class="pre">Scenario:</span>
|
33
|
-
<span class="name">
|
34
|
-
<a href="<%= "#{tag.scenario.feature.name}.html" %>"><%= tag.scenario.value %></a>
|
35
|
-
</span>
|
36
|
-
</div>
|
37
|
-
<div class="description"><%= tag.scenario.description %></div>
|
38
|
-
</div>
|
39
|
-
<% else %>
|
40
|
-
<div class="feature direct">
|
41
|
-
<div class="title">
|
42
|
-
<span class="pre">Feature:</span>
|
43
|
-
<span class="name">
|
44
|
-
<a href="<%= "#{tag.feature.name}.html" %>"><%= tag.feature.value %></a>
|
45
|
-
</span>
|
46
|
-
</div>
|
47
|
-
<div class="description"><%= tag.feature.description %></div>
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<% tag.feature.scenarios.each do |scenario| %>
|
51
|
-
<div class="scenario indirect">
|
52
|
-
<div class="title">
|
53
|
-
<span class="pre">Scenario:</span>
|
54
|
-
<span class="name">
|
55
|
-
<a href="<%= "#{scenario.feature.name}.html" %>"><%= scenario.value %></a>
|
56
|
-
</span>
|
57
|
-
</div>
|
58
|
-
<div class="description"><%= scenario.description %></div>
|
59
|
-
</div>
|
60
|
-
<% end %>
|
61
|
-
<% end %>
|
62
|
-
|
63
|
-
<% end %>
|
64
|
-
<% end%>
|
65
|
-
</div>
|
@@ -1,153 +0,0 @@
|
|
1
|
-
|
2
|
-
shared_examples_for "a feature file" do
|
3
|
-
it "should have a defined feature" do
|
4
|
-
@parser.features.first.should_not be_nil
|
5
|
-
end
|
6
|
-
|
7
|
-
it "the feature should have a unique name" do
|
8
|
-
@parser.features.first.name.should == @feature[:file].gsub('.','_').to_sym
|
9
|
-
end
|
10
|
-
|
11
|
-
it "the feature should have the specified title" do
|
12
|
-
@parser.features.first.value.should == @feature[:name]
|
13
|
-
end
|
14
|
-
|
15
|
-
it "the feature should have all specified tags" do
|
16
|
-
@feature[:tags].find do |expected_tag|
|
17
|
-
@parser.features.first.tags.find{|tag| tag.value == expected_tag }
|
18
|
-
end.should_not be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "the feature should have the correct number of tags" do
|
22
|
-
@feature[:tags].each do |expected_tag|
|
23
|
-
@parser.features.first.tags.find_all {|tag| tag.value == expected_tag }.count.should == 1
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "the feature's tags should have a file" do
|
28
|
-
@parser.features.first.tags.each do |tag|
|
29
|
-
tag.files.should_not be_nil
|
30
|
-
tag.files.should_not be_empty
|
31
|
-
tag.files.first.first.should == @feature[:file]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "the feature should have a description" do
|
36
|
-
@parser.features.first.description.join("\n") == @feature[:description].join("\n")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "the feature should have a file" do
|
40
|
-
@parser.features.first.files.first[0].should == @feature[:file]
|
41
|
-
end
|
42
|
-
|
43
|
-
it "the feature should have a line number" do
|
44
|
-
@parser.features.first.files.first[1].should_not be_nil
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
shared_examples_for "a feature file with a background" do
|
50
|
-
|
51
|
-
it "the feature should have a background" do
|
52
|
-
@parser.features.first.background.should_not be_nil
|
53
|
-
end
|
54
|
-
|
55
|
-
it "the background should have a unique scenario name" do
|
56
|
-
@parser.features.first.background.name.should == "#{@feature[:file]}.background".gsub('.','_').to_sym
|
57
|
-
end
|
58
|
-
|
59
|
-
it "the background should have the correct title" do
|
60
|
-
@parser.features.first.background.value.should == "Background"
|
61
|
-
end
|
62
|
-
|
63
|
-
it "the background should have a file" do
|
64
|
-
@parser.features.first.background.files.first[0].should == @feature[:file]
|
65
|
-
end
|
66
|
-
|
67
|
-
it "the background should have a line number" do
|
68
|
-
@parser.features.first.background.files.first[1].should_not be_nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it "the background should have all their defined steps" do
|
72
|
-
@parser.features.first.scenarios.first.steps.should_not be_nil
|
73
|
-
if @background
|
74
|
-
@background.each_with_index do |step,index|
|
75
|
-
@parser.features.first.background.steps[index].value.should == step
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
it "the background steps should have files and line numbers" do
|
81
|
-
if @background
|
82
|
-
@background.each_with_index do |step,index|
|
83
|
-
@parser.features.first.background.steps[index].files.first[0].should == @feature[:file]
|
84
|
-
@parser.features.first.background.steps[index].files.first[1].should_not be_nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
shared_examples_for "a feature file with scenarios" do
|
92
|
-
it "should have all scenarios" do
|
93
|
-
@scenarios.each_with_index do |scenario,index|
|
94
|
-
@parser.features.first.scenarios[index].should_not be_nil
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
it "each scenario should have a unique scenario name" do
|
99
|
-
@parser.features.first.scenarios.first.name.should == "#{@feature[:file]}_scenario_0".gsub('.','_').to_sym
|
100
|
-
end
|
101
|
-
|
102
|
-
it "each scenario should have the correct title" do
|
103
|
-
@parser.features.first.scenarios.each_with_index do |scenario,index|
|
104
|
-
scenario.value.should == @scenarios[index][:title].join("\n")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
it "each scenario should have the correct tags" do
|
109
|
-
@scenarios.each_with_index do |scenario,index|
|
110
|
-
scenario[:tags].each do |expeced_tag|
|
111
|
-
@parser.features.first.scenarios[index].tags.find {|tag| tag.value == expeced_tag}.should_not be_nil
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it "each scenario should have the correct number of tags" do
|
117
|
-
@parser.features.first.scenarios.first.tags.find_all {|tag| tag.value == "@ninja" }.count.should == 1
|
118
|
-
end
|
119
|
-
|
120
|
-
it "each scenario should have a file" do
|
121
|
-
@parser.features.first.scenarios.first.files.first[0].should == @feature[:file]
|
122
|
-
end
|
123
|
-
|
124
|
-
it "each scenario should have a line number" do
|
125
|
-
@parser.features.first.scenarios.first.files.first[1].should_not be_nil
|
126
|
-
end
|
127
|
-
|
128
|
-
it "each scenario should have all their defined steps" do
|
129
|
-
@parser.features.first.scenarios.first.steps.should_not be_nil
|
130
|
-
if @scenarios
|
131
|
-
@scenarios.each_with_index do |scenario,scenario_index|
|
132
|
-
@parser.features.first.scenarios[scenario_index].should_not be_nil
|
133
|
-
|
134
|
-
scenario[:steps].each_with_index do |step,step_index|
|
135
|
-
@parser.features.first.scenarios[scenario_index].steps[step_index].name.should == "#{@feature[:file].gsub('.','_')}_scenario_#{scenario_index}_step_#{step_index}".to_sym
|
136
|
-
@parser.features.first.scenarios[scenario_index].steps[step_index].value.should == step
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
it "each scenario's steps should have files and line numbers" do
|
143
|
-
if @scenarios
|
144
|
-
@scenarios.each_with_index do |scenario,scenario_index|
|
145
|
-
scenario[:steps].each_with_index do |step,step_index|
|
146
|
-
@parser.features.first.scenarios[scenario_index].steps[step_index].files.first[0].should == @feature[:file]
|
147
|
-
@parser.features.first.scenarios[scenario_index].steps[step_index].files.first[1].should_not be_nil
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe "Gherkin" do
|
4
|
-
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
|
8
|
-
@source = File.dirname(__FILE__) + '/test.feature'
|
9
|
-
File.should exist(@source)
|
10
|
-
@data = File.open(@source, 'r').read
|
11
|
-
|
12
|
-
@parser = YARD::Parser::Cucumber::FeatureParser.new(@data,@source)
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
it "should not be nil" do
|
18
|
-
@parser.should_not be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should parse" do
|
22
|
-
@parser.parse
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should tokenize" do
|
26
|
-
@parser.tokenize
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should enumerator" do
|
30
|
-
@parser.enumerator
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
data/spec/city/test.feature
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
@customer
|
2
|
-
Feature: Customer Logout Feature
|
3
|
-
As a customer of the product I am able to logout
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given this undefined step definition
|
7
|
-
|
8
|
-
@bvt
|
9
|
-
Scenario: Customer that is logged in is able to log out
|
10
|
-
Given that a customer is a valid customer
|
11
|
-
And a customer logs in as username 'frank' with password 'default'
|
12
|
-
And I expect them to have logged in successfully
|
13
|
-
When the customer logs out
|
14
|
-
Then I expect the customer to be shown the logout page
|
15
|
-
|
16
|
-
Scenario: Customers with a complete profile are allowed to post
|
17
|
-
Given that a customer is a valid customer
|
18
|
-
And the customer has the following details:
|
19
|
-
| Name | Email | Age |
|
20
|
-
| Frank | f@email.com | 22 |
|
21
|
-
When a customer logs in as username 'frank' with password 'default'
|
22
|
-
And visits the customer update page
|
23
|
-
Then I expect the customer is able able to post to their profile
|
24
|
-
|
25
|
-
@product
|
26
|
-
Scenario Outline: Customers that bought a product are included in their product groups
|
27
|
-
Given that <Customer> is a valid customer
|
28
|
-
And that the product, named '<Product>', is a valid product
|
29
|
-
When the customer has purchased the product
|
30
|
-
Then I expect the customer to be a member of the '<Product>' group
|
31
|
-
|
32
|
-
Examples:
|
33
|
-
| Customer | Product |
|
34
|
-
| Customer A | Product A |
|
35
|
-
| Customer A | Product B |
|
36
|
-
| Customer A | Product C |
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
module YARD::Handlers::Cucumber
|
4
|
-
|
5
|
-
describe Base do
|
6
|
-
|
7
|
-
it "should respond to method handles?" do
|
8
|
-
Base.should respond_to(:handles?)
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
describe FeatureHandler do
|
14
|
-
|
15
|
-
it "should respond to method process" do
|
16
|
-
FeatureHandler.should respond_to(:process)
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
@@ -1,215 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require File.dirname(__FILE__) + '/feature_parser_spec_examples.rb'
|
3
|
-
|
4
|
-
module YARD::Parser::Cucumber
|
5
|
-
|
6
|
-
describe YARD::CodeObjects::Cucumber::Tag do
|
7
|
-
|
8
|
-
[:value].each do |attribute|
|
9
|
-
it "should respond to method #{attribute}" do
|
10
|
-
YARD::CodeObjects::Cucumber::Tag.new(:root,"tag_name").should respond_to(attribute)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
describe YARD::CodeObjects::Cucumber::Step do
|
17
|
-
|
18
|
-
[:value, :definition].each do |attribute|
|
19
|
-
it "should respond to method #{attribute}" do
|
20
|
-
YARD::CodeObjects::Cucumber::Step.new(:root,"name").should respond_to(attribute)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return the line prefix and the remainder" do
|
25
|
-
step = YARD::CodeObjects::Cucumber::Step.new(:root,"name") {|s| s.value = "Given something something" }
|
26
|
-
step.keyword.should == "Given"
|
27
|
-
step.line.should == "something something"
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
describe YARD::CodeObjects::Cucumber::Scenario do
|
33
|
-
|
34
|
-
[:value, :description, :steps, :tags ].each do |attribute|
|
35
|
-
it "should respond to method #{attribute}" do
|
36
|
-
YARD::CodeObjects::Cucumber::Scenario.new(:root,"name").should respond_to(attribute)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
describe YARD::CodeObjects::Cucumber::Feature do
|
43
|
-
|
44
|
-
[:value, :description, :scenarios, :background, :tags ].each do |attribute|
|
45
|
-
it "should respond to method #{attribute}" do
|
46
|
-
YARD::CodeObjects::Cucumber::Feature.new(:root,"name").should respond_to(attribute)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
describe FeatureParser do
|
54
|
-
|
55
|
-
|
56
|
-
it "should accept source and a file when created" do
|
57
|
-
lambda { FeatureParser.new("source code","filename") }.should_not raise_exception(Exception)
|
58
|
-
end
|
59
|
-
|
60
|
-
[ "parse", "tokenize", "enumerator" ].each do |required_method|
|
61
|
-
it "should have a method named #{required_method}" do
|
62
|
-
FeatureParser.instance_methods.should include(required_method)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should return itself when parse is called" do
|
67
|
-
parser = FeatureParser.new("source","filename")
|
68
|
-
parser.parse.should == parser
|
69
|
-
end
|
70
|
-
|
71
|
-
context "feature file with tags, feature, and description" do
|
72
|
-
|
73
|
-
before(:all) do
|
74
|
-
@feature = { :file => 'new.exciting.feature',
|
75
|
-
:name => "New Exciting Feature",
|
76
|
-
:tags => [ "@bvt", "@build", "@wip" ],
|
77
|
-
:description => [ "This feature is going to save the company." ] }
|
78
|
-
|
79
|
-
@parser = FeatureParser.new(%{
|
80
|
-
#{@feature[:tags].join(" ")}
|
81
|
-
Feature: #{@feature[:name]}
|
82
|
-
#{@feature[:description].join("\n")}
|
83
|
-
},@feature[:file])
|
84
|
-
|
85
|
-
@parser = @parser.parse
|
86
|
-
end
|
87
|
-
|
88
|
-
after(:all) do
|
89
|
-
@parser = nil
|
90
|
-
end
|
91
|
-
|
92
|
-
it_should_behave_like "a feature file"
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
context "feature file with a description that uses step keywords" do
|
97
|
-
|
98
|
-
before(:all) do
|
99
|
-
@feature = { :file => 'description.with.keywords.feature',
|
100
|
-
:name => "Fully Described Feature",
|
101
|
-
:tags => [ "@bvt", "@build", "@wip" ],
|
102
|
-
:description => ["As a product owner",
|
103
|
-
"When I ask about the work done",
|
104
|
-
"Then I want to see what this cukes things is all about",
|
105
|
-
"And I really want a straight answer",
|
106
|
-
"Given that I can be provided with one"] }
|
107
|
-
|
108
|
-
@parser = FeatureParser.new(%{
|
109
|
-
#{@feature[:tags].join(" ")}
|
110
|
-
Feature: #{@feature[:name]}
|
111
|
-
#{@feature[:description].join("\n")}
|
112
|
-
},@feature[:file])
|
113
|
-
|
114
|
-
@parser = @parser.parse
|
115
|
-
end
|
116
|
-
|
117
|
-
after(:all) do
|
118
|
-
@parser = nil
|
119
|
-
end
|
120
|
-
|
121
|
-
it_should_behave_like "a feature file"
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
|
126
|
-
context "feature file with background and one scenario" do
|
127
|
-
|
128
|
-
before(:all) do
|
129
|
-
|
130
|
-
@feature = { :file => "ninja.exciting.feature",
|
131
|
-
:name => "Ninja Feature Set",
|
132
|
-
:tags => [ "@bvt", "@build", "@wip" ],
|
133
|
-
:description => ["This feature is going to save the company"] }
|
134
|
-
|
135
|
-
@background = [ "Given that I have taken a nap" ]
|
136
|
-
|
137
|
-
@scenarios = [ { :tags => ["@ninja"],
|
138
|
-
:title => ["Ninja striking an opponent in the morning"],
|
139
|
-
:steps => [ "Given that there is an opponent",
|
140
|
-
"And a reason to fight him",
|
141
|
-
"When I karate strike him",
|
142
|
-
"Then I expect him to fall" ] } ]
|
143
|
-
|
144
|
-
@parser = FeatureParser.new(%{
|
145
|
-
#{@feature[:tags].join(" ")}
|
146
|
-
Feature: #{@feature[:name]}
|
147
|
-
#{@feature[:description].join("\n")}
|
148
|
-
Background:
|
149
|
-
#{@background.join("\n")}
|
150
|
-
#{@scenarios.first[:tags].join(" ")}
|
151
|
-
Scenario: #{@scenarios.first[:title].join("\n")}
|
152
|
-
#{@scenarios.first[:steps].join("\n")}
|
153
|
-
},@feature[:file])
|
154
|
-
@parser = @parser.parse
|
155
|
-
end
|
156
|
-
|
157
|
-
after(:all) do
|
158
|
-
@parser = nil
|
159
|
-
end
|
160
|
-
|
161
|
-
it_should_behave_like "a feature file"
|
162
|
-
it_should_behave_like "a feature file with a background"
|
163
|
-
it_should_behave_like "a feature file with scenarios"
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
context "feature file no background and multiple scenarios" do
|
168
|
-
|
169
|
-
before(:all) do
|
170
|
-
|
171
|
-
@feature = { :file => "ninja.strike.feature",
|
172
|
-
:name => "Ninja Feature Set",
|
173
|
-
:tags => [ "@kill", "@silently", "@sneak" ],
|
174
|
-
:description => ["This feature is going to save the company"] }
|
175
|
-
|
176
|
-
@scenarios = [
|
177
|
-
{ :tags => ["@ninja"],
|
178
|
-
:title => ["Killing Scenario"],
|
179
|
-
:steps => [ "Given that there is an opponent",
|
180
|
-
"And a reason to fight him",
|
181
|
-
"When I karate strike him",
|
182
|
-
"Then I expect him to fall" ] },
|
183
|
-
{ :tags => [],
|
184
|
-
:title => ["Dissappearing Scenario"],
|
185
|
-
:steps => [ "Given that I have defeated an opponent",
|
186
|
-
"And there are no more opponents",
|
187
|
-
"When I stop to take a breath",
|
188
|
-
"Then I expect to dissapear" ] } ]
|
189
|
-
|
190
|
-
@parser = FeatureParser.new(%{
|
191
|
-
#{@feature[:tags].join(" ")}
|
192
|
-
Feature: #{@feature[:name]}
|
193
|
-
#{@feature[:description].join("\n")}
|
194
|
-
#{@scenarios.collect {|scenario|
|
195
|
-
scenario[:tags].join(" ") +
|
196
|
-
"\nScenario: " + scenario[:title].join("\n") + "\n" +
|
197
|
-
scenario[:steps].join("\n")
|
198
|
-
}.join("\n")}},@feature[:file])
|
199
|
-
@parser = @parser.parse
|
200
|
-
end
|
201
|
-
|
202
|
-
after(:all) do
|
203
|
-
@parser = nil
|
204
|
-
end
|
205
|
-
|
206
|
-
it_should_behave_like "a feature file"
|
207
|
-
it_should_behave_like "a feature file with scenarios"
|
208
|
-
|
209
|
-
end
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
end
|
214
|
-
|
215
|
-
end
|