cucumberator 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7ff4dc931a1c85e148985c480045395406cce132
4
+ data.tar.gz: 0ebc0e4a03750148300d2b6712ef57080d649e5b
5
+ SHA512:
6
+ metadata.gz: 7be7c6b10c90a802c3db76e03167ab4e259773dc48cba1d90ab653b462a4bff179f41aeba14e75325a4ac44ac8b650d7c10ec28e4dd7587129f8a79c01c80583
7
+ data.tar.gz: b238d4702fda381cab5c0db0dbfbd09f0e6f25d0b4b8232726218e4ad6f7fbee42e33787f8f13a96112062a89e59143ec40415f4052aff8567f4d965b6b943c6
data/README.md CHANGED
@@ -3,26 +3,40 @@ Cucumberator is Cucumber extension to write steps in command line, whatch how br
3
3
  ## How to use
4
4
 
5
5
  * Put @cucumberize tag in front of empty Scenario you want to append with new steps.
6
- * Or place step "Then I will write new steps" anywhere in scenario.
6
+ * Or place step "Then I will write new steps" anywhere in scenario [PREFERRED]
7
7
  * Fire up the cucumber and wait until prompt shows up.
8
- * Write a step, watch it happen on the browser!
8
+ * Write a step, watch it happen on the browser!
9
9
 
10
10
  All steps are **automatically saved** into .feature file unless it's unsuccessful. If you're unhappy with the last step, type "undo". See all commands with "help".
11
11
 
12
12
  If you have Continuous Integration, do not forget to remove cucumberator tag/step before pushing! ;-)
13
13
 
14
+ ## Available commands
15
+
16
+ When you're in cucumberator prompt, the following commands are available:
17
+
18
+ * save - force-saves last step into current feature file
19
+ * last-step - display last executed step (to be saved on 'save' command)
20
+ * undo - remove last saved line from feature file
21
+ * next - execute next step and stop
22
+ * steps - display available steps
23
+ * where - display current location in file
24
+ * exit - exits current scenario
25
+ * exit-all - exists whole Cucumber feature
26
+ * help - displays all available commands
27
+
14
28
  ## Installation
15
29
 
16
30
  If you use bundler (and you should), add to your Gemfile
17
-
31
+
18
32
  gem "cucumberator", :require => false
19
-
33
+
20
34
  Otherwise, install with
21
-
35
+
22
36
  gem install cucumberator
23
37
 
24
38
  Then require it in one of your ruby files under features/support (e.g. env.rb)
25
-
39
+
26
40
  require 'cucumberator'
27
41
 
28
42
  Now use special step in any place:
@@ -38,11 +52,22 @@ or put @cucumberize before last **empty** Scenario you want to fill up, for exam
38
52
 
39
53
  and then run this feature file, watch your console for prompt to show up. Enjoy writing steps on the go!
40
54
 
55
+ ## Compability
56
+
57
+ Latest cucumberator version supports:
58
+
59
+ * Ruby >= 1.9
60
+ * Cucumber >= 1.3
61
+
41
62
  ## TODO
42
63
 
43
64
  * tests
44
- * "next" command to execute next step from scenario and stop
65
+ * refactor Cucumberator::Writer - too fat already
66
+
67
+ ## Suggestions?
68
+
69
+ Drop me a line or feel free to contribute!
45
70
 
46
- ## SUGGESTIONS?
71
+ ## Sponsors
47
72
 
48
- Drop me a line or feel free to contribute!
73
+ Sponsored (and used) by [SameSystem](http://www.samesystem.com).
data/cucumberator.gemspec CHANGED
@@ -11,12 +11,13 @@ Gem::Specification.new do |s|
11
11
  s.summary = "cucumberator-#{s.version}"
12
12
  s.description = %q{Prompt for writing Cucumber tests}
13
13
  s.post_install_message = "(::)\nCucumberator installed! Now require cucumberator in your env.rb and check README for usage examples\n(::)"
14
+ s.licenses = ['MIT', 'GPL-2']
14
15
 
15
16
  s.files = `git ls-files`.split("\n")
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
19
  s.require_paths = ["lib"]
19
20
 
20
- s.add_dependency 'cucumber', '> 1.0.2'
21
- s.add_dependency 'cucumber-rails', '> 1.0.2'
21
+ s.add_dependency 'cucumber', '> 1.3'
22
+ s.add_dependency 'cucumber-rails', '> 1.3'
22
23
  end
data/lib/cucumberator.rb CHANGED
@@ -17,4 +17,4 @@ end
17
17
 
18
18
  Then /^I will write new steps$/ do
19
19
  Cucumberator::Writer.new(self, @current_cucumberator_scenario, @current_step.line)
20
- end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module Cucumberator
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -15,22 +15,31 @@ module Cucumberator
15
15
  end
16
16
 
17
17
  def check_scenario
18
- raise "Sorry, no cucumberator when scenario is already failing!" if scenario.failed?
18
+ raise "Sorry, cucumberator is not available when scenario is already failing!" if scenario.failed?
19
19
  end
20
20
 
21
21
  def set_autocomplete
22
- commands = %w(exit exit-all help last-step save undo next steps)
23
- @steps = scenario.instance_variable_get("@current_visitor").step_mother.instance_variable_get("@support_code").step_definitions.map{|sd| sd.regexp_source }
24
-
22
+ commands = %w(exit exit-all help last-step save undo next where whereami steps)
23
+
24
+ @steps = all_defined_steps
25
25
  @steps.each do |s|
26
26
  # remove typical start/end regexp parts
27
27
  step = s.gsub(/^\/\^|\$\/$/,'')
28
28
  # every step is equal, no matter if When/Then/And, so combining everything for autocomplete
29
- commands << "When #{step}" << "Then #{step}" << "And #{step}"
29
+ commands << "When #{step}" << "Then #{step}" << "And #{step}"
30
30
  end
31
31
 
32
32
  Readline.basic_word_break_characters = ""; # no break chars = no autobreaking for completion input
33
- Readline.completion_proc = proc{|s| commands.grep( /^#{Regexp.escape(s)}/ ) }
33
+ Readline.completion_proc = proc { |s| commands.grep( /^#{Regexp.escape(s)}/ ) }
34
+ end
35
+
36
+ def current_visitor
37
+ @current_visitor ||= scenario.instance_variable_get("@current_visitor")
38
+ end
39
+
40
+ def all_defined_steps
41
+ support_code = current_visitor.runtime.instance_variable_get("@support_code")
42
+ support_code.step_definitions.map { |sd| sd.regexp_source }
34
43
  end
35
44
 
36
45
  def read_input
@@ -39,15 +48,19 @@ module Cucumberator
39
48
  read_input unless exit_flag
40
49
  end
41
50
 
51
+ def mark_exit(totally = false)
52
+ Cucumber.wants_to_quit = true if totally
53
+ self.exit_flag = true
54
+ end
55
+
42
56
  def parse_input(input)
43
57
  case input
44
58
  when "exit"
45
- self.exit_flag = true and return
59
+ mark_exit and return
46
60
 
47
61
  when "exit-all"
48
- Cucumber.wants_to_quit = true
49
- self.exit_flag = true and return
50
-
62
+ mark_exit(true)
63
+
51
64
  when "help"
52
65
  display_help
53
66
 
@@ -57,15 +70,18 @@ module Cucumberator
57
70
  when "save"
58
71
  save_last_input
59
72
 
60
- when "undo"
73
+ when "undo"
61
74
  undo
62
75
 
63
76
  when "next"
64
- execute_next_step
77
+ execute_next_step
65
78
 
66
79
  when "steps"
67
80
  display_steps
68
81
 
82
+ when "where", "whereami"
83
+ display_current_location
84
+
69
85
  when ""
70
86
  save_empty_line
71
87
 
@@ -84,7 +100,7 @@ module Cucumberator
84
100
  end
85
101
 
86
102
 
87
- ## COMMANDS
103
+ ## COMMANDS
88
104
 
89
105
  def display_help
90
106
  puts ":: Write a step here and watch it happen on the browser."
@@ -93,8 +109,9 @@ module Cucumberator
93
109
  puts ":: save - force-saves last step into current feature file"
94
110
  puts ":: last-step - display last executed step (to be saved on 'save' command)"
95
111
  puts ":: undo - remove last saved line from feature file"
96
- #puts ":: next - execute next step and stop"
112
+ puts ":: next - execute next step and stop"
97
113
  puts ":: steps - display available steps"
114
+ puts ":: where - display current location in file"
98
115
  puts ":: exit - exits current scenario"
99
116
  puts ":: exit-all - exists whole Cucumber feature"
100
117
  puts ":: help - display this notification"
@@ -107,22 +124,22 @@ module Cucumberator
107
124
  string_to_save = (" " * spaces_in_last_input) + last_input
108
125
  save_to_feature_file(string_to_save)
109
126
 
110
- puts "Saved \"#{last_input}\" to #{File.basename(feature_file)}"
127
+ puts "Saved `#{last_input}` to #{File.basename(feature_file)}"
111
128
  self.last_input = nil
112
129
  end
113
130
  end
114
131
 
115
132
  def save_to_feature_file(string)
116
133
  if step_line
117
- feature_file_lines = File.readlines(feature_file)
118
- feature_file_lines.insert(step_line, string.to_s+$/) # $/ - default newline separator
119
- File.open(feature_file, 'w'){|f| f.puts(feature_file_lines.join) }
134
+ lines = feature_file_lines
135
+ lines.insert(step_line, string.to_s+$/) # $/ - default newline separator
136
+ File.open(feature_file, 'w'){|f| f.puts(lines.join) }
137
+ self.saved_stack << [step_line, string]
120
138
  self.step_line += 1
121
139
  else
122
140
  File.open(feature_file, 'a'){|f| f.puts(string) }
141
+ self.saved_stack << [feature_file_lines.size, string]
123
142
  end
124
-
125
- self.saved_stack << string
126
143
  end
127
144
 
128
145
  def save_empty_line
@@ -139,33 +156,74 @@ module Cucumberator
139
156
 
140
157
  def undo
141
158
  if saved_stack.empty?
142
- puts "There's nothing to revert yet" and return
159
+ puts "There's nothing to revert yet"
160
+ return
161
+ end
162
+
163
+ lines = feature_file_lines
164
+
165
+ remove_line, remove_string = self.saved_stack.pop
166
+ lines.delete_at(remove_line)
167
+ File.open(feature_file, 'w') { |f| f.puts(lines.join) }
168
+ self.step_line -= 1
169
+
170
+ puts "Removed `#{remove_string.to_s.strip}` from #{File.basename(feature_file)}"
171
+ end
172
+
173
+ def display_current_location
174
+ display_line(step_line - 1)
175
+ display_line(step_line, current: true)
176
+ display_line(step_line + 1)
177
+ end
178
+
179
+ def display_line(line_number, opts = {})
180
+ lines = feature_file_lines
181
+ line_string = sprintf("%3d", line_number)
182
+
183
+ if opts[:current]
184
+ line_string << ": -> "
185
+ else
186
+ line_string << ": "
143
187
  end
144
188
 
145
- feature_file_lines = File.readlines(feature_file)
189
+ line_string << lines[line_number]
190
+ puts line_string
191
+ end
192
+
193
+ def execute_next_step
194
+ next_step = detect_next_step
146
195
 
147
- removed = if step_line
148
- self.step_line -= 1
149
- feature_file_lines.delete_at(step_line)
196
+ if next_step
197
+ puts next_step.backtrace_line
198
+ current_visitor.visit_step(next_step)
199
+ self.step_line = next_step.file_colon_line.split(':').last.to_i + 1
150
200
  else
151
- feature_file_lines.pop
201
+ puts ":: Looks like it's the end of feature file. Happy coding! <3"
202
+ mark_exit(true)
152
203
  end
204
+ end
153
205
 
154
- puts "Removed \"#{removed.to_s.strip}\" from #{File.basename(feature_file)}"
206
+ def detect_next_step
207
+ next_step = nil
155
208
 
156
- File.open(feature_file, 'w'){|f| f.puts(feature_file_lines.join) }
157
- self.saved_stack.pop
209
+ scenario.steps.each do |step|
210
+ if step.status == :skipped and not step.backtrace_line["Then I will write new steps"]
211
+ next_step = step
212
+ break
213
+ end
214
+ end
215
+
216
+ next_step
158
217
  end
159
218
 
160
- # TODO: find a way to execute next step & stop
161
- def execute_next_step
162
- puts ":: Sorry, not available yet"
219
+ def feature_file_lines
220
+ File.readlines(feature_file)
163
221
  end
164
222
 
165
223
  def display_steps
166
224
  if @steps and @steps.size > 0
167
225
  puts ":: Yay, you have #{@steps.size} steps in your pocket:"
168
- @steps.each{|s| puts s }
226
+ @steps.each { |s| puts s }
169
227
  else
170
228
  puts ":: Sorry, no steps detected?"
171
229
  end
@@ -199,4 +257,4 @@ module Cucumberator
199
257
  end
200
258
  end
201
259
 
202
- end
260
+ end
metadata CHANGED
@@ -1,65 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cucumberator
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
11
5
  platform: ruby
12
- authors:
13
- - "Vidmantas Kabo\xC5\xA1is"
6
+ authors:
7
+ - Vidmantas Kabošis
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-11-12 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: cucumber
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">"
28
- - !ruby/object:Gem::Version
29
- hash: 19
30
- segments:
31
- - 1
32
- - 0
33
- - 2
34
- version: 1.0.2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>'
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
35
20
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: cucumber-rails
39
21
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">"
44
- - !ruby/object:Gem::Version
45
- hash: 19
46
- segments:
47
- - 1
48
- - 0
49
- - 2
50
- version: 1.0.2
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>'
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cucumber-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>'
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
51
34
  type: :runtime
52
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>'
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
53
41
  description: Prompt for writing Cucumber tests
54
- email:
42
+ email:
55
43
  - vidmantas@kabosis.lt
56
44
  executables: []
57
-
58
45
  extensions: []
59
-
60
46
  extra_rdoc_files: []
61
-
62
- files:
47
+ files:
63
48
  - .gitignore
64
49
  - Gemfile
65
50
  - LICENSE
@@ -70,42 +55,32 @@ files:
70
55
  - lib/cucumberator/current_step.rb
71
56
  - lib/cucumberator/version.rb
72
57
  - lib/cucumberator/writer.rb
73
- has_rdoc: true
74
58
  homepage: https://github.com/vidmantas/cucumberator
75
- licenses: []
76
-
59
+ licenses:
60
+ - MIT
61
+ - GPL-2
62
+ metadata: {}
77
63
  post_install_message: |-
78
64
  (::)
79
65
  Cucumberator installed! Now require cucumberator in your env.rb and check README for usage examples
80
66
  (::)
81
67
  rdoc_options: []
82
-
83
- require_paths:
68
+ require_paths:
84
69
  - lib
85
- required_ruby_version: !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
103
80
  requirements: []
104
-
105
81
  rubyforge_project:
106
- rubygems_version: 1.4.2
82
+ rubygems_version: 2.0.3
107
83
  signing_key:
108
- specification_version: 3
109
- summary: cucumberator-0.0.6
84
+ specification_version: 4
85
+ summary: cucumberator-0.0.7
110
86
  test_files: []
111
-