Module: Spinach::DSL::ClassMethods

Defined in:
lib/spinach/dsl.rb

Overview

Class methods to extend the host class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#feature_nameObject (readonly)

The feature name.



21
22
23
# File 'lib/spinach/dsl.rb', line 21

def feature_name
  @feature_name
end

Instance Method Details

#feature(name) ⇒ Object

Sets the feature name.

Examples:

class MyFeature < Spinach::FeatureSteps
  feature "Satisfy needs"
end

Parameters:

  • name (String)

    The name.



73
74
75
# File 'lib/spinach/dsl.rb', line 73

def feature(name)
  @feature_name = name
end

#step(step, &block) ⇒ Object Also known as: Given, When, Then, And, But

Defines an action to perform given a particular step literal.

Examples:

These 3 examples are equivalent:

class MyFeature < Spinach::FeatureSteps
  When "I go to the toilet" do
    @sittin_on_the_toilet.must_equal true
  end
end

class MyFeature < Spinach::FeatureSteps
  step "I go to the toilet" do
    @sittin_on_the_toilet.must_equal true
  end
end

class MyFeature < Spinach::FeatureSteps
  def i_go_to_the_toilet
    @sittin_on_the_toilet.must_equal true
  end
end

Parameters:

  • step (String)

    The step name.

  • block (Proc)

    Action to perform in that step.



52
53
54
# File 'lib/spinach/dsl.rb', line 52

def step(step, &block)
  define_method(Spinach::Support.underscore(step), &block)
end