stepdown 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/Gemfile +4 -2
  2. data/Gemfile.lock +14 -10
  3. data/History.txt +30 -0
  4. data/README.rdoc +2 -2
  5. data/Rakefile +13 -0
  6. data/bin/stepdown +4 -4
  7. data/lib/stepdown.rb +6 -0
  8. data/lib/stepdown/analyzer.rb +67 -0
  9. data/lib/stepdown/feature_parser.rb +30 -0
  10. data/lib/stepdown/html_reporter.rb +41 -0
  11. data/lib/stepdown/options.rb +59 -0
  12. data/lib/stepdown/reporter.rb +106 -0
  13. data/lib/stepdown/scenario.rb +25 -0
  14. data/lib/stepdown/step.rb +22 -0
  15. data/lib/stepdown/step_collection.rb +36 -0
  16. data/lib/stepdown/step_group.rb +45 -0
  17. data/lib/stepdown/step_instance.rb +63 -0
  18. data/lib/stepdown/step_usage.rb +15 -0
  19. data/lib/stepdown/text_reporter.rb +38 -0
  20. data/spec/lib/{feature_parser_spec.rb → stepdown/feature_parser_spec.rb} +13 -12
  21. data/spec/lib/{options_spec.rb → stepdown/options_spec.rb} +24 -6
  22. data/spec/lib/stepdown/reporter_spec.rb +184 -0
  23. data/spec/lib/stepdown/scenario_spec.rb +40 -0
  24. data/spec/lib/stepdown/step_collection_spec.rb +78 -0
  25. data/spec/lib/stepdown/step_group_spec.rb +43 -0
  26. data/spec/lib/{step_instance_spec.rb → stepdown/step_instance_spec.rb} +13 -12
  27. data/spec/spec_helper.rb +4 -0
  28. data/stepdown.gemspec +7 -4
  29. data/templates/main.html.haml +3 -3
  30. data/templates/style.sass +5 -4
  31. metadata +64 -34
  32. data/lib/counting_step.rb +0 -14
  33. data/lib/feature_parser.rb +0 -32
  34. data/lib/html_reporter.rb +0 -37
  35. data/lib/options.rb +0 -69
  36. data/lib/reporter.rb +0 -62
  37. data/lib/scenario.rb +0 -19
  38. data/lib/step.rb +0 -10
  39. data/lib/step_down.rb +0 -112
  40. data/lib/step_group.rb +0 -52
  41. data/lib/step_instance.rb +0 -60
  42. data/lib/step_usage.rb +0 -13
  43. data/lib/text_reporter.rb +0 -36
  44. data/spec/lib/scenario_spec.rb +0 -42
  45. data/spec/lib/step_group_spec.rb +0 -119
