Class: Feature

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

Direct Known Subclasses

ObjcFeature, RailsFeature

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Feature

Returns a new instance of Feature.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/feature.rb', line 8

def initialize(hash={})
  @title                  = hash[:title]
  @body                   = hash[:body]
  @parent                 = hash[:parent]
  @keyword                = hash[:keyword] || "Feature:"
  @scenario_keyword       = hash[:scenario_keyword] || "Scenario:"
  @given_scenario_keyword = hash[:given_scenario_keyword] || "GivenScenario:"
  @follow_up_keyword      = hash[:follow_up_keyword] || "And"
  
  raise "No title given" unless title
  raise "No body given" unless body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/feature.rb', line 3

def body
  @body
end

#follow_up_keywordObject (readonly)

Returns the value of attribute follow_up_keyword.



3
4
5
# File 'lib/feature.rb', line 3

def follow_up_keyword
  @follow_up_keyword
end

#given_scenario_keywordObject (readonly)

Returns the value of attribute given_scenario_keyword.



3
4
5
# File 'lib/feature.rb', line 3

def given_scenario_keyword
  @given_scenario_keyword
end

#keywordObject (readonly)

Returns the value of attribute keyword.



3
4
5
# File 'lib/feature.rb', line 3

def keyword
  @keyword
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/feature.rb', line 3

def parent
  @parent
end

#parserObject (readonly)

Returns the value of attribute parser.



3
4
5
# File 'lib/feature.rb', line 3

def parser
  @parser
end

#scenario_keywordObject (readonly)

Returns the value of attribute scenario_keyword.



3
4
5
# File 'lib/feature.rb', line 3

def scenario_keyword
  @scenario_keyword
end

#scenariosObject (readonly)

Returns the value of attribute scenarios.



3
4
5
# File 'lib/feature.rb', line 3

def scenarios
  @scenarios
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/feature.rb', line 3

def title
  @title
end

Instance Method Details

#storyObject



21
22
23
# File 'lib/feature.rb', line 21

def story
  body.split(/#{scenario_keyword}/)[0].split(/#{keyword}\s#{title}/).join(" ").strip
end

#story_htmlObject



25
26
27
# File 'lib/feature.rb', line 25

def story_html
  story.split("\n").join(" <br />")
end