Class: ObjcFeature

Inherits:
Feature show all
Defined in:
lib/ObjC/objc_feature.rb

Instance Attribute Summary

Attributes inherited from Feature

#body, #follow_up_keyword, #given_scenario_keyword, #keyword, #parent, #parser, #scenario_keyword, #scenarios, #title

Instance Method Summary collapse

Methods inherited from Feature

#initialize, #story, #story_html

Constructor Details

This class inherits a constructor from Feature

Instance Method Details

#parse_scenarios(klass = ObjcScenario) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ObjC/objc_feature.rb', line 2

def parse_scenarios(klass=ObjcScenario)
  title_body_arr = Parser.title_and_body_by_keyword_from_string({
    :string => body,
    :keyword => scenario_keyword
  })
  @scenarios = title_body_arr.map {|hash| klass.new(hash.update({
    :parent => self,
    :given_scenario_keyword => given_scenario_keyword,
    :follow_up_keyword => follow_up_keyword
  }))}
  @scenarios.each {|scenario| scenario.collect_steps}
  self
end

#test_case_nameObject



38
39
40
# File 'lib/ObjC/objc_feature.rb', line 38

def test_case_name
  "#{title.remove_invalid_chars.split(/\s+/).map {|w| w.capitalize}.join('')}Test"
end

#to_htmlObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ObjC/objc_feature.rb', line 26

def to_html
  "  <div class=\"feature\">\n    <h2 class=\"feature_title\">\#{keyword} \#{title}</h2>\n    <p class=\"story\">\n      \#{story_html}\n    </p>\n    \#{scenarios.map {|s| s.to_html }.join(\" \\n\")}\n  </div>\n"
end

#to_sObject



16
17
18
19
20
21
22
23
24
# File 'lib/ObjC/objc_feature.rb', line 16

def to_s
  "  @interface \#{test_case_name} : OMFeature\n  @end\n  @implementation \#{test_case_name}\n  \#{scenarios.map {|s| s.to_s}.join(\" \")}\n  @end\n  END\nend\n"