cukable 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +47 -0
- data/README.md +368 -0
- data/Rakefile +41 -0
- data/bin/cuke2fit +25 -0
- data/cukable.gemspec +26 -0
- data/features/conversion.feature +54 -0
- data/features/cuke_fixture.feature +147 -0
- data/features/slim_json_formatter.feature +153 -0
- data/features/step_definitions/cukable_steps.rb +115 -0
- data/features/support/env.rb +183 -0
- data/lib/cukable.rb +2 -0
- data/lib/cukable/conversion.rb +314 -0
- data/lib/cukable/cuke.rb +305 -0
- data/lib/cukable/helper.rb +221 -0
- data/lib/cukable/slim_json_formatter.rb +366 -0
- data/spec/conversion_spec.rb +275 -0
- data/spec/cuke_spec.rb +134 -0
- data/spec/helper_spec.rb +203 -0
- data/spec/spec_helper.rb +10 -0
- data/vendor/cache/rubyslim-0.1.1.gem +0 -0
- metadata +188 -0
data/bin/cuke2fit
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Script to convert Cucumber features into FitNesse wiki pages
|
4
|
+
|
5
|
+
# Desired behavior:
|
6
|
+
#
|
7
|
+
# - Recursively search for .feature files in a directory
|
8
|
+
# - Create a FitNesse wiki hierarchy that mirrors the .feature hierarchy, with
|
9
|
+
# one wiki page for each .feature file
|
10
|
+
# - Fill those wiki pages with a table - essentially just the text of the
|
11
|
+
# .feature file with |...| wrapping each line. Empty lines should be skipped.
|
12
|
+
#
|
13
|
+
|
14
|
+
require 'cukable/conversion'
|
15
|
+
|
16
|
+
if ARGV.count == 0
|
17
|
+
puts "Usage: cuke2fit.rb <features_path> <fitnesse_path>"
|
18
|
+
else
|
19
|
+
converter = Cukable::Converter.new
|
20
|
+
messages = converter.features_to_fitnesse(ARGV[0], ARGV[1])
|
21
|
+
messages.each do |message|
|
22
|
+
puts message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
data/cukable.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "cukable"
|
3
|
+
s.version = "0.1.1"
|
4
|
+
s.summary = "Runs Cucumber tests from FitNesse"
|
5
|
+
s.description = <<-EOS
|
6
|
+
Cukable allows running Cucumber test scenarios from FitNesse
|
7
|
+
EOS
|
8
|
+
s.authors = ["Eric Pierce", "Ken Brazier"]
|
9
|
+
s.email = "wapcaplet88@gmail.com"
|
10
|
+
s.homepage = "http://github.com/wapcaplet/cukable"
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
|
13
|
+
s.add_dependency 'json'
|
14
|
+
s.add_dependency 'cucumber'
|
15
|
+
s.add_dependency 'diff-lcs'
|
16
|
+
|
17
|
+
s.add_development_dependency 'rspec', '>= 2.2.0'
|
18
|
+
s.add_development_dependency 'rcov'
|
19
|
+
s.add_development_dependency 'yard'
|
20
|
+
s.add_development_dependency 'bluecloth'
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.require_path = 'lib'
|
24
|
+
|
25
|
+
s.executables = ['cuke2fit']
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Feature: Conversion
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a standard Cucumber project directory structure
|
5
|
+
And a FitNesse wiki
|
6
|
+
|
7
|
+
Scenario: Convert features to FitNesse
|
8
|
+
Given a file named "features/passing.feature" with:
|
9
|
+
"""
|
10
|
+
Feature: Passing
|
11
|
+
Scenario: Passing
|
12
|
+
Given a step passes
|
13
|
+
"""
|
14
|
+
And a file named "features/failing.feature" with:
|
15
|
+
"""
|
16
|
+
Feature: Failing
|
17
|
+
Scenario: Failing
|
18
|
+
Given a step fails
|
19
|
+
"""
|
20
|
+
When I convert features to FitNesse
|
21
|
+
|
22
|
+
Then I should have a Suite "FeatureS" containing:
|
23
|
+
"""
|
24
|
+
These variables must be defined for rubyslim to work:
|
25
|
+
!define TEST_SYSTEM {slim}
|
26
|
+
!define TEST_RUNNER {rubyslim}
|
27
|
+
!define COMMAND_PATTERN {rubyslim}
|
28
|
+
|
29
|
+
Extra command-line arguments to pass to Cucumber:
|
30
|
+
!define CUCUMBER_ARGS {}
|
31
|
+
|
32
|
+
!contents -R9 -p -f -h
|
33
|
+
"""
|
34
|
+
|
35
|
+
And I should have a Test "FeatureS/AaaAccelerator" containing:
|
36
|
+
"""
|
37
|
+
"""
|
38
|
+
|
39
|
+
And I should have a Test "FeatureS/PassingFeature" containing:
|
40
|
+
"""
|
41
|
+
!| Table: Cuke |
|
42
|
+
| Feature: Passing |
|
43
|
+
| Scenario: Passing |
|
44
|
+
| Given a step passes |
|
45
|
+
"""
|
46
|
+
|
47
|
+
And I should have a Test "FeatureS/FailingFeature" containing:
|
48
|
+
"""
|
49
|
+
!| Table: Cuke |
|
50
|
+
| Feature: Failing |
|
51
|
+
| Scenario: Failing |
|
52
|
+
| Given a step fails |
|
53
|
+
"""
|
54
|
+
|
@@ -0,0 +1,147 @@
|
|
1
|
+
Feature: Cuke fixture
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a standard Cucumber project directory structure
|
5
|
+
|
6
|
+
Scenario: Do table
|
7
|
+
Given a Cuke fixture
|
8
|
+
When I do this table:
|
9
|
+
| Feature: Table |
|
10
|
+
| Scenario: Table |
|
11
|
+
|
12
|
+
Then "slim_results/features/fitnesse/fitnesse_test.feature.json" should contain JSON:
|
13
|
+
"""
|
14
|
+
[
|
15
|
+
["report:Feature: Table"],
|
16
|
+
["report:Scenario: Table"]
|
17
|
+
]
|
18
|
+
"""
|
19
|
+
|
20
|
+
Scenario: Write features
|
21
|
+
Given a Cuke fixture
|
22
|
+
And a FitNesse wiki
|
23
|
+
And a FitNesse suite "TestSuite" with:
|
24
|
+
"""
|
25
|
+
!contents
|
26
|
+
"""
|
27
|
+
And a FitNesse test "TestSuite/HelloWorld" with:
|
28
|
+
"""
|
29
|
+
| Table: Cuke |
|
30
|
+
| Feature: Hello |
|
31
|
+
| Scenario: Hello |
|
32
|
+
"""
|
33
|
+
And a FitNesse test "TestSuite/GoodbyeWorld" with:
|
34
|
+
"""
|
35
|
+
| Table: Cuke |
|
36
|
+
| Feature: Goodbye |
|
37
|
+
| Scenario: Goodbye |
|
38
|
+
"""
|
39
|
+
When I write features for suite "TestSuite"
|
40
|
+
|
41
|
+
Then "features/fitnesse/HelloWorld_0.feature" should contain:
|
42
|
+
"""
|
43
|
+
Feature: Hello
|
44
|
+
Scenario: Hello
|
45
|
+
"""
|
46
|
+
And "features/fitnesse/GoodbyeWorld_0.feature" should contain:
|
47
|
+
"""
|
48
|
+
Feature: Goodbye
|
49
|
+
Scenario: Goodbye
|
50
|
+
"""
|
51
|
+
|
52
|
+
|
53
|
+
Scenario: Accelerate suite
|
54
|
+
Given a FitNesse wiki
|
55
|
+
And a Cuke fixture
|
56
|
+
And a Suite "FeatureS" containing:
|
57
|
+
"""
|
58
|
+
!define TEST_SYSTEM {slim}
|
59
|
+
!define TEST_RUNNER {rubyslim}
|
60
|
+
!define COMMAND_PATTERN {rubyslim}
|
61
|
+
!define CUCUMBER_ARGS {}
|
62
|
+
"""
|
63
|
+
|
64
|
+
And a Test "FeatureS/AaaAccelerator" containing:
|
65
|
+
"""
|
66
|
+
"""
|
67
|
+
|
68
|
+
And a Test "FeatureS/PassingFeature" containing:
|
69
|
+
"""
|
70
|
+
!| Table: Cuke |
|
71
|
+
| Feature: Passing |
|
72
|
+
| Scenario: Passing |
|
73
|
+
| Given a step passes |
|
74
|
+
"""
|
75
|
+
|
76
|
+
And a Test "FeatureS/FailingFeature" containing:
|
77
|
+
"""
|
78
|
+
!| Table: Cuke |
|
79
|
+
| Feature: Failing |
|
80
|
+
| Scenario: Failing |
|
81
|
+
| Given a step fails |
|
82
|
+
"""
|
83
|
+
|
84
|
+
When I run the accelerator for suite "FeatureS"
|
85
|
+
|
86
|
+
Then "slim_results/features/fitnesse/PassingFeature_0.feature.json" should contain JSON:
|
87
|
+
"""
|
88
|
+
[
|
89
|
+
["report:Feature: Passing"],
|
90
|
+
["report:Scenario: Passing"],
|
91
|
+
["error:Given a step passes"]
|
92
|
+
]
|
93
|
+
"""
|
94
|
+
|
95
|
+
And "slim_results/features/fitnesse/FailingFeature_0.feature.json" should contain JSON:
|
96
|
+
"""
|
97
|
+
[
|
98
|
+
["report:Feature: Failing"],
|
99
|
+
["report:Scenario: Failing"],
|
100
|
+
["error:Given a step fails"]
|
101
|
+
]
|
102
|
+
"""
|
103
|
+
|
104
|
+
|
105
|
+
@wip
|
106
|
+
Scenario: Accelerate suite with skipped tags
|
107
|
+
# FIXME: Fails when run with other scenarios. Lack of init/cleanup in self_test dir?
|
108
|
+
Given a FitNesse wiki
|
109
|
+
And a Cuke fixture
|
110
|
+
|
111
|
+
And a Test "FeatureS/SkippedScenariosFeature" containing:
|
112
|
+
"""
|
113
|
+
!| Table: Cuke |
|
114
|
+
| Feature: Passing |
|
115
|
+
| @skip |
|
116
|
+
| Scenario: Skipped scenario |
|
117
|
+
| Given a step passes |
|
118
|
+
| Scenario: Passing |
|
119
|
+
| Given a step passes |
|
120
|
+
| @skip |
|
121
|
+
| Scenario: Another skipped scenario |
|
122
|
+
| Given a step passes |
|
123
|
+
"""
|
124
|
+
|
125
|
+
And a Test "FeatureS/SkippedFeature" containing:
|
126
|
+
"""
|
127
|
+
!| Table: Cuke |
|
128
|
+
| @skip |
|
129
|
+
| Feature: Skipped feature |
|
130
|
+
| Scenario: Failing |
|
131
|
+
| Given a step fails |
|
132
|
+
"""
|
133
|
+
|
134
|
+
When I set CUCUMBER_ARGS to "--tags ~@skip"
|
135
|
+
And I run the accelerator for suite "FeatureS"
|
136
|
+
|
137
|
+
Then "slim_results/features/fitnesse/SkippedScenariosFeature_0.feature.json" should contain JSON:
|
138
|
+
"""
|
139
|
+
[
|
140
|
+
["report:Feature: Passing"],
|
141
|
+
["report:Scenario: Passing"],
|
142
|
+
["error:Given a step passes"]
|
143
|
+
]
|
144
|
+
"""
|
145
|
+
|
146
|
+
And "slim_results/features/fitnesse/SkippedFeature_0.feature.json" should not exist
|
147
|
+
|
@@ -0,0 +1,153 @@
|
|
1
|
+
@wip
|
2
|
+
Feature: Slim JSON Formatter
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given a standard Cucumber project directory structure
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Passing step
|
9
|
+
Given a file named "features/passing.feature" with:
|
10
|
+
"""
|
11
|
+
Feature: Passing
|
12
|
+
Scenario: Passing
|
13
|
+
Given a step passes
|
14
|
+
"""
|
15
|
+
When I run cucumber on "features/passing.feature"
|
16
|
+
Then "slim_results/features/passing.feature.json" should contain JSON:
|
17
|
+
"""
|
18
|
+
[
|
19
|
+
["report:Feature: Passing"],
|
20
|
+
["report:Scenario: Passing"],
|
21
|
+
["pass:Given a step passes"]
|
22
|
+
]
|
23
|
+
"""
|
24
|
+
|
25
|
+
|
26
|
+
Scenario: Failing step
|
27
|
+
Given a file named "features/failing.feature" with:
|
28
|
+
"""
|
29
|
+
Feature: Failing
|
30
|
+
Scenario: Failing
|
31
|
+
Given a step fails
|
32
|
+
"""
|
33
|
+
When I run cucumber on "features/failing.feature"
|
34
|
+
Then "slim_results/features/failing.feature.json" should contain JSON:
|
35
|
+
"""
|
36
|
+
[
|
37
|
+
["report:Feature: Failing"],
|
38
|
+
["report:Scenario: Failing"],
|
39
|
+
["fail:Given a step fails"]
|
40
|
+
]
|
41
|
+
"""
|
42
|
+
|
43
|
+
|
44
|
+
Scenario: Undefined step
|
45
|
+
Given a file named "features/undefined.feature" with:
|
46
|
+
"""
|
47
|
+
Feature: Undefined
|
48
|
+
Scenario: Undefined
|
49
|
+
Given a step is undefined
|
50
|
+
"""
|
51
|
+
When I run cucumber on "features/undefined.feature"
|
52
|
+
Then "slim_results/features/undefined.feature.json" should contain JSON:
|
53
|
+
"""
|
54
|
+
[
|
55
|
+
["report:Feature: Undefined"],
|
56
|
+
["report:Scenario: Undefined"],
|
57
|
+
["error:Given a step is undefined"]
|
58
|
+
]
|
59
|
+
"""
|
60
|
+
|
61
|
+
|
62
|
+
Scenario: Skipped step
|
63
|
+
Given a file named "features/skipped.feature" with:
|
64
|
+
"""
|
65
|
+
Feature: Skipped
|
66
|
+
Scenario: Skipped
|
67
|
+
When a step fails
|
68
|
+
Then a step is skipped
|
69
|
+
"""
|
70
|
+
When I run cucumber on "features/skipped.feature"
|
71
|
+
Then "slim_results/features/skipped.feature.json" should contain JSON:
|
72
|
+
"""
|
73
|
+
[
|
74
|
+
["report:Feature: Skipped"],
|
75
|
+
["report:Scenario: Skipped"],
|
76
|
+
["fail:When a step fails"],
|
77
|
+
["ignore:Then a step is skipped"]
|
78
|
+
]
|
79
|
+
"""
|
80
|
+
|
81
|
+
|
82
|
+
Scenario: Passing table
|
83
|
+
Given a file named "features/passing_table.feature" with:
|
84
|
+
"""
|
85
|
+
Feature: Passing table
|
86
|
+
Scenario: Passing table
|
87
|
+
When I have a table:
|
88
|
+
| OK | OK | OK |
|
89
|
+
| OK | OK | OK |
|
90
|
+
"""
|
91
|
+
When I run cucumber on "features/passing_table.feature"
|
92
|
+
Then "slim_results/features/passing_table.feature.json" should contain JSON:
|
93
|
+
"""
|
94
|
+
[
|
95
|
+
["report:Feature: Passing table"],
|
96
|
+
["report:Scenario: Passing table"],
|
97
|
+
["pass:When I have a table:"],
|
98
|
+
["report: ", "pass:OK", "pass:OK", "pass:OK"],
|
99
|
+
["report: ", "pass:OK", "pass:OK", "pass:OK"]
|
100
|
+
]
|
101
|
+
"""
|
102
|
+
|
103
|
+
|
104
|
+
Scenario: Failing table
|
105
|
+
Given a file named "features/failing_table.feature" with:
|
106
|
+
"""
|
107
|
+
Feature: Failing table
|
108
|
+
Scenario: Failing table
|
109
|
+
When I have a table:
|
110
|
+
| OK | OK | OK |
|
111
|
+
| OK | FAIL | OK |
|
112
|
+
"""
|
113
|
+
When I run cucumber on "features/failing_table.feature"
|
114
|
+
Then "slim_results/features/failing_table.feature.json" should contain JSON:
|
115
|
+
# FIXME: The table rows should probably not be marked 'pass' here!
|
116
|
+
"""
|
117
|
+
[
|
118
|
+
["report:Feature: Failing table"],
|
119
|
+
["report:Scenario: Failing table"],
|
120
|
+
["fail:When I have a table:"],
|
121
|
+
["report: ", "pass:OK", "pass:OK", "pass:OK"],
|
122
|
+
["report: ", "pass:OK", "pass:FAIL", "pass:OK"]
|
123
|
+
]
|
124
|
+
"""
|
125
|
+
|
126
|
+
|
127
|
+
Scenario: Scenario Outline
|
128
|
+
Given a file named "features/scenario_outline.feature" with:
|
129
|
+
"""
|
130
|
+
Feature: Failing table
|
131
|
+
Scenario Outline: Outline
|
132
|
+
Given a step <result>
|
133
|
+
|
134
|
+
Examples:
|
135
|
+
| result |
|
136
|
+
| passes |
|
137
|
+
| fails |
|
138
|
+
"""
|
139
|
+
When I run cucumber on "features/scenario_outline.feature"
|
140
|
+
Then "slim_results/features/scenario_outline.feature.json" should contain JSON:
|
141
|
+
"""
|
142
|
+
[
|
143
|
+
["report:Feature: Failing table"],
|
144
|
+
["report:Scenario Outline: Outline"],
|
145
|
+
["ignore:Given a step <result>"],
|
146
|
+
["report:Examples: "],
|
147
|
+
["report: ", "pass:result"],
|
148
|
+
["report: ", "pass:passes"],
|
149
|
+
["report: ", "fail:fails"],
|
150
|
+
["fail:<br/>"]
|
151
|
+
]
|
152
|
+
"""
|
153
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# Steps for Cukable self-tests
|
2
|
+
# NOTE: Helper methods are defined in features/support/env.rb
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'cukable/cuke'
|
6
|
+
|
7
|
+
|
8
|
+
Given /^a standard Cucumber project directory structure$/ do
|
9
|
+
create_standard_cucumber_dir
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
Given /^a FitNesse wiki$/ do
|
14
|
+
create_standard_fitnesse_dir
|
15
|
+
@fitnesse_root = 'FitNesseRoot'
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
Given /^a FitNesse suite "(.+)" with:$/ do |page_name, content|
|
20
|
+
create_fitnesse_page(page_name, content)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
Given /^a FitNesse test "(.+)" with:$/ do |page_name, content|
|
25
|
+
create_fitnesse_page(page_name, content)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
Given /^a file named "(.+)" with:$/ do |filename, content|
|
30
|
+
create_file(filename, content)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
When /^I run cucumber on "(.+)"$/ do |feature_files|
|
35
|
+
format = "--format Cucumber::Formatter::SlimJSON --out slim_results"
|
36
|
+
run_cucumber("#{format} #{feature_files}")
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
Then /^"(.+)" should contain:$/ do |filename, text|
|
41
|
+
file_should_contain(filename, text)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
Then /^"(.+)" should contain JSON:$/ do |filename, json_text|
|
46
|
+
file_should_contain_json(filename, json_text)
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
Then /^"(.+)" should not exist$/ do |filename|
|
51
|
+
in_test_dir do
|
52
|
+
if File.exist?(filename)
|
53
|
+
raise Exception, "Expected #{filename} to be non-existent, but it exists"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
Given /^a (Test|Suite) "(.+)" containing:$/ do |type, filename, content|
|
60
|
+
content_file = File.join(@fitnesse_root, filename, 'content.txt')
|
61
|
+
properties_file = File.join(@fitnesse_root, filename, 'properties.xml')
|
62
|
+
create_file(content_file, content)
|
63
|
+
create_file(properties_file, xml_content(type))
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
Then /^I should have a (Test|Suite) "(.+)" containing:$/ do |type, filename, content|
|
68
|
+
content_file = File.join(@fitnesse_root, filename, 'content.txt')
|
69
|
+
properties_file = File.join(@fitnesse_root, filename, 'properties.xml')
|
70
|
+
file_should_contain(content_file, content)
|
71
|
+
file_should_contain(properties_file, xml_content(type))
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
Given /^a Cuke fixture$/ do
|
76
|
+
in_test_dir do
|
77
|
+
@cuke = Cukable::Cuke.new
|
78
|
+
@cucumber_args = ''
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
When /^I do this table:$/ do |table|
|
84
|
+
in_test_dir do
|
85
|
+
@table = @cuke.do_table(table.raw)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
When /^I write features for suite "(.+)"$/ do |suite_name|
|
91
|
+
in_test_dir do
|
92
|
+
@cuke.write_suite_features("FitNesseRoot/#{suite_name}")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
When /^I convert features to FitNesse$/ do
|
98
|
+
in_test_dir do
|
99
|
+
@converter = Cukable::Converter.new
|
100
|
+
@converter.features_to_fitnesse('features', @fitnesse_root)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
When /^I set CUCUMBER_ARGS to "(.+)"$/ do |args|
|
106
|
+
@cucumber_args = args
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
When /^I run the accelerator for suite "(.+)"$/ do |suite_name|
|
111
|
+
in_test_dir do
|
112
|
+
@cuke.accelerate("#{suite_name}.AaaAccelerator", @cucumber_args)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|