stepdown-patched 0.6.3.1patched

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/.bundle/config +1 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +12 -0
  5. data/Gemfile.lock +31 -0
  6. data/History.txt +50 -0
  7. data/README.rdoc +28 -0
  8. data/Rakefile +14 -0
  9. data/bin/stepdown +23 -0
  10. data/lib/stepdown/analyzer.rb +74 -0
  11. data/lib/stepdown/feature_parser.rb +60 -0
  12. data/lib/stepdown/graph.rb +75 -0
  13. data/lib/stepdown/html_reporter.rb +37 -0
  14. data/lib/stepdown/options.rb +68 -0
  15. data/lib/stepdown/reporter.rb +23 -0
  16. data/lib/stepdown/scenario.rb +26 -0
  17. data/lib/stepdown/statistics.rb +162 -0
  18. data/lib/stepdown/step.rb +22 -0
  19. data/lib/stepdown/step_collection.rb +36 -0
  20. data/lib/stepdown/step_group.rb +45 -0
  21. data/lib/stepdown/step_instance.rb +63 -0
  22. data/lib/stepdown/step_usage.rb +15 -0
  23. data/lib/stepdown/text_reporter.rb +39 -0
  24. data/lib/stepdown/version.rb +3 -0
  25. data/lib/stepdown/yaml_writer.rb +14 -0
  26. data/lib/stepdown.rb +17 -0
  27. data/public/bluff-min.js +1 -0
  28. data/public/excanvas.js +35 -0
  29. data/public/jquery-1.6.1.min.js +18 -0
  30. data/public/js-class.js +1 -0
  31. data/public/step_down.js +41 -0
  32. data/public/stepdown.css +24 -0
  33. data/spec/fixtures/20110611.yml +5 -0
  34. data/spec/fixtures/20110612.yml +5 -0
  35. data/spec/lib/stepdown/analyzer_spec.rb +70 -0
  36. data/spec/lib/stepdown/feature_parser_spec.rb +93 -0
  37. data/spec/lib/stepdown/graph_spec.rb +82 -0
  38. data/spec/lib/stepdown/options_spec.rb +98 -0
  39. data/spec/lib/stepdown/scenario_spec.rb +40 -0
  40. data/spec/lib/stepdown/statistics_spec.rb +239 -0
  41. data/spec/lib/stepdown/step_collection_spec.rb +78 -0
  42. data/spec/lib/stepdown/step_group_spec.rb +43 -0
  43. data/spec/lib/stepdown/step_instance_spec.rb +85 -0
  44. data/spec/spec_helper.rb +4 -0
  45. data/stepdown.gemspec +30 -0
  46. data/templates/_empty.html.erb +5 -0
  47. data/templates/_grouping.html.erb +31 -0
  48. data/templates/_unused.html.erb +5 -0
  49. data/templates/_usages.html.erb +8 -0
  50. data/templates/index.html.erb +218 -0
  51. data/templates/style.sass +25 -0
  52. metadata +183 -0
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'scenario'
3
+ require 'step'
4
+
5
+
6
+ describe Stepdown::Scenario do
7
+ before :each do
8
+ @scenario = Stepdown::Scenario.new('scenario')
9
+ @s1 = Stepdown::Step.new(1, /step 1/)
10
+ @s2 = Stepdown::Step.new(2, /Step 2/)
11
+ @s2_dup = Stepdown::Step.new(2, /Step 2/)
12
+ @s3 = Stepdown::Step.new(3, /Step 3/)
13
+
14
+ end
15
+
16
+ describe "adding steps" do
17
+ before :each do
18
+ @scenario.add_step(@s1)
19
+ @scenario.add_step(@s2)
20
+ @scenario.add_step(@s2_dup)
21
+ @scenario.add_step(@s3)
22
+ end
23
+
24
+ it "should add steps to cache" do
25
+ steps = [@s1, @s2, @s3]
26
+ @scenario.steps.should =~ steps
27
+ end
28
+
29
+ it "should return the total number of steps" do
30
+ @scenario.step_count.should == 4
31
+ end
32
+
33
+ it "should return the number of unique steps" do
34
+ @scenario.unique_step_count.should == 3
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
@@ -0,0 +1,239 @@
1
+ require 'stepdown/step_group'
2
+ require 'stepdown/step_usage'
3
+ require 'stepdown/reporter'
4
+ require 'stepdown/scenario'
5
+ require 'stepdown/statistics'
6
+
7
+ describe Stepdown::Statistics do
8
+
9
+ describe "returning overall statistics" do
10
+ it "should return the total number of steps" do
11
+ steps = [mock('step_1'), mock('step_2')]
12
+ reporter = Stepdown::Statistics.new([], steps)
13
+ reporter.total_steps.should == 2
14
+ end
15
+
16
+ it "should return the total number of scenarios" do
17
+ scenarios = [mock('scenario_1'), mock('scenario_2')]
18
+ reporter = Stepdown::Statistics.new(scenarios, [])
19
+ reporter.total_scenarios.should == 2
20
+ end
21
+
22
+ it "should return the number of steps per scenario" do
23
+ steps = [mock('step_1'), mock('step_2'), mock('step_3')]
24
+ scenario1 = mock("scenario1", :steps => steps, :step_count => steps.length)
25
+ scenario2 = mock("scenario2", :steps => [], :step_count => 0)
26
+
27
+ reporter = Stepdown::Statistics.new([scenario1, scenario2], [])
28
+ reporter.steps_per_scenario.should == "1.50"
29
+ end
30
+
31
+ it "should return the number of unique steps per scenario" do
32
+ steps = [mock('step_1'), mock('step_2'), mock('step_3')]
33
+ scenario1 = mock("scenario1", :steps => steps, :unique_step_count => 2, :step_count => 3)
34
+ scenario2 = mock("scenario2", :steps => steps[0...1], :unique_step_count => 1, :step_count => 1)
35
+
36
+ reporter = Stepdown::Statistics.new([scenario1, scenario2], [])
37
+ reporter.unique_steps.should == "1.33"
38
+ end
39
+
40
+ end
41
+
42
+ #this whole grouping thing needs to be refactored. Nasty.
43
+ describe "creating step groupings" do
44
+ before :each do
45
+ @scen_1 = Stepdown::Scenario.new('scenario')
46
+ @scen_2 = Stepdown::Scenario.new('scenario')
47
+ @scenarios = [@scen_1, @scen_2]
48
+
49
+ @collection = Stepdown::StepCollection.new
50
+ @s1 = Stepdown::Step.new(1, /step 1/)
51
+ @s2 = Stepdown::Step.new(2, /step 2/)
52
+ @s3 = Stepdown::Step.new(3, /step 3/)
53
+ @s4 = Stepdown::Step.new(4, /step 4/)
54
+ @s5 = Stepdown::Step.new(5, /step 5/)
55
+
56
+ @collection.add_step(@s1.id, @s1.regex)
57
+ @collection.add_step(@s2.id, @s2.regex)
58
+ @collection.add_step(@s3.id, @s3.regex)
59
+ @collection.add_step(@s4.id, @s4.regex)
60
+ @collection.add_step(@s5.id, @s5.regex)
61
+
62
+ @scen_1.add_step(@s1)
63
+ @scen_1.add_step(@s2)
64
+ @scen_1.add_step(@s3)
65
+ @scen_1.add_step(@s4)
66
+
67
+ @scen_2.add_step(@s1)
68
+ @scen_2.add_step(@s2)
69
+ @scen_2.add_step(@s1)
70
+ @scen_2.add_step(@s5)
71
+
72
+ end
73
+
74
+ it "should return the correct step grouping" do
75
+ reporter = Stepdown::Statistics.new([@scen_1, @scen_2], @collection)
76
+
77
+ reporter.groupings[0].step_collection.should =~ [@s1,@s2,@s3,@s4,@s5]
78
+ reporter.groupings[1].step_collection.should =~ [@s1,@s2,@s3,@s4,@s5]
79
+ # TODO: fix these
80
+ # reporter.groupings[2].step_collection.should =~ [@s1,@s2,@s5]
81
+ # reporter.groupings[3].step_collection.should =~ [@s1,@s2,@s3,@s4]
82
+ # reporter.groupings[4].step_collection.should =~ [@s1,@s2,@s3,@s4]
83
+ end
84
+
85
+ it "should return usage for steps across scenarios" do
86
+ reporter = Stepdown::Statistics.new([@scen_1, @scen_2], @collection)
87
+
88
+ group_1 = reporter.groupings.detect{|g| g.id == 1}
89
+ group_1.use_count.should == 8
90
+ end
91
+
92
+ it "should return usage for steps in scenarios with duplicated steps" do
93
+ reporter = Stepdown::Statistics.new([@scen_1, @scen_2], @collection)
94
+
95
+ group_5 = reporter.groupings.detect{|g| g.id == 5}
96
+ group_5.use_count.should == 4
97
+ end
98
+
99
+ end
100
+
101
+ #this usage thing needs to be refactored as well
102
+ describe "creating step usages" do
103
+ before :each do
104
+ @scen_1 = Stepdown::Scenario.new('scenario')
105
+ @scen_2 = Stepdown::Scenario.new('scenario')
106
+ @scenarios = [@scen_1, @scen_2]
107
+
108
+ @collection = Stepdown::StepCollection.new
109
+ @s1 = Stepdown::Step.new(1, /step 1/)
110
+ @s2 = Stepdown::Step.new(2, /step 2/)
111
+ @s3 = Stepdown::Step.new(3, /step 3/)
112
+ @s4 = Stepdown::Step.new(4, /step 4/)
113
+ @s5 = Stepdown::Step.new(5, /step 5/)
114
+
115
+ @collection.add_step(@s1.id, @s1.regex)
116
+ @collection.add_step(@s2.id, @s2.regex)
117
+ @collection.add_step(@s3.id, @s3.regex)
118
+ @collection.add_step(@s4.id, @s4.regex)
119
+ @collection.add_step(@s5.id, @s5.regex)
120
+
121
+ @scen_1.add_step(@s1)
122
+ @scen_1.add_step(@s2)
123
+ @scen_1.add_step(@s3)
124
+ @scen_1.add_step(@s4)
125
+
126
+ @scen_2.add_step(@s1)
127
+ @scen_2.add_step(@s2)
128
+ @scen_2.add_step(@s1)
129
+ @scen_2.add_step(@s5)
130
+ @scen_2.add_step(@s5)
131
+ end
132
+
133
+ it "should return the usage of across scenarios" do
134
+ reporter = Stepdown::Statistics.new([@scen_2, @scen_1], @collection)
135
+
136
+ usage = reporter.usages.detect{|use| use.step.id == 1}
137
+ usage.total_usage.should == 3
138
+ usage.number_scenarios.should == 2
139
+ usage.use_scenario.should == "1.50"
140
+ end
141
+
142
+ it "should return duplicate usage of a step in a scenario" do
143
+ reporter = Stepdown::Statistics.new([@scen_2, @scen_1], @collection)
144
+
145
+ usage = reporter.usages.detect{|use| use.step.id == 5}
146
+ usage.total_usage.should == 2
147
+ usage.number_scenarios.should == 1
148
+ usage.use_scenario.should == "2.00"
149
+ end
150
+
151
+ it "should return usage of a step in a scenario" do
152
+ reporter = Stepdown::Statistics.new([@scen_2, @scen_1], @collection)
153
+
154
+ usage = reporter.usages.detect{|use| use.step.id == 3}
155
+ usage.total_usage.should == 1
156
+ usage.number_scenarios.should == 1
157
+ usage.use_scenario.should == "1.00"
158
+ end
159
+
160
+ end
161
+
162
+ describe "returing step usage" do
163
+ before :each do
164
+ @reporter = Stepdown::Statistics.new([], mock('step_colllection'))
165
+
166
+ @use_1 = Stepdown::StepUsage.new(Stepdown::Step.new(1,/regex/))
167
+ @use_2 = Stepdown::StepUsage.new(Stepdown::Step.new(2,/regex/))
168
+ @use_3 = Stepdown::StepUsage.new(Stepdown::Step.new(3,/regex/))
169
+
170
+ @use_1.total_usage += 1
171
+ @use_2.total_usage += 1
172
+
173
+ @reporter.stub!(:step_usages).and_return([@use_1, @use_2, @use_3])
174
+ end
175
+
176
+ it "should return used steps" do
177
+ @reporter.usages.should =~ [@use_1, @use_2]
178
+ end
179
+
180
+ it "should return unused steps" do
181
+ @reporter.unused.should =~ [@use_3]
182
+ end
183
+
184
+ it "should return the number of unused steps" do
185
+ @reporter.unused_step_count.should == 1
186
+ end
187
+ end
188
+
189
+ describe "returning empty scenarios" do
190
+
191
+ it "should return scenarios with no steps" do
192
+ scen_1 = Stepdown::Scenario.new('scenario')
193
+ scen_2 = Stepdown::Scenario.new('scenario')
194
+
195
+ @reporter = Stepdown::Statistics.new([scen_1, scen_2], Stepdown::StepCollection.new)
196
+
197
+ @reporter.empty().should == [scen_1,scen_2]
198
+ end
199
+
200
+ it "should not return scenarios with steps" do
201
+ scen_1 = Stepdown::Scenario.new('scenario')
202
+ scen_2 = Stepdown::Scenario.new('scenario')
203
+
204
+ scen_1.add_step(Stepdown::Step.new(1,/regex/))
205
+
206
+ @reporter = Stepdown::Statistics.new([scen_1, scen_2], Stepdown::StepCollection.new)
207
+
208
+ @reporter.empty().should == [scen_2]
209
+ end
210
+
211
+ end
212
+
213
+ describe "report helpers" do
214
+ before :each do
215
+ @top_10 = [1,2,3,4,5,6,7,8,9,10]
216
+ @rest = [11,12]
217
+ @all = @top_10 + @rest
218
+ @stats = Stepdown::Statistics.new([], mock('step_collection'))
219
+ end
220
+
221
+ methods = ["groupings", "usages", "empty", "unused"]
222
+
223
+ methods.each do |method|
224
+ it "should return the top 10 #{method}" do
225
+ @stats.should_receive(method.to_sym).and_return(@all)
226
+ @stats.send("#{method}_top".to_sym).should eql @top_10
227
+ end
228
+ end
229
+
230
+ methods.each do |method|
231
+ it "should return the rest of #{method}" do
232
+ @stats.stub!(method.to_sym).and_return(@all)
233
+ @stats.send("#{method}_rest".to_sym).should eql @rest
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'step_collection'
3
+ require 'step'
4
+
5
+ describe Stepdown::StepCollection do
6
+
7
+ before :each do
8
+ @collection = Stepdown::StepCollection.new
9
+ end
10
+
11
+ it "should return an empty hash when for an empty group" do
12
+ @collection.steps.should be_empty
13
+ end
14
+
15
+ it "should return the current steps in the group" do
16
+ @collection.add_step(1,/regex 1/)
17
+ @collection.add_step(2,/regex 2/)
18
+ @collection.add_step(3,/regex 3/)
19
+
20
+ @collection.steps.collect{|s| s.regex }.should =~ [/regex 1/,/regex 2/,/regex 3/]
21
+ end
22
+
23
+ describe "adding a step to the step group" do
24
+ before :each do
25
+ @collection = Stepdown::StepCollection.new
26
+ end
27
+
28
+ it "should add new steps" do
29
+ step = mock("step")
30
+ Stepdown::Step.stub!(:new).and_return(step)
31
+ step.should_receive(:count=).with(1)
32
+ @collection.add_step(1, /regex/)
33
+ @collection.steps.should == [step]
34
+
35
+ end
36
+
37
+ it "should update the count for an existing step" do
38
+
39
+ @collection.add_step(1,/regex/)
40
+ @collection.add_step(1,/regex/)
41
+
42
+ @collection.steps[0].count.should == 2
43
+ end
44
+
45
+ it "should update step counts when multiple steps present" do
46
+ @collection.add_step(1,/regex/)
47
+ @collection.add_step(1,/regex/)
48
+
49
+ @collection.add_step(2,/regex/)
50
+
51
+ @collection.add_step(3,/regex/)
52
+ @collection.add_step(3,/regex/)
53
+ @collection.add_step(3,/regex/)
54
+
55
+ @collection.steps.detect{|s| s.id == 1}.count.should == 2
56
+ @collection.steps.detect{|s| s.id == 2}.count.should == 1
57
+ @collection.steps.detect{|s| s.id == 3}.count.should == 3
58
+
59
+ end
60
+
61
+ end
62
+
63
+ describe "acting as an array" do
64
+ before :each do
65
+ @collection = Stepdown::StepCollection.new
66
+ end
67
+
68
+ it "should return a step for an existing id" do
69
+ @collection.add_step(0, /regex/)
70
+ @collection[0].should be_instance_of(Stepdown::Step)
71
+ end
72
+
73
+ it "should return nil for a step that doesn't exist" do
74
+ @collection[1].should be_nil
75
+ end
76
+ end
77
+
78
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'step_group'
3
+ require 'step'
4
+
5
+ describe Stepdown::StepGroup do
6
+
7
+ describe "returning the number of steps that are near the current step" do
8
+ before :each do
9
+ @step_group = Stepdown::StepGroup.new(Stepdown::Step.new(0,/regex/))
10
+ end
11
+
12
+ it "should return the steps ordered by use count" do
13
+ @step_group.add_step(Stepdown::Step.new(1,/regex/))
14
+ @step_group.add_step(Stepdown::Step.new(1,/regex/))
15
+ @step_group.add_step(Stepdown::Step.new(3,/regex/))
16
+ @step_group.add_step(Stepdown::Step.new(3,/regex/))
17
+ @step_group.add_step(Stepdown::Step.new(3,/regex/))
18
+ @step_group.add_step(Stepdown::Step.new(2,/regex/))
19
+
20
+ @step_group.step_collection[0].count.should == 3
21
+ @step_group.step_collection[1].count.should == 2
22
+ @step_group.step_collection[2].count.should == 1
23
+ end
24
+
25
+ end
26
+
27
+ describe "updating the use count of the main step" do
28
+ before :each do
29
+ @step_group = Stepdown::StepGroup.new(Stepdown::Step.new(0,/regex/))
30
+ end
31
+
32
+ it "should return 0 for an empty group" do
33
+ @step_group.use_count.should be_zero
34
+ end
35
+
36
+ it "should return 0 for an empty group" do
37
+ @step_group.update_use_count(10)
38
+ @step_group.use_count.should == 10
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ require 'step_instance'
3
+ require 'step'
4
+
5
+
6
+ describe Stepdown::StepInstance do
7
+
8
+ before :each do
9
+ @step_instance = Stepdown::StepInstance.new
10
+ end
11
+
12
+ it "should deal with missing constants" do
13
+ lambda{ @step_instance.instance_eval("MissingConst") }.should_not raise_error
14
+ lambda{ @step_instance.instance_eval("MissingConst::MissingClass") }.should_not raise_error
15
+ lambda{ @step_instance.instance_eval("MissingConst::MissingClass.missing_method") }.should_not raise_error
16
+ end
17
+
18
+ it "should deal with missing methods" do
19
+ lambda{ @step_instance.doesnt_exist }.should_not raise_error
20
+ lambda{ Stepdown::StepInstance.doesnt_exist }.should_not raise_error
21
+ end
22
+
23
+ describe "returning steps" do
24
+ it "should return parsed steps" do
25
+ @step_instance.Given(/given/)
26
+ @step_instance.When(/when/)
27
+ @step_instance.Then(/then/)
28
+
29
+ @step_instance.step_collection.length.should == 3
30
+ end
31
+
32
+ end
33
+
34
+ describe "returning matched steps" do
35
+ it "should return nil when no matching step found" do
36
+ @step_instance.Given(/some step/)
37
+ @step_instance.line_matches("Given some other step").should be_nil
38
+ end
39
+
40
+ it "should parse And steps" do
41
+ @step_instance.Given(/matched step/)
42
+ @step_instance.line_matches("And matched step").regex.should == /matched step/
43
+ end
44
+
45
+ it "should parse Given steps" do
46
+ @step_instance.Given(/matched step/)
47
+ @step_instance.line_matches("Given matched step").regex.should == /matched step/
48
+ end
49
+
50
+ it "should parse When steps" do
51
+ @step_instance.When(/matched step/)
52
+ @step_instance.line_matches("When matched step").regex.should == /matched step/
53
+ end
54
+
55
+ it "should parse Then steps" do
56
+ @step_instance.Then(/matched step/)
57
+ @step_instance.line_matches("Then matched step").regex.should == /matched step/
58
+ end
59
+
60
+ end
61
+
62
+ describe "parsing step definitions" do
63
+ before :each do
64
+ @regex = /reg/
65
+ end
66
+
67
+ it "should define given steps" do
68
+ @step_instance.Given(@regex)
69
+ @step_instance.step_collection.should be_an_instance_of Stepdown::StepCollection
70
+ @step_instance.step_collection.count.should == 1
71
+ end
72
+
73
+ it "should define when steps" do
74
+ @step_instance.When(@regex)
75
+ @step_instance.step_collection.should be_an_instance_of Stepdown::StepCollection
76
+ @step_instance.step_collection.count.should == 1
77
+ end
78
+
79
+ it "should define then steps" do
80
+ @step_instance.Then(@regex)
81
+ @step_instance.step_collection.should be_an_instance_of Stepdown::StepCollection
82
+ @step_instance.step_collection.count.should == 1
83
+ end
84
+ end
85
+ end