@@ -1,13 +0,0 @@
1
- class StepUsage
2
-
3
- attr_accessor :total_usage, :number_scenarios, :use_scenario
4
- attr_reader :step
5
-
6
- def initialize(step)
7
- @step = step
8
- @total_usage = 0
9
- @number_scenarios = 0
10
- @use_scenario = 0.0
11
- end
12
-
13
- end
@@ -1,36 +0,0 @@
1
- require 'reporter'
2
-
3
- class TextReporter < Reporter
4
-
5
- def output_overview
6
- puts "Generating report..."
7
- output = File.new(Reporter::OUTPUT_DIR + '/analysis.txt', "w+")
8
-
9
- output.puts "Total number of scenarios: #{total_scenarios}"
10
- output.puts "Total numer of steps: #{total_steps}"
11
- output.puts "Steps per scenario: #{steps_per_scenario}"
12
- output.puts "Unique steps per scenario: #{unique_steps}"
13
-
14
- output.puts "Step usages"
15
- usages.each{|use| output.puts used_step_line(use) }
16
-
17
- output.puts "Unused steps"
18
- unused_steps.each{|use| output.puts unused_step_line(use) }
19
-
20
- output.close
21
-
22
- puts "Report output to #{Reporter::OUTPUT_DIR}/analysis.txt"
23
-
24
- end
25
-
26
- def used_step_line(use)
27
- line = [use.step.regex.inspect, use.total_usage, use.number_scenarios, use.use_scenario]
28
- line.join("|")
29
- end
30
-
31
- def unused_step_line(use)
32
- use.step.regex
33
- end
34
-
35
-
36
- end
@@ -1,42 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/scenario')
2
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/step')
3
-
4
-
5
- describe Scenario do
6
- before :each do
7
- @scenario = Scenario.new
8
- @s1 = Step.new(1, /step 1/)
9
- @s2 = Step.new(2, /Step 2/)
10
- @s2_dup = Step.new(2, /Step 2/)
11
- @s3 = Step.new(3, /Step 3/)
12
-
13
- end
14
-
15
- describe "adding steps" do
16
- it "should add steps to cache" do
17
- @scenario.add_step(@s1)
18
- @scenario.add_step(@s2)
19
- @scenario.add_step(@s2_dup)
20
- @scenario.add_step(@s3)
21
-
22
- steps = [@s1, @s2, @s2_dup, @s3]
23
- @scenario.steps.should =~ steps
24
- end
25
-
26
- end
27
-
28
- describe "returning unique steps" do
29
- it "should only return one instance of each step" do
30
- @scenario.add_step(@s1)
31
- @scenario.add_step(@s2)
32
- @scenario.add_step(@s2_dup)
33
- @scenario.add_step(@s3)
34
-
35
- steps = [@s1, @s2, @s3]
36
- @scenario.uniq_steps.should =~ steps
37
- end
38
-
39
- end
40
-
41
- end
42
-
@@ -1,119 +0,0 @@
1
- require 'rspec'
2
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/step_group')
3
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/counting_step')
4
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/step')
5
-
6
- describe StepGroup do
7
-
8
- describe "returning the number of steps that are near the current step" do
9
- before :each do
10
- @step_group = StepGroup.new(Step.new(0,/regex/))
11
- end
12
-
13
- it "should return an empty hash when for an empty group" do
14
- @step_group.in_steps.should be_empty
15
- end
16
-
17
- it "should return the current steps in the group" do
18
- @step_group.add_step(Step.new(1,/regex/))
19
- @step_group.add_step(Step.new(2,/regex/))
20
- @step_group.add_step(Step.new(3,/regex/))
21
-
22
- @step_group.in_steps.count.should == 3
23
- end
24
-
25
- it "should return the steps ordered by use count" do
26
- @step_group.add_step(Step.new(1,/regex/))
27
- @step_group.add_step(Step.new(1,/regex/))
28
- @step_group.add_step(Step.new(3,/regex/))
29
- @step_group.add_step(Step.new(3,/regex/))
30
- @step_group.add_step(Step.new(3,/regex/))
31
- @step_group.add_step(Step.new(2,/regex/))
32
-
33
- @step_group.in_steps[0][1].count.should == 3
34
- @step_group.in_steps[1][1].count.should == 2
35
- @step_group.in_steps[2][1].count.should == 1
36
- end
37
-
38
- end
39
-
40
- describe "adding a step to the step group" do
41
- before :each do
42
- @step_group = StepGroup.new(Step.new(0,/regex/))
43
- end
44
-
45
- it "should add new steps" do
46
- step1 = Step.new(1,/regex/)
47
- counting_step = mock("counting_step")
48
- CountingStep.stub!(:new).and_return(counting_step)
49
- counting_step.should_receive(:count=).with(1)
50
- @step_group.add_step(step1)
51
- @step_group.in_steps.should == [[1, counting_step]]
52
-
53
- end
54
-
55
- it "should update the count for an existing step" do
56
-
57
- step1 = Step.new(1,/regex/)
58
- @step_group.add_step(step1)
59
- @step_group.add_step(step1)
60
-
61
- @step_group.in_steps[0][1].count.should == 2
62
- end
63
-
64
- it "should update step counts when multiple steps present" do
65
- step1 = Step.new(1,/regex/)
66
- @step_group.add_step(step1)
67
- @step_group.add_step(step1)
68
-
69
- step2 = Step.new(2,/regex/)
70
- @step_group.add_step(step2)
71
-
72
- step3 = Step.new(3,/regex/)
73
- @step_group.add_step(step3)
74
- @step_group.add_step(step3)
75
- @step_group.add_step(step3)
76
-
77
- @step_group.in_steps[0][1].count.should == 3
78
- @step_group.in_steps[1][1].count.should == 2
79
- @step_group.in_steps[2][1].count.should == 1
80
-
81
- end
82
-
83
- end
84
-
85
- describe "updating the use count of the main step" do
86
- before :each do
87
- @step_group = StepGroup.new(Step.new(0,/regex/))
88
- end
89
-
90
- it "should return 0 for an empty group" do
91
- @step_group.update_use_count.should be_zero
92
- end
93
-
94
- it "should return the total use" do
95
- @step_group.add_step(Step.new(1,/regex/))
96
- @step_group.add_step(Step.new(1,/regex/))
97
- @step_group.add_step(Step.new(3,/regex/))
98
- @step_group.add_step(Step.new(4,/regex/))
99
- @step_group.add_step(Step.new(1,/regex/))
100
-
101
- @step_group.update_use_count.should == 5
102
- end
103
-
104
- it "should update the use when new steps are added" do
105
- @step_group.add_step(Step.new(1,/regex/))
106
- @step_group.add_step(Step.new(1,/regex/))
107
-
108
- @step_group.update_use_count.should == 2
109
-
110
- @step_group.add_step(Step.new(3,/regex/))
111
- @step_group.add_step(Step.new(4,/regex/))
112
- @step_group.add_step(Step.new(1,/regex/))
113
-
114
- @step_group.update_use_count.should == 5
115
- end
116
-
117
- end
118
-
119
- end