Class: CukeWriter::Formatter
- Inherits:
-
Object
- Object
- CukeWriter::Formatter
- Defined in:
- lib/cuke_writer.rb
Instance Method Summary collapse
- #after_examples(*args) ⇒ Object
- #after_feature(feature) ⇒ Object
- #background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
- #before_table_row(table_row) ⇒ Object
- #examples_name(*args) ⇒ Object
-
#initialize(step_mother, path_or_io, options) ⇒ Formatter
constructor
A new instance of Formatter.
- #scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
Constructor Details
#initialize(step_mother, path_or_io, options) ⇒ Formatter
Returns a new instance of Formatter.
9 10 11 12 13 14 15 16 |
# File 'lib/cuke_writer.rb', line 9 def initialize(step_mother, path_or_io, ) @options = @meta_dir = 'generated_features' @step_collector = StepCollector.new @current_scenario_outline_heading = nil @scenario_outline_name = nil @currently_in_examples_table = false end |
Instance Method Details
#after_examples(*args) ⇒ Object
45 46 47 48 |
# File 'lib/cuke_writer.rb', line 45 def after_examples(*args) @scenario_outline_name = nil @currently_in_examples_table = false end |
#after_feature(feature) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cuke_writer.rb', line 18 def after_feature(feature) if @step_collector.steps.size > 0 FileUtils.mkdir_p(output_directory) unless File.directory?(output_directory) File.open("#{output_directory}/#{feature.filename}", 'w') do |fh| fh.write "@cuke_writer\nFeature: #{feature.name}\n [generated from #{feature.file}]\n" fh.write @step_collector.steps.join("\n") + "\n" end end @step_collector.reset end |
#background_name(keyword, name, file_colon_line, source_indent) ⇒ Object
37 38 39 |
# File 'lib/cuke_writer.rb', line 37 def background_name(keyword, name, file_colon_line, source_indent) @step_collector.add_scenario "#{keyword}: #{name}\n [from #{file_colon_line}]", {:indent => 2} end |
#before_table_row(table_row) ⇒ Object
50 51 52 53 54 |
# File 'lib/cuke_writer.rb', line 50 def before_table_row(table_row) if @currently_in_examples_table @step_collector.add_scenario("Scenario: #{@scenario_outline_info[:name]}\n [from #{@scenario_outline_info[:file]}:#{table_row.line}]", {:indent => 2}) end end |
#examples_name(*args) ⇒ Object
41 42 43 |
# File 'lib/cuke_writer.rb', line 41 def examples_name(*args) @currently_in_examples_table = true end |
#scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/cuke_writer.rb', line 29 def scenario_name(keyword, name, file_colon_line, source_indent) if keyword == 'Scenario Outline' @scenario_outline_info = {:name => name, :file => file_colon_line.gsub(/:\d+$/, '')} else @step_collector.add_scenario "#{keyword}: #{name}\n [from #{file_colon_line}]", {:indent => 2} end end |