cuketagger 1.5 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +13 -0
- data/Gemfile +18 -0
- data/History.md +11 -0
- data/LICENSE.txt +23 -0
- data/README.markdown +60 -8
- data/Rakefile +21 -55
- data/bin/cuketagger +5 -5
- data/cuketagger.gemspec +31 -0
- data/lib/cuketagger.rb +13 -18
- data/lib/cuketagger/array_list_extension.rb +13 -13
- data/lib/cuketagger/tagger.rb +231 -130
- data/lib/cuketagger/version.rb +3 -3
- data/testing/cucumber/features/.cucumber/stepdefs.json +146 -0
- data/testing/cucumber/features/cuketagger.feature +173 -0
- data/testing/cucumber/features/scenario_outline.feature +37 -0
- data/testing/cucumber/features/step_definitions/cuketagger_steps.rb +20 -0
- data/testing/cucumber/features/support/env.rb +11 -0
- data/testing/cuke_tagger_helper.rb +31 -0
- data/testing/rspec/spec/spec_helper.rb +27 -0
- data/testing/rspec/spec/tagger_integration_spec.rb +1548 -0
- data/testing/rspec/spec/tagger_unit_spec.rb +23 -0
- metadata +147 -64
- data/lib/cuketagger/tag_formatter.rb +0 -21
data/lib/cuketagger/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module CukeTagger
|
2
|
-
|
3
|
-
end
|
1
|
+
module CukeTagger
|
2
|
+
VERSION = '1.6.0'
|
3
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"source": "^a file named \"([^\\\"]*)\" with:$",
|
4
|
+
"flags": "",
|
5
|
+
"steps": [
|
6
|
+
{
|
7
|
+
"name": "a file named \"outline.feature\" with:",
|
8
|
+
"args": [
|
9
|
+
{
|
10
|
+
"offset": 14,
|
11
|
+
"val": "outline.feature"
|
12
|
+
}
|
13
|
+
]
|
14
|
+
}
|
15
|
+
]
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"source": "^I run cuketagger with \"([^\\\"]*)\"$",
|
19
|
+
"flags": "",
|
20
|
+
"steps": [
|
21
|
+
{
|
22
|
+
"name": "I run cuketagger with \"--force remove:two remove:three sample.feature:6\"",
|
23
|
+
"args": [
|
24
|
+
{
|
25
|
+
"offset": 23,
|
26
|
+
"val": "--force remove:two remove:three sample.feature:6"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"name": "I run cuketagger with \"add:fails add:bar outline.feature:4\"",
|
32
|
+
"args": [
|
33
|
+
{
|
34
|
+
"offset": 23,
|
35
|
+
"val": "add:fails add:bar outline.feature:4"
|
36
|
+
}
|
37
|
+
]
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "I run cuketagger with \"add:foo add:bar sample.feature:11\"",
|
41
|
+
"args": [
|
42
|
+
{
|
43
|
+
"offset": 23,
|
44
|
+
"val": "add:foo add:bar sample.feature:11"
|
45
|
+
}
|
46
|
+
]
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "I run cuketagger with \"remove:one add:bar sample.feature\"",
|
50
|
+
"args": [
|
51
|
+
{
|
52
|
+
"offset": 23,
|
53
|
+
"val": "remove:one add:bar sample.feature"
|
54
|
+
}
|
55
|
+
]
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"name": "I run cuketagger with \"remove:one add:bar sample.feature:3\"",
|
59
|
+
"args": [
|
60
|
+
{
|
61
|
+
"offset": 23,
|
62
|
+
"val": "remove:one add:bar sample.feature:3"
|
63
|
+
}
|
64
|
+
]
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"name": "I run cuketagger with \"remove:two remove:three sample.feature:6\"",
|
68
|
+
"args": [
|
69
|
+
{
|
70
|
+
"offset": 23,
|
71
|
+
"val": "remove:two remove:three sample.feature:6"
|
72
|
+
}
|
73
|
+
]
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"name": "I run cuketagger with \"remove:two remove:three sample.feature:6:11\"",
|
77
|
+
"args": [
|
78
|
+
{
|
79
|
+
"offset": 23,
|
80
|
+
"val": "remove:two remove:three sample.feature:6:11"
|
81
|
+
}
|
82
|
+
]
|
83
|
+
},
|
84
|
+
{
|
85
|
+
"name": "I run cuketagger with \"replace:nope:four sample.feature:6\"",
|
86
|
+
"args": [
|
87
|
+
{
|
88
|
+
"offset": 23,
|
89
|
+
"val": "replace:nope:four sample.feature:6"
|
90
|
+
}
|
91
|
+
]
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"name": "I run cuketagger with \"replace:two:four sample.feature:6\"",
|
95
|
+
"args": [
|
96
|
+
{
|
97
|
+
"offset": 23,
|
98
|
+
"val": "replace:two:four sample.feature:6"
|
99
|
+
}
|
100
|
+
]
|
101
|
+
}
|
102
|
+
]
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"source": "^I should see:$",
|
106
|
+
"flags": "",
|
107
|
+
"steps": [
|
108
|
+
{
|
109
|
+
"name": "I should see:",
|
110
|
+
"args": [
|
111
|
+
|
112
|
+
]
|
113
|
+
}
|
114
|
+
]
|
115
|
+
},
|
116
|
+
{
|
117
|
+
"source": "^the content of \"([^\\\"]*)\" should be:$",
|
118
|
+
"flags": "",
|
119
|
+
"steps": [
|
120
|
+
{
|
121
|
+
"name": "the content of \"sample.feature\" should be:",
|
122
|
+
"args": [
|
123
|
+
{
|
124
|
+
"offset": 16,
|
125
|
+
"val": "sample.feature"
|
126
|
+
}
|
127
|
+
]
|
128
|
+
}
|
129
|
+
]
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"source": "^I should see '(.+?)' in the output$",
|
133
|
+
"flags": "",
|
134
|
+
"steps": [
|
135
|
+
{
|
136
|
+
"name": "I should see 'expected \"@nope\" at sample.feature:6, skipping' in the output",
|
137
|
+
"args": [
|
138
|
+
{
|
139
|
+
"offset": 14,
|
140
|
+
"val": "expected \"@nope\" at sample.feature:6, skipping"
|
141
|
+
}
|
142
|
+
]
|
143
|
+
}
|
144
|
+
]
|
145
|
+
}
|
146
|
+
]
|
@@ -0,0 +1,173 @@
|
|
1
|
+
Feature: CukeTagger
|
2
|
+
In order to quickly add or remove tags
|
3
|
+
As a Cucumber user
|
4
|
+
I want to use cuketagger
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "sample.feature" with:
|
8
|
+
"""
|
9
|
+
# Feature comment
|
10
|
+
@one
|
11
|
+
Feature: Sample
|
12
|
+
|
13
|
+
@two @three
|
14
|
+
Scenario: Missing
|
15
|
+
Given missing
|
16
|
+
|
17
|
+
# Scenario comment
|
18
|
+
@three
|
19
|
+
Scenario: Passing
|
20
|
+
Given passing
|
21
|
+
| a | b |
|
22
|
+
| c | d |
|
23
|
+
|
24
|
+
"""
|
25
|
+
|
26
|
+
|
27
|
+
Scenario: Remove tags from specific scenario
|
28
|
+
When I run cuketagger with "remove:two remove:three sample.feature:6"
|
29
|
+
Then I should see:
|
30
|
+
"""
|
31
|
+
# Feature comment
|
32
|
+
@one
|
33
|
+
Feature: Sample
|
34
|
+
|
35
|
+
Scenario: Missing
|
36
|
+
Given missing
|
37
|
+
|
38
|
+
# Scenario comment
|
39
|
+
@three
|
40
|
+
Scenario: Passing
|
41
|
+
Given passing
|
42
|
+
| a | b |
|
43
|
+
| c | d |
|
44
|
+
|
45
|
+
"""
|
46
|
+
|
47
|
+
Scenario: Remove tags from multiple scenarios
|
48
|
+
When I run cuketagger with "remove:two remove:three sample.feature:6:11"
|
49
|
+
Then I should see:
|
50
|
+
"""
|
51
|
+
# Feature comment
|
52
|
+
@one
|
53
|
+
Feature: Sample
|
54
|
+
|
55
|
+
Scenario: Missing
|
56
|
+
Given missing
|
57
|
+
|
58
|
+
# Scenario comment
|
59
|
+
Scenario: Passing
|
60
|
+
Given passing
|
61
|
+
| a | b |
|
62
|
+
| c | d |
|
63
|
+
|
64
|
+
"""
|
65
|
+
|
66
|
+
Scenario: Add tags to specific scenario
|
67
|
+
When I run cuketagger with "add:foo add:bar sample.feature:11"
|
68
|
+
Then I should see:
|
69
|
+
"""
|
70
|
+
# Feature comment
|
71
|
+
@one
|
72
|
+
Feature: Sample
|
73
|
+
|
74
|
+
@two @three
|
75
|
+
Scenario: Missing
|
76
|
+
Given missing
|
77
|
+
|
78
|
+
# Scenario comment
|
79
|
+
@three @foo @bar
|
80
|
+
Scenario: Passing
|
81
|
+
Given passing
|
82
|
+
| a | b |
|
83
|
+
| c | d |
|
84
|
+
|
85
|
+
"""
|
86
|
+
|
87
|
+
Scenario: Add and remove tags from feature
|
88
|
+
When I run cuketagger with "remove:one add:bar sample.feature"
|
89
|
+
Then I should see:
|
90
|
+
"""
|
91
|
+
# Feature comment
|
92
|
+
@bar
|
93
|
+
Feature: Sample
|
94
|
+
|
95
|
+
@two @three
|
96
|
+
Scenario: Missing
|
97
|
+
Given missing
|
98
|
+
|
99
|
+
# Scenario comment
|
100
|
+
@three
|
101
|
+
Scenario: Passing
|
102
|
+
Given passing
|
103
|
+
| a | b |
|
104
|
+
| c | d |
|
105
|
+
|
106
|
+
"""
|
107
|
+
|
108
|
+
Scenario: Add and remove tags from feature with line given
|
109
|
+
When I run cuketagger with "remove:one add:bar sample.feature:3"
|
110
|
+
Then I should see:
|
111
|
+
"""
|
112
|
+
# Feature comment
|
113
|
+
@bar
|
114
|
+
Feature: Sample
|
115
|
+
|
116
|
+
@two @three
|
117
|
+
Scenario: Missing
|
118
|
+
Given missing
|
119
|
+
|
120
|
+
# Scenario comment
|
121
|
+
@three
|
122
|
+
Scenario: Passing
|
123
|
+
Given passing
|
124
|
+
| a | b |
|
125
|
+
| c | d |
|
126
|
+
|
127
|
+
"""
|
128
|
+
|
129
|
+
Scenario: Replace tags in feature
|
130
|
+
When I run cuketagger with "replace:two:four sample.feature:6"
|
131
|
+
Then I should see:
|
132
|
+
"""
|
133
|
+
# Feature comment
|
134
|
+
@one
|
135
|
+
Feature: Sample
|
136
|
+
|
137
|
+
@four @three
|
138
|
+
Scenario: Missing
|
139
|
+
Given missing
|
140
|
+
|
141
|
+
# Scenario comment
|
142
|
+
@three
|
143
|
+
Scenario: Passing
|
144
|
+
Given passing
|
145
|
+
| a | b |
|
146
|
+
| c | d |
|
147
|
+
|
148
|
+
"""
|
149
|
+
|
150
|
+
Scenario: Replace non-existing tag
|
151
|
+
When I run cuketagger with "replace:nope:four sample.feature:6"
|
152
|
+
Then I should see 'expected "@nope" at sample.feature:6, skipping' in the output
|
153
|
+
|
154
|
+
Scenario: Rewrite file
|
155
|
+
When I run cuketagger with "--force remove:two remove:three sample.feature:6"
|
156
|
+
Then the content of "sample.feature" should be:
|
157
|
+
"""
|
158
|
+
# Feature comment
|
159
|
+
@one
|
160
|
+
Feature: Sample
|
161
|
+
|
162
|
+
Scenario: Missing
|
163
|
+
Given missing
|
164
|
+
|
165
|
+
# Scenario comment
|
166
|
+
@three
|
167
|
+
Scenario: Passing
|
168
|
+
Given passing
|
169
|
+
| a | b |
|
170
|
+
| c | d |
|
171
|
+
|
172
|
+
"""
|
173
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Feature: Scenario Outline
|
2
|
+
|
3
|
+
|
4
|
+
Scenario: Add tag to scenario outline
|
5
|
+
Given a file named "outline.feature" with:
|
6
|
+
"""
|
7
|
+
Feature: Outline Sample
|
8
|
+
|
9
|
+
@foo
|
10
|
+
Scenario Outline: Test state
|
11
|
+
Given <state> without a table
|
12
|
+
Given <other_state> without a table
|
13
|
+
|
14
|
+
Examples: Rainbow colours
|
15
|
+
| state | other_state |
|
16
|
+
| missing | passing |
|
17
|
+
| passing | passing |
|
18
|
+
| failing | passing |
|
19
|
+
|
20
|
+
"""
|
21
|
+
When I run cuketagger with "add:fails add:bar outline.feature:4"
|
22
|
+
Then I should see:
|
23
|
+
"""
|
24
|
+
Feature: Outline Sample
|
25
|
+
|
26
|
+
@foo @fails @bar
|
27
|
+
Scenario Outline: Test state
|
28
|
+
Given <state> without a table
|
29
|
+
Given <other_state> without a table
|
30
|
+
|
31
|
+
Examples: Rainbow colours
|
32
|
+
| state | other_state |
|
33
|
+
| missing | passing |
|
34
|
+
| passing | passing |
|
35
|
+
| failing | passing |
|
36
|
+
|
37
|
+
"""
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Given /^a file named "([^\"]*)" with:$/ do |file_name, file_content|
|
2
|
+
CukeTaggerHelper.create_file(file_name, file_content)
|
3
|
+
(@created_files ||= []) << file_name
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^I run cuketagger with "([^\"]*)"$/ do |args|
|
7
|
+
@output = CukeTaggerHelper.run_cuketagger args
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^I should see:$/ do |string|
|
11
|
+
expect(@output).to eq(string)
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^the content of "([^\"]*)" should be:$/ do |file_name, expected_content|
|
15
|
+
expect(File.read(file_name)).to eq(expected_content)
|
16
|
+
end
|
17
|
+
|
18
|
+
Then /^I should see '(.+?)' in the output$/ do |str|
|
19
|
+
expect(@output).to include(str)
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
|
4
|
+
module CukeTaggerHelper
|
5
|
+
extend Open3
|
6
|
+
|
7
|
+
@@file_count = 1
|
8
|
+
ROOT = File.expand_path "#{File.dirname(__FILE__)}/.."
|
9
|
+
|
10
|
+
def self.create_file(file_name, file_content)
|
11
|
+
File.open(file_name, 'w') { |f| f << file_content }
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.run_cuketagger(args)
|
15
|
+
%x{#{cuketagger} #{args} 2>&1}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.cuketagger
|
19
|
+
"ruby -W0 -rubygems #{'-d ' if $DEBUG} #{ROOT}/bin/cuketagger"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.log_message(message)
|
23
|
+
File.open('ct_logfile.txt', 'a') { |file| file.puts message }
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.save_file(content)
|
27
|
+
File.write("target_file_#{@@file_count}.feature", content)
|
28
|
+
@@file_count += 1
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
this_dir = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require "#{this_dir}/../../cuke_tagger_helper"
|
4
|
+
require "#{this_dir}/../../../lib/cuketagger"
|
5
|
+
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
|
9
|
+
config.before(:all) do
|
10
|
+
@default_file_directory = "#{this_dir}/temp_files"
|
11
|
+
@default_feature_file_name = 'test_feature.feature'
|
12
|
+
|
13
|
+
logfile = 'ct_logfile.txt'
|
14
|
+
File.delete(logfile) if File.exists?(logfile)
|
15
|
+
end
|
16
|
+
|
17
|
+
config.before(:all) do |spec|
|
18
|
+
FileUtils.remove_dir(@default_file_directory, true) if File.exists?(@default_file_directory)
|
19
|
+
|
20
|
+
FileUtils.mkdir(@default_file_directory)
|
21
|
+
end
|
22
|
+
|
23
|
+
config.after(:all) do |spec|
|
24
|
+
FileUtils.remove_dir(@default_file_directory, true)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|