Class: Lime::Feature::Scope

Inherits:
World
  • Object
show all
Defined in:
lib/lime/feature.rb

Instance Method Summary collapse

Constructor Details

#initialize(feature, &block) ⇒ Scope

Returns a new instance of Scope.



88
89
90
91
92
93
# File 'lib/lime/feature.rb', line 88

def initialize(feature, &block)
  @_feature = feature
  @_skip    = false

  module_eval(&block) if block
end

Instance Method Details

#_featureObject

Access to underlying feature instance.



184
185
186
# File 'lib/lime/feature.rb', line 184

def _feature
  @_feature
end

#As(description) ⇒ Object Also known as: as



103
104
105
# File 'lib/lime/feature.rb', line 103

def As(description)
  @_feature.story << "As " + description
end

#Given(description, &procedure) ⇒ Object Also known as: given

Given …

Parameters:

  • description (String)

    A brief description of the given criteria.



141
142
143
# File 'lib/lime/feature.rb', line 141

def Given(description, &procedure)
  @_feature[:given][description] = procedure
end

#include(mixin) ⇒ Object

Include module and if a Featurette, also update Feature instance.



191
192
193
194
195
196
# File 'lib/lime/feature.rb', line 191

def include(mixin)
  if Featurette === mixin
    @_feature.update(mixin)
  end
  super(mixin)
end

#Scenario(label, &procedure) ⇒ Object Also known as: scenario

Define a Scenario.



122
123
124
125
126
127
128
129
130
131
132
# File 'lib/lime/feature.rb', line 122

def Scenario(label, &procedure)
  scenario = Scenario.new(
    @_feature,
    :skip  => @_skip,
    :label => label,
    &procedure
  )
  @_feature.scenarios << scenario
  @_skip = false
  scenario
end

#skip(reason = true) ⇒ Object

TODO:

Use block form of this instead?

Skip the next scenario when running feature.

skip "for some reason"
Scenario "blah blah blah" do
  # ...
end


177
178
179
# File 'lib/lime/feature.rb', line 177

def skip(reason=true)
  @_skip = reason
end

#Then(description, &procedure) ⇒ Object Also known as: hence

Then …

Parameters:

  • description (String)

    A brief description of the then criteria.



163
164
165
# File 'lib/lime/feature.rb', line 163

def Then(description, &procedure)
  @_feature[:then][description] = procedure
end

#To(description) ⇒ Object Also known as: to



96
97
98
# File 'lib/lime/feature.rb', line 96

def To(description)
  @_feature.story << "To " + description
end

#We(description) ⇒ Object Also known as: we, I



110
111
112
# File 'lib/lime/feature.rb', line 110

def We(description)
  @_feature.story << "We " + description
end

#When(description, &procedure) ⇒ Object Also known as: wence

When …

Parameters:

  • description (String)

    A brief description of the when criteria.



152
153
154
# File 'lib/lime/feature.rb', line 152

def When(description, &procedure)
  @_feature[:when][description] = procedure
end