Module: Spinach

Defined in:
lib/spinach.rb,
lib/spinach/cli.rb,
lib/spinach/dsl.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/reporter.rb,
lib/spinach/exceptions.rb,
lib/spinach/feature_steps.rb,
lib/spinach/runner/feature.rb,
lib/spinach/reporter/stdout.rb,
lib/spinach/runner/scenario.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, Support Classes: Cli, Config, FeatureSteps, FeatureStepsNotFoundException, Parser, Reporter, Runner, StepNotDefinedException

Constant Summary collapse

VERSION =

Spinach version.

"0.1.2"
@@features =
[]

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

.featuresArray<Feature>

Returns All the registered features.

Returns:

  • (Array<Feature>)

    All the registered features.



31
32
33
# File 'lib/spinach.rb', line 31

def self.features
  @@features
end

.find_feature(name) ⇒ Object

Finds a feature given a feature name.

Parameters:

  • name (String)

    The feature name.



49
50
51
52
53
54
55
# File 'lib/spinach.rb', line 49

def self.find_feature(name)
  klass = Spinach::Support.camelize(name)
  @@features.detect do |feature|
    feature.feature_name.to_s == name.to_s ||
    feature.name == klass
  end || raise(Spinach::FeatureStepsNotFoundException, [klass, name])
end

.reset_featuresObject

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



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

def self.reset_features
  @@features = []
end