Module: Spinach::DSL::InstanceMethods

Defined in:
lib/spinach/dsl.rb

Overview

Instance methods to include in the host class.

Instance Method Summary collapse

Instance Method Details

#execute(step) ⇒ Object

Executes a given step.



178
179
180
181
182
183
184
185
# File 'lib/spinach/dsl.rb', line 178

def execute(step)
  underscored_step = Spinach::Support.underscore(step.name)
  if self.respond_to?(underscored_step)
    self.send(underscored_step)
  else
    raise Spinach::StepNotDefinedException.new(step)
  end
end

#nameString

Returns The feature name.

Returns:

  • (String)

    The feature name.



201
202
203
# File 'lib/spinach/dsl.rb', line 201

def name
  self.class.feature_name
end

#pending(reason) ⇒ Object

Raises an exception that defines the current step as a pending one.

Parameters:

  • reason (String)

    The reason why the step is set to pending

Raises:



215
216
217
# File 'lib/spinach/dsl.rb', line 215

def pending(reason)
  raise Spinach::StepPendingException.new(reason)
end

#step_location_for(step) ⇒ String

Gets current step source location.

Parameters:

  • step (String)

    The step name to execute.

Returns:

  • (String)

    The file and line where the step was defined.



194
195
196
197
# File 'lib/spinach/dsl.rb', line 194

def step_location_for(step)
  underscored_step = Spinach::Support.underscore(step)
  location = method(underscored_step).source_location if self.respond_to?(underscored_step)
end