Class: Cucumber::StepWriter
- Inherits:
-
Object
- Object
- Cucumber::StepWriter
- Includes:
- Formatter::ANSIColor, Formatter::Io
- Defined in:
- lib/cucumber/step_writer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_features(features) ⇒ Object
- #after_write ⇒ Object
-
#initialize(step_mother, path_or_io, options) ⇒ StepWriter
constructor
A new instance of StepWriter.
Constructor Details
#initialize(step_mother, path_or_io, options) ⇒ StepWriter
Returns a new instance of StepWriter.
19 20 21 |
# File 'lib/cucumber/step_writer.rb', line 19 def initialize(step_mother, path_or_io, ) @step_mother, @io = step_mother, ensure_dir(path_or_io, 'step writer') end |
Class Method Details
.after_write(&block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cucumber/step_writer.rb', line 10 def after_write(&block) if block @after_write = block else @after_write end end |
Instance Method Details
#after_features(features) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cucumber/step_writer.rb', line 23 def after_features(features) undefined = @step_mother.steps(:undefined) return if undefined.empty? undefined.each do |step| step_name = Cucumber::Undefined === step.exception ? step.exception.step_name : step.name step_multiline_class = step.multiline_arg ? step.multiline_arg.class : nil path = Pathname(@io).join(step.actual_keyword.downcase.strip, step_name.underscore.gsub(%r{[^\w]+}, '_') + '.rb') if !path.file? puts yellow("Writing new step to #{path}.") path.parent.mkpath path.open('wb') { |fh| fh.print @step_mother.snippet_text(step.actual_keyword, step_name, step_multiline_class) } end end after_write.call(@io) if after_write end |
#after_write ⇒ Object
44 45 46 |
# File 'lib/cucumber/step_writer.rb', line 44 def after_write self.class.after_write end |