Sha256: 69800757b129e494e8247965e8a6d7b2f29f2699ab4afea11fb2f4b8b4ddbde6

Contents?: true

Size: 1.28 KB

Versions: 24

Compression:

Stored size: 1.28 KB

Contents

# -*- coding: utf-8 -*-
module FeatureFactory
  def create_feature(name = generate_feature_name)
    gherkin = <<-GHERKIN
Feature: #{name}
#{yield}
    GHERKIN
    write_file filename(name), gherkin
  end

  def create_feature_ja(name = generate_feature_name)
    gherkin = <<-GHERKIN
# language: ja
機能: #{name}
#{yield}
    GHERKIN
    write_file filename(name), gherkin
  end

  def create_scenario(name = generate_scenario_name)
    <<-GHERKIN
  Scenario: #{name}
  #{yield}
    GHERKIN
  end

  def create_scenario_ja(name = generate_scenario_name)
    <<-GHERKIN
  シナリオ: #{name}
  #{yield}
    GHERKIN
  end

  def create_step_definition
    write_file generate_step_definition_filename, yield
  end

  def generate_feature_name
    "Test Feature #{next_increment(:feature)}"
  end

  def generate_scenario_name
    "Test Scenario #{next_increment(:scenario)}"
  end

  def next_increment(label)
    @increments ||= {}
    @increments[label] ||= 0
    @increments[label] += 1
  end

  def generate_step_definition_filename
    "features/step_definitions/test_steps#{next_increment(:step_defs)}.rb"
  end

  def filename(name)
    "features/#{name.downcase.gsub(' ', '_')}.feature"
  end

  def features
    in_current_dir do
      Dir['features/*.feature']
    end
  end
end

World(FeatureFactory)

Version data entries

24 entries across 22 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/cucumber-1.3.16/features/support/feature_factory.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/cucumber-1.3.18/features/support/feature_factory.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/cucumber-1.3.18/features/support/feature_factory.rb
cucumber-1.3.20 features/support/feature_factory.rb
cucumber-1.3.19 features/support/feature_factory.rb
cucumber-1.3.18 features/support/feature_factory.rb
cucumber-1.3.17 features/support/feature_factory.rb
cucumber-1.3.16 features/support/feature_factory.rb
cucumber-1.3.15 features/support/feature_factory.rb
cucumber-1.3.14 features/support/feature_factory.rb
cucumber-1.3.13 features/support/feature_factory.rb
cucumber-1.3.12 features/support/feature_factory.rb
cucumber-1.3.11 features/support/feature_factory.rb
cucumber-1.3.10 features/support/feature_factory.rb
cucumber-1.3.9 features/support/feature_factory.rb
cucumber-1.3.8 features/support/feature_factory.rb
cucumber-1.3.7 features/support/feature_factory.rb
cucumber-1.3.6 features/support/feature_factory.rb
cucumber-1.3.5 features/support/feature_factory.rb
cucumber-1.3.4 features/support/feature_factory.rb