cukecutter 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cukecutter.rb +93 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d6fdec2ebc82ff4e04181ee4807a198859a5973
4
+ data.tar.gz: 11aaa7ab6b7411f08080b8a185938ae4388be912
5
+ SHA512:
6
+ metadata.gz: ab6b9ab5aa2e5d5c0544bc6ce85bf2ac8d622831e09e79251972138b6eea31f6b96ecfd352b27f4a29fc19fbe6265414b6c84cbd9f57b3e37af4e9fb47a84cb0
7
+ data.tar.gz: f08d6a6653a32481f3600a955ca9a4647de284d39db36b33a186e7d7a789d7a2c4f04ff467826d9ddd42f30951752a1b1c97709f801baad135d915f6b249c519
data/lib/cukecutter.rb ADDED
@@ -0,0 +1,93 @@
1
+ require 'fileutils'
2
+
3
+ class Cukecutter
4
+
5
+ def feature(feature, scenario)
6
+ @feature = feature
7
+ @scenario = scenario
8
+ end
9
+
10
+ def create_structure
11
+ if File.exists?("features") && File.directory?("features")
12
+ return
13
+ else
14
+ FileUtils.mkpath "features/step_definitions"
15
+ FileUtils.mkdir "features/support"
16
+ end
17
+ end
18
+
19
+ def create_bulk
20
+ # create features from list in features.md
21
+ file = File.new("features.md", "r")
22
+ while (line = file.gets)
23
+ line = line.chomp.strip.gsub(' ', '_')
24
+ FileUtils.touch "features/#{line}.feature"
25
+ FileUtils.touch "features/step_definitions/#{line}.steps.rb"
26
+ end
27
+ file.close
28
+ end
29
+
30
+ def create_feature
31
+ print "Feature name: "
32
+ @feature = gets.chomp
33
+ print "Scenario: "
34
+ @scenario = gets.chomp
35
+ puts "please enter steps:"
36
+ puts "Cucumber steps starts with 'Given, When, Then, And, But' keywords."
37
+ end
38
+
39
+ def write_feature
40
+ File.open("features/""#{@feature}.feature", "w") do |f|
41
+ f.write("Feature: #{@feature}\n")
42
+ f.write("\tScenario: #{@scenario}\n")
43
+ end
44
+ @steps.each do |steps|
45
+ File.open("features/""#{@feature}.feature", "a") do |f|
46
+ f.write("\t\t#{steps}")
47
+ end
48
+ end
49
+ FileUtils.touch "features/step_definitions/#{@feature}.steps.rb"
50
+ end
51
+
52
+
53
+ def steps
54
+ steps_keywords = %w(Given When Then And But)
55
+ nsteps = 0
56
+ @steps = []
57
+ while true
58
+ print "Add step [Y/n]: "
59
+ choice = gets
60
+ if choice.downcase.strip != "n"
61
+ puts "Step #{nsteps +1}:"
62
+ step = gets.capitalize
63
+ init_step_word = step.split(' ').first
64
+ if steps_keywords.include?(init_step_word)
65
+ @steps << step
66
+ nsteps = nsteps ++ 1
67
+ else
68
+ puts "Error: #{init_step_word} unsupported initial value"
69
+ puts "Use only #{steps_keywords} keywords"
70
+ end
71
+ elsif choice.downcase.strip == "n"
72
+ break
73
+ else
74
+ "please enter a valid choice."
75
+ end
76
+ end
77
+ end
78
+
79
+
80
+ def cucumber_wrapper
81
+ cucumber = `cucumber features/#{@feature}.feature`
82
+ File.open("features/step_definitions/#{@feature}.steps.rb", 'w') do |parsed_steps|
83
+ parsed_steps.write cucumber.split("You can implement step definitions for undefined steps with these snippets:\n\n").last
84
+ end
85
+ end
86
+ end
87
+
88
+ # cukecutter = Cukecutter.new
89
+ # cukecutter.create_structure
90
+ # cukecutter.create_feature
91
+ # cukecutter.steps
92
+ # cukecutter.write_feature
93
+ # cukecutter.cucumber_wrapper
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cukecutter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Walker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Cucumber feature and step definition tool
14
+ email: adamlwalker77@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/cukecutter.rb
20
+ homepage: https://github.com/adamlwalker/cukecutter
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: CukeCutter
44
+ test_files: []