Class: Lime::Feature
- Inherits:
-
Object
- Object
- Lime::Feature
- Defined in:
- lib/lime/feature.rb
Overview
Features contain scenarios.
The ‘advice` are given, when and then rules.
Defined Under Namespace
Classes: Scope
Instance Attribute Summary collapse
-
#advice ⇒ Object
readonly
Advice are labeled procedures, such as before and after advice.
-
#label ⇒ Object
readonly
Brief description of the feature.
-
#scenarios ⇒ Object
readonly
List of scenarios.
-
#scope ⇒ Object
readonly
Module for evaluating tests.
-
#story ⇒ Object
readonly
The descriptive details of the feature, defined using the ‘To`, `As` and `We` methods.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Convenience method for accessing advice, aka step definitions.
-
#each(&block) ⇒ Object
Iterate over each scenario.
-
#initialize(settings = {}, &block) ⇒ Feature
constructor
A new instance of Feature.
-
#size ⇒ Object
Number of scenarios.
- #to_s ⇒ Object
-
#type ⇒ Object
Subclasses of TestCase can override this to describe the type of test case they define.
- #update(mixin) ⇒ Object
Constructor Details
#initialize(settings = {}, &block) ⇒ Feature
Returns a new instance of Feature.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lime/feature.rb', line 33 def initialize(settings={}, &block) @label = settings[:label] @setup = settings[:setup] @advice = Advice.new @story = [] @scenarios = [] @scope = Scope.new(self, &block) @scenarios.each do |scenario| scenario.scope.__send__(:extend, @scope) end end |
Instance Attribute Details
#advice ⇒ Object (readonly)
Advice are labeled procedures, such as before and after advice.
27 28 29 |
# File 'lib/lime/feature.rb', line 27 def advice @advice end |
#label ⇒ Object (readonly)
Brief description of the feature.
16 17 18 |
# File 'lib/lime/feature.rb', line 16 def label @label end |
#scenarios ⇒ Object (readonly)
List of scenarios.
23 24 25 |
# File 'lib/lime/feature.rb', line 23 def scenarios @scenarios end |
#scope ⇒ Object (readonly)
Module for evaluating tests.
30 31 32 |
# File 'lib/lime/feature.rb', line 30 def scope @scope end |
#story ⇒ Object (readonly)
The descriptive details of the feature, defined using the ‘To`, `As` and `We` methods.
20 21 22 |
# File 'lib/lime/feature.rb', line 20 def story @story end |
Instance Method Details
#[](key) ⇒ Object
Convenience method for accessing advice, aka step definitions.
50 51 52 |
# File 'lib/lime/feature.rb', line 50 def [](key) @advice[key] end |
#each(&block) ⇒ Object
Iterate over each scenario.
55 56 57 |
# File 'lib/lime/feature.rb', line 55 def each(&block) scenarios.each(&block) end |
#size ⇒ Object
Number of scenarios.
60 61 62 |
# File 'lib/lime/feature.rb', line 60 def size scenarios.size end |
#to_s ⇒ Object
71 72 73 |
# File 'lib/lime/feature.rb', line 71 def to_s (["#{label}"] + story).join("\n") end |
#type ⇒ Object
Subclasses of TestCase can override this to describe the type of test case they define.
66 67 68 |
# File 'lib/lime/feature.rb', line 66 def type 'Feature' end |
#update(mixin) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/lime/feature.rb', line 76 def update(mixin) @advice[:given].update( mixin[:given] || {} ) @advice[:when].update( mixin[:when] || {} ) @advice[:then].update( mixin[:then] || {} ) #@scope.__send__(:include, mixin) if Module === mixin end |