Sha256: e5f8abd675b8e78162cc9b65548444966ecabd74d6060d71a0a47cde1732fbf9

Contents?: true

Size: 989 Bytes

Versions: 36

Compression:

Stored size: 989 Bytes

Contents

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

  def create_scenario(name = generate_scenario_name)
    <<-GHERKIN
  Scenario: #{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

36 entries across 34 versions & 8 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/gems/cucumber-1.2.1/features/support/feature_factory.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/cucumber-1.2.1/features/support/feature_factory.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/cucumber-1.2.1/features/support/feature_factory.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/features/support/feature_factory.rb
cucumber-1.2.5 features/support/feature_factory.rb
cucumber-1.2.3 features/support/feature_factory.rb
cucumber-1.2.2 features/support/feature_factory.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/cucumber-1.2.1/features/support/feature_factory.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/features/support/feature_factory.rb
casecumber-1.2.1.cb2 features/support/feature_factory.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/cucumber-1.2.1/features/support/feature_factory.rb
cucumber-1.2.1 features/support/feature_factory.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/features/support/feature_factory.rb
ftl-0.2.0 vendor/bundle/gems/cucumber-1.2.0/features/support/feature_factory.rb
cucumber-1.2.0 features/support/feature_factory.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/features/support/feature_factory.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/features/support/feature_factory.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/features/support/feature_factory.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/features/support/feature_factory.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/cucumber-1.1.9/features/support/feature_factory.rb