Class: Cucumber2RSpec::Feature

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_feature_text) ⇒ Feature

Returns a new instance of Feature.



7
8
9
10
# File 'lib/cucumber2rspec/feature.rb', line 7

def initialize raw_feature_text
  @raw      = raw_feature_text
  @_feature = Cucumber2RSpec.parser.parse_or_fail(raw) # Cucumber::Ast::Feature
end

Instance Attribute Details

#_featureObject (readonly)

Returns the value of attribute _feature.



5
6
7
# File 'lib/cucumber2rspec/feature.rb', line 5

def _feature
  @_feature
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/cucumber2rspec/feature.rb', line 5

def name
  @name
end

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/cucumber2rspec/feature.rb', line 5

def raw
  @raw
end

Instance Method Details

#backgroundObject



18
19
20
21
# File 'lib/cucumber2rspec/feature.rb', line 18

def background
  _background = _feature.instance_variable_get('@background')
  Background.new self, _background if _background
end

#codeObject



27
28
29
30
31
32
33
# File 'lib/cucumber2rspec/feature.rb', line 27

def code
  Cucumber2RSpec.log { name }
  the_code = 'describe ' + name.inspect + ' do' + "\n\n"
  the_code << background.code + "\n\n" if background
  scenarios.each {|scenario| the_code << scenario.code + "\n\n" }
  the_code << "end"
end

#scenariosObject



23
24
25
# File 'lib/cucumber2rspec/feature.rb', line 23

def scenarios
  _feature.instance_variable_get('@feature_elements').map {|scenario| Scenario.new(self, scenario) }
end