public
Rubygem
Description: Behaviour Driven Development framework for Ruby
Homepage: http://rspec.info
Clone URL: git://github.com/dchelimsky/rspec.git
Click here to lend your support to: rspec and make a donation at www.pledgie.com !
"And"s in Story HTML output
josephwilk (author)
Mon Jul 14 04:51:52 -0700 2008
dchelimsky (committer)
Tue Jul 15 20:57:11 -0700 2008
commit  d84231200d1b09ed4d21c82487a6bf4cc29509f6
tree    5b8be6fc84189f99c4a596d9702be1fa1fe57d0a
parent  5bb989c6a54e325198e180ef3d4e59b5bf6eb21c
...
86
87
88
 
89
90
91
...
149
150
151
 
 
 
 
 
152
153
 
 
154
155
 
 
 
 
 
 
156
157
158
...
86
87
88
89
90
91
92
...
150
151
152
153
154
155
156
157
158
 
159
160
161
162
163
164
165
166
167
168
169
170
171
0
@@ -86,6 +86,7 @@ EOF
0
           end
0
      
0
           def scenario_started(story_title, scenario_name)
0
+ @previous_type = nil
0
             @scenario_failed = false
0
             @scenario_text = <<-EOF
0
               <dt>Scenario: #{h scenario_name}</dt>
0
@@ -149,10 +150,22 @@ EOF
0
             spans = args.map { |arg| "<span class=\"param\">#{arg}</span>" }
0
             desc_string = description.step_name
0
             arg_regexp = description.arg_regexp
0
+ inner = if(type == @previous_type)
0
+ "And "
0
+ else
0
+ "#{type.to_s.capitalize} "
0
+ end
0
             i = -1
0
- inner = type.to_s.capitalize + ' ' + desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
0
+ inner += desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
0
+
0
             @scenario_text += " <li class=\"#{klass}\">#{inner}</li>\n"
0
             
0
+ if type == :'given scenario'
0
+ @previous_type = :given
0
+ else
0
+ @previous_type = type
0
+ end
0
+
0
           end
0
         end
0
       end
...
61
62
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
65
66
...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
0
@@ -61,6 +61,54 @@ module Spec
0
 EOF
0
           end
0
           
0
+ it 'should document additional givens using And' do
0
+ # when
0
+ @reporter.step_succeeded :given, 'step 1'
0
+ @reporter.step_succeeded :given, 'step 2'
0
+ @reporter.scenario_ended
0
+ @reporter.story_ended '', ''
0
+
0
+ # then
0
+ @out.string.should include("Given step 1")
0
+ @out.string.should include("And step 2")
0
+ end
0
+
0
+ it 'should document additional events using And' do
0
+ # when
0
+ @reporter.step_succeeded :when, 'step 1'
0
+ @reporter.step_succeeded :when, 'step 2'
0
+ @reporter.scenario_ended
0
+ @reporter.story_ended '', ''
0
+
0
+ # then
0
+ @out.string.should include("When step 1")
0
+ @out.string.should include("And step 2")
0
+ end
0
+
0
+ it 'should document additional outcomes using And' do
0
+ # when
0
+ @reporter.step_succeeded :then, 'step 1'
0
+ @reporter.step_succeeded :then, 'step 2'
0
+ @reporter.scenario_ended
0
+ @reporter.story_ended '', ''
0
+
0
+ # then
0
+ @out.string.should include("Then step 1")
0
+ @out.string.should include("And step 2")
0
+ end
0
+
0
+ it 'should document a GivenScenario followed by a Given using And' do
0
+ # when
0
+ @reporter.step_succeeded :'given scenario', 'a scenario'
0
+ @reporter.step_succeeded :given, 'a context'
0
+ @reporter.scenario_ended
0
+ @reporter.story_ended '', ''
0
+
0
+ # then
0
+ @out.string.should include("Given scenario a scenario")
0
+ @out.string.should include("And a context")
0
+ end
0
+
0
           it "should create a failed story if one of its scenarios fails" do
0
               @reporter.story_started('story_title', 'narrative')
0
               @reporter.scenario_started('story_title', 'succeeded_scenario_name')

Comments

    No one has commented yet.