Module: Spinach

Defined in:
lib/spinach.rb,
lib/spinach/cli.rb,
lib/spinach/dsl.rb,
lib/spinach/step.rb,
lib/spinach/hooks.rb,
lib/spinach/config.rb,
lib/spinach/parser.rb,
lib/spinach/runner.rb,
lib/spinach/auditor.rb,
lib/spinach/feature.rb,
lib/spinach/support.rb,
lib/spinach/version.rb,
lib/spinach/capybara.rb,
lib/spinach/features.rb,
lib/spinach/hookable.rb,
lib/spinach/reporter.rb,
lib/spinach/scenario.rb,
lib/spinach/background.rb,
lib/spinach/exceptions.rb,
lib/spinach/generators.rb,
lib/spinach/tags_matcher.rb,
lib/spinach/feature_steps.rb,
lib/spinach/parser/visitor.rb,
lib/spinach/orderers/random.rb,
lib/spinach/reporter/stdout.rb,
lib/spinach/orderers/default.rb,
lib/spinach/reporter/progress.rb,
lib/spinach/reporter/reporting.rb,
lib/spinach/reporter/failure_file.rb,
lib/spinach/runner/feature_runner.rb,
lib/spinach/runner/scenario_runner.rb,
lib/spinach/generators/step_generator.rb,
lib/spinach/generators/feature_generator.rb

Overview

Spinach is a BDD framework leveraging the great GherkinRuby language. This language is the one used defining features in Cucumber, the BDD framework Spinach is inspired upon.

Its main design goals are:

* No magic: All features are implemented using normal Ruby classes.
* Reusability: Steps are methods, so they can be reused using modules, a
  common, normal practice among rubyists.
* Proper encapsulation: No conflicts between steps from different
  scenarios.

Defined Under Namespace

Modules: DSL, Features, Generators, Hookable, Orderers, Support, TagsMatcher Classes: Auditor, Background, Cli, Config, Feature, FeatureSteps, HookNotYieldException, Hooks, Parser, Reporter, Runner, Scenario, Step, StepNotDefinedException, StepPendingException

Constant Summary collapse

VERSION =

Spinach version.

"0.12.0"
@@feature_steps =
[]

Class Method Summary collapse

Class Method Details

.configConfig

Accesses spinach config. Allows you to configure several runtime options, like the step definitions path.

Examples:

Spinach.config[:step_definitions_path]
  # => 'features/steps'
Spinach.config[:step_definitions_path] = 'integration/steps'
  # => 'integration/steps'

Returns:

  • (Config)

    The config object



17
18
19
# File 'lib/spinach/config.rb', line 17

def self.config
  @config ||= Config.new
end

.feature_stepsArray<FeatureSteps>

Returns All the registered features.

Returns:



42
43
44
# File 'lib/spinach.rb', line 42

def self.feature_steps
  @@feature_steps
end

.find_step_definitions(name) ⇒ StepDefinitions

Finds step definitions given a feature name.

Parameters:

  • name (String)

    The feature name to get the definitions for.

Returns:

  • (StepDefinitions)

    the StepDefinitions class for the given feature name



70
71
72
73
74
75
76
77
78
# File 'lib/spinach.rb', line 70

def self.find_step_definitions(name)
  klass = Spinach::Support.camelize(name)
  scoped_klass = Spinach::Support.scoped_camelize(name)
  feature_steps.detect do |feature|
      feature.name == klass ||
      feature.name == scoped_klass ||
      feature.feature_name.to_s == name.to_s
  end
end

.hooksObject

Returns a new hook object that will receive all the messages from the run and fire up the appropiate callbacks when needed.



57
58
59
# File 'lib/spinach.rb', line 57

def self.hooks
  @@hooks ||= Hooks.new
end

.reset_feature_stepsObject

Resets Spinach to a pristine state, as if no feature was ever registered. Mostly useful in Spinach’s own testing.



50
51
52
# File 'lib/spinach.rb', line 50

def self.reset_feature_steps
  @@feature_steps = []
end