Class: Cucumber2RSpec::Background

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature, cucumber_ast_background) ⇒ Background

Returns a new instance of Background.



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

def initialize feature, cucumber_ast_background
  @feature   = feature
  @_background = cucumber_ast_background # Cucumber::Ast::Background
end

Instance Attribute Details

#_backgroundObject (readonly)

Returns the value of attribute _background.



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

def _background
  @_background
end

#featureObject (readonly)

Returns the value of attribute feature.



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

def feature
  @feature
end

Instance Method Details

#codeObject



20
21
22
23
24
25
# File 'lib/cucumber2rspec/background.rb', line 20

def code
  Cucumber2RSpec.log { '  Background' }
  the_code = "  before do\n"
  the_code << code_without_block.sub(/\n$/, '') # kill the last newline
  the_code << '  end'
end

#code_without_blockObject



16
17
18
# File 'lib/cucumber2rspec/background.rb', line 16

def code_without_block
  Step.code_for_steps(steps)
end

#stepsObject



12
13
14
# File 'lib/cucumber2rspec/background.rb', line 12

def steps
  _background.instance_variable_get('@steps').map {|step| Step.new(self, step) }
end