Class: RailsFeature
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 = RailsScenario) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/Rails/rails_feature.rb', line 2
def parse_scenarios(klass=RailsScenario)
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_name ⇒ Object
36
37
38
|
# File 'lib/Rails/rails_feature.rb', line 36
def test_case_name
"#{title.remove_invalid_chars.split(/\s+/).map {|w| w.capitalize}.join('')}Test"
end
|
#to_html ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/Rails/rails_feature.rb', line 24
def to_html
<<-END
<div class="feature">
<h2 class="feature_title">#{keyword} #{title}</h2>
<p class="story">
#{story_html}
</p>
#{scenarios.map {|s| s.to_html }.join(" \n")}
</div>
END
end
|
#to_s ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/Rails/rails_feature.rb', line 16
def to_s
<<-END
class #{test_case_name} < FeaturesTestCaseClass
#{scenarios.map {|s| s.to_s}.join("\n")}
end
END
end
|