Module: Spinach

Defined in:
lib/spinach.rb,
lib/spinach/cli.rb,
lib/spinach/dsl.rb,
lib/spinach/hooks.rb,
lib/spinach/config.rb,
lib/spinach/parser.rb,
lib/spinach/runner.rb,
lib/spinach/support.rb,
lib/spinach/version.rb,
lib/spinach/capybara.rb,
lib/spinach/hookable.rb,
lib/spinach/reporter.rb,
lib/spinach/exceptions.rb,
lib/spinach/generators.rb,
lib/spinach/feature_steps.rb,
lib/spinach/reporter/stdout.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,
lib/spinach/reporter/stdout/error_reporting.rb

Overview

Spinach is a BDD framework leveraging the great Gherkin 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, Generators, Hookable, Support Classes: Cli, Config, FeatureSteps, Hooks, Parser, Reporter, Runner, StepNotDefinedException

Constant Summary collapse

VERSION =

Spinach version.

"0.1.5.3"
@@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



15
16
17
# File 'lib/spinach/config.rb', line 15

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

.feature_stepsArray<FeatureSteps>

Returns All the registered features.

Returns:



34
35
36
# File 'lib/spinach.rb', line 34

def self.feature_steps
  @@feature_steps
end

.find_feature_steps(name) ⇒ FeatureSteps

Finds a feature given a feature name.

Parameters:

  • name (String)

    The feature name.

Returns:



62
63
64
65
66
67
68
# File 'lib/spinach.rb', line 62

def self.find_feature_steps(name)
  klass = Spinach::Support.camelize(name)
  feature_steps.detect do |feature|
    feature.feature_name.to_s == name.to_s ||
    feature.name == klass
  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.



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

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.



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

def self.reset_feature_steps
  @@feature_steps = []
end