cukecutter 0.0.6 → 0.0.7
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 +4 -4
- data/bin/cutcuke +9 -0
- data/lib/cukecutter.rb +119 -119
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42899ed903cb2d706ae561dfc26654b396ba871d
|
4
|
+
data.tar.gz: dd5947540029d2bff56fe859e42e4a4a240389c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b7a210e8008b64a94c5011d988ada82398de0878da2b305af24b245a2b3ec85cb45324a432fbadcffee5aef6f1e37d6c7dfc687d38f6265af0e38a3e59cc947
|
7
|
+
data.tar.gz: 7752bdf04f15a5c732209646e6fcec0348925995a728299e4d78fe1ed0152ef98125976c889dbf26f9f0af6262e24cafb22c688552d96625f214d22fa08b9366
|
data/bin/cutcuke
ADDED
data/lib/cukecutter.rb
CHANGED
@@ -1,120 +1,120 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
# @example include 'cukecutter' and run from command line
|
4
|
-
# cukecutter = Cukecutter.new
|
5
|
-
# cukecutter.create_structure
|
6
|
-
# cukecutter.create_feature
|
7
|
-
# cukecutter.steps
|
8
|
-
# cukecutter.cucumber_wrapper
|
9
|
-
|
10
|
-
class Cukecutter
|
11
|
-
|
12
|
-
def feature(feature, scenario)
|
13
|
-
@feature = feature
|
14
|
-
@scenario = scenario
|
15
|
-
@tags = tags
|
16
|
-
@description = description
|
17
|
-
end
|
18
|
-
|
19
|
-
# Creates the following folders
|
20
|
-
# features/
|
21
|
-
# features/step_definitions
|
22
|
-
# features/support
|
23
|
-
# And the file
|
24
|
-
# features/support/env.rb
|
25
|
-
def create_structure
|
26
|
-
if File.exists?("features") && File.directory?("features")
|
27
|
-
return
|
28
|
-
else
|
29
|
-
FileUtils.mkpath "features/step_definitions"
|
30
|
-
FileUtils.mkdir "features/support"
|
31
|
-
FileUtils.mkdir "features/screenshots"
|
32
|
-
FileUtils.touch"features/support/env.rb"
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
# create features from list in features.md
|
39
|
-
def create_bulk
|
40
|
-
file = File.new("features.md", "r")
|
41
|
-
while (line = file.gets)
|
42
|
-
line = line.chomp.strip.gsub(' ', '_')
|
43
|
-
FileUtils.touch "features/#{line}.feature"
|
44
|
-
FileUtils.touch "features/step_definitions/#{line}.steps.rb"
|
45
|
-
end
|
46
|
-
file.close
|
47
|
-
end
|
48
|
-
|
49
|
-
def create_feature
|
50
|
-
print "Feature name: "
|
51
|
-
@feature = gets.chomp
|
52
|
-
print "Feature description: "
|
53
|
-
@description = gets.chomp
|
54
|
-
print "Tags seperated by spaces (ex: @api):"
|
55
|
-
@tags = gets.chomp
|
56
|
-
print "Scenario: "
|
57
|
-
@scenario = gets.chomp
|
58
|
-
puts "please enter steps:"
|
59
|
-
puts "Cucumber steps starts with 'Given, When, Then, And, But' keywords."
|
60
|
-
end
|
61
|
-
|
62
|
-
# Creates .feature and .steps.rb files
|
63
|
-
def write_feature
|
64
|
-
File.open("features/""#{@feature.gsub(" ", "_")}.feature", "w") do |f|
|
65
|
-
f.write("#{@tags}\n")
|
66
|
-
f.write("Feature: #{@feature}\n")
|
67
|
-
f.write("Description: #{@description}\n\n")
|
68
|
-
f.write("\tScenario: #{@scenario}\n")
|
69
|
-
end
|
70
|
-
@steps.each do |steps|
|
71
|
-
File.open("features/""#{@feature.gsub(" ", "_")}.feature", "a") do |f|
|
72
|
-
f.write("\t\t#{steps}")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
FileUtils.touch "features/step_definitions/#{@feature.gsub(" ", "_")}.steps.rb"
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
# Console based walkthrough for feature and step creation
|
80
|
-
def steps
|
81
|
-
steps_keywords = %w(Given When Then And But)
|
82
|
-
nsteps = 0
|
83
|
-
@steps = []
|
84
|
-
while true
|
85
|
-
print "Add step [Y/n]: "
|
86
|
-
choice = gets
|
87
|
-
if choice.downcase.strip != "n"
|
88
|
-
puts "Step #{nsteps +1}:"
|
89
|
-
step = gets.capitalize
|
90
|
-
init_step_word = step.split(' ').first
|
91
|
-
if steps_keywords.include?(init_step_word)
|
92
|
-
@steps << step
|
93
|
-
nsteps = nsteps ++ 1
|
94
|
-
else
|
95
|
-
puts "Error: #{init_step_word} unsupported initial value"
|
96
|
-
puts "Use only #{steps_keywords} keywords"
|
97
|
-
end
|
98
|
-
elsif choice.downcase.strip == "n"
|
99
|
-
break
|
100
|
-
else
|
101
|
-
"please enter a valid choice."
|
102
|
-
end
|
103
|
-
end
|
104
|
-
write_feature
|
105
|
-
end
|
106
|
-
|
107
|
-
def more_steps
|
108
|
-
# placeholder for more steps and scenarios
|
109
|
-
# adds additional scenario and steps to file created in write feature
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
# runs cucumber and generates contents of .step_definitions from cucumber output
|
114
|
-
def cucumber_wrapper
|
115
|
-
cucumber = `cucumber features/#{@feature.gsub(" ", "_")}.feature`
|
116
|
-
File.open("features/step_definitions/#{@feature.gsub(" ", "_")}.steps.rb", 'w') do |parsed_steps|
|
117
|
-
parsed_steps.write cucumber.split("You can implement step definitions for undefined steps with these snippets:\n\n").last
|
118
|
-
end
|
119
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
# @example include 'cukecutter' and run from command line
|
4
|
+
# cukecutter = Cukecutter.new
|
5
|
+
# cukecutter.create_structure
|
6
|
+
# cukecutter.create_feature
|
7
|
+
# cukecutter.steps
|
8
|
+
# cukecutter.cucumber_wrapper
|
9
|
+
|
10
|
+
class Cukecutter
|
11
|
+
|
12
|
+
def feature(feature, scenario)
|
13
|
+
@feature = feature
|
14
|
+
@scenario = scenario
|
15
|
+
@tags = tags
|
16
|
+
@description = description
|
17
|
+
end
|
18
|
+
|
19
|
+
# Creates the following folders
|
20
|
+
# features/
|
21
|
+
# features/step_definitions
|
22
|
+
# features/support
|
23
|
+
# And the file
|
24
|
+
# features/support/env.rb
|
25
|
+
def create_structure
|
26
|
+
if File.exists?("features") && File.directory?("features")
|
27
|
+
return
|
28
|
+
else
|
29
|
+
FileUtils.mkpath "features/step_definitions"
|
30
|
+
FileUtils.mkdir "features/support"
|
31
|
+
FileUtils.mkdir "features/screenshots"
|
32
|
+
FileUtils.touch"features/support/env.rb"
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# create features from list in features.md
|
39
|
+
def create_bulk
|
40
|
+
file = File.new("features.md", "r")
|
41
|
+
while (line = file.gets)
|
42
|
+
line = line.chomp.strip.gsub(' ', '_')
|
43
|
+
FileUtils.touch "features/#{line}.feature"
|
44
|
+
FileUtils.touch "features/step_definitions/#{line}.steps.rb"
|
45
|
+
end
|
46
|
+
file.close
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_feature
|
50
|
+
print "Feature name: "
|
51
|
+
@feature = gets.chomp
|
52
|
+
print "Feature description: "
|
53
|
+
@description = gets.chomp
|
54
|
+
print "Tags seperated by spaces (ex: @api):"
|
55
|
+
@tags = gets.chomp
|
56
|
+
print "Scenario: "
|
57
|
+
@scenario = gets.chomp
|
58
|
+
puts "please enter steps:"
|
59
|
+
puts "Cucumber steps starts with 'Given, When, Then, And, But' keywords."
|
60
|
+
end
|
61
|
+
|
62
|
+
# Creates .feature and .steps.rb files
|
63
|
+
def write_feature
|
64
|
+
File.open("features/""#{@feature.gsub(" ", "_")}.feature", "w") do |f|
|
65
|
+
f.write("#{@tags}\n")
|
66
|
+
f.write("Feature: #{@feature}\n")
|
67
|
+
f.write("Description: #{@description}\n\n")
|
68
|
+
f.write("\tScenario: #{@scenario}\n")
|
69
|
+
end
|
70
|
+
@steps.each do |steps|
|
71
|
+
File.open("features/""#{@feature.gsub(" ", "_")}.feature", "a") do |f|
|
72
|
+
f.write("\t\t#{steps}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
FileUtils.touch "features/step_definitions/#{@feature.gsub(" ", "_")}.steps.rb"
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# Console based walkthrough for feature and step creation
|
80
|
+
def steps
|
81
|
+
steps_keywords = %w(Given When Then And But)
|
82
|
+
nsteps = 0
|
83
|
+
@steps = []
|
84
|
+
while true
|
85
|
+
print "Add step [Y/n]: "
|
86
|
+
choice = gets
|
87
|
+
if choice.downcase.strip != "n"
|
88
|
+
puts "Step #{nsteps +1}:"
|
89
|
+
step = gets.capitalize
|
90
|
+
init_step_word = step.split(' ').first
|
91
|
+
if steps_keywords.include?(init_step_word)
|
92
|
+
@steps << step
|
93
|
+
nsteps = nsteps ++ 1
|
94
|
+
else
|
95
|
+
puts "Error: #{init_step_word} unsupported initial value"
|
96
|
+
puts "Use only #{steps_keywords} keywords"
|
97
|
+
end
|
98
|
+
elsif choice.downcase.strip == "n"
|
99
|
+
break
|
100
|
+
else
|
101
|
+
"please enter a valid choice."
|
102
|
+
end
|
103
|
+
end
|
104
|
+
write_feature
|
105
|
+
end
|
106
|
+
|
107
|
+
def more_steps
|
108
|
+
# placeholder for more steps and scenarios
|
109
|
+
# adds additional scenario and steps to file created in write feature
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
# runs cucumber and generates contents of .step_definitions from cucumber output
|
114
|
+
def cucumber_wrapper
|
115
|
+
cucumber = `cucumber features/#{@feature.gsub(" ", "_")}.feature`
|
116
|
+
File.open("features/step_definitions/#{@feature.gsub(" ", "_")}.steps.rb", 'w') do |parsed_steps|
|
117
|
+
parsed_steps.write cucumber.split("You can implement step definitions for undefined steps with these snippets:\n\n").last
|
118
|
+
end
|
119
|
+
end
|
120
120
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cukecutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Walker
|
@@ -26,10 +26,12 @@ dependencies:
|
|
26
26
|
version: 0.7.5
|
27
27
|
description: Cucumber feature and step definition tool automated generator. CLI
|
28
28
|
email: adamlwalker77@gmail.com
|
29
|
-
executables:
|
29
|
+
executables:
|
30
|
+
- cutcuke
|
30
31
|
extensions: []
|
31
32
|
extra_rdoc_files: []
|
32
33
|
files:
|
34
|
+
- bin/cutcuke
|
33
35
|
- lib/cukecutter.rb
|
34
36
|
homepage: https://github.com/adamlwalker/cukecutter
|
35
37
|
licenses:
|
@@ -52,9 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
54
|
version: '0'
|
53
55
|
requirements: []
|
54
56
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.4.5
|
56
58
|
signing_key:
|
57
59
|
specification_version: 4
|
58
60
|
summary: CukeCutter cucumber generator
|
59
61
|
test_files: []
|
60
|
-
has_rdoc:
|