Module: Spinach

Defined in:
lib/spinach.rb,
lib/spinach/dsl.rb,
lib/spinach/cli.rb,
lib/spinach/step.rb,
lib/spinach/hooks.rb,
lib/spinach/parser.rb,
lib/spinach/config.rb,
lib/spinach/runner.rb,
lib/spinach/support.rb,
lib/spinach/version.rb,
lib/spinach/feature.rb,
lib/spinach/capybara.rb,
lib/spinach/features.rb,
lib/spinach/scenario.rb,
lib/spinach/hookable.rb,
lib/spinach/reporter.rb,
lib/spinach/background.rb,
lib/spinach/generators.rb,
lib/spinach/exceptions.rb,
lib/spinach/tags_matcher.rb,
lib/spinach/feature_steps.rb,
lib/spinach/parser/visitor.rb,
lib/spinach/reporter/stdout.rb,
lib/spinach/reporter/progress.rb,
lib/spinach/reporter/reporting.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, Support, TagsMatcher Classes: Background, Cli, Config, Feature, FeatureSteps, Hooks, Parser, Reporter, Runner, Scenario, Step, StepNotDefinedException, StepPendingException

Constant Summary

VERSION =

Spinach version.

"0.8.10"
@@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:



40
41
42
# File 'lib/spinach.rb', line 40

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



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

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.



55
56
57
# File 'lib/spinach.rb', line 55

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.



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

def self.reset_feature_steps
  @@feature_steps = []
end