stepdown 0.3.3 → 0.4.0

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 (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
@@ -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
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,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
@@ -1,12 +1,12 @@
1
- require 'rspec'
2
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/step_instance')
3
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/step')
1
+ require 'spec_helper'
2
+ require 'step_instance'
3
+ require 'step'
4
4
 
5
5
 
6
- describe StepInstance do
6
+ describe Stepdown::StepInstance do
7
7
 
8
8
  before :each do
9
- @step_instance = StepInstance.new
9
+ @step_instance = Stepdown::StepInstance.new
10
10
  end
11
11
 
12
12
  it "should deal with missing constants" do
@@ -17,7 +17,7 @@ describe StepInstance do
17
17
 
18
18
  it "should deal with missing methods" do
19
19
  lambda{ @step_instance.doesnt_exist }.should_not raise_error
20
- lambda{ StepInstance.doesnt_exist }.should_not raise_error
20
+ lambda{ Stepdown::StepInstance.doesnt_exist }.should_not raise_error
21
21
  end
22
22
 
23
23
  describe "returning steps" do
@@ -26,7 +26,7 @@ describe StepInstance do
26
26
  @step_instance.When(/when/)
27
27
  @step_instance.Then(/then/)
28
28
 
29
- @step_instance.steps.length.should == 3
29
+ @step_instance.step_collection.length.should == 3
30
30
  end
31
31
 
32
32
  end
@@ -62,23 +62,24 @@ describe StepInstance do
62
62
  describe "parsing step definitions" do
63
63
  before :each do
64
64
  @regex = /reg/
65
- @step = mock('step')
66
- Step.should_receive(:new).with(0, @regex).and_return(@step)
67
65
  end
68
66
 
69
67
  it "should define given steps" do
70
68
  @step_instance.Given(@regex)
71
- @step_instance.steps.should =~ [@step]
69
+ @step_instance.step_collection.should be_an_instance_of Stepdown::StepCollection
70
+ @step_instance.step_collection.count.should == 1
72
71
  end
73
72
 
74
73
  it "should define when steps" do
75
74
  @step_instance.When(@regex)
76
- @step_instance.steps.should =~ [@step]
75
+ @step_instance.step_collection.should be_an_instance_of Stepdown::StepCollection
76
+ @step_instance.step_collection.count.should == 1
77
77
  end
78
78
 
79
79
  it "should define then steps" do
80
80
  @step_instance.Then(@regex)
81
- @step_instance.steps.should =~ [@step]
81
+ @step_instance.step_collection.should be_an_instance_of Stepdown::StepCollection
82
+ @step_instance.step_collection.count.should == 1
82
83
  end
83
84
  end
84
85
  end
@@ -0,0 +1,4 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib/stepdown')
3
+
4
+ require 'rspec'
@@ -1,10 +1,11 @@
1
1
 
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "stepdown"
4
- s.version = "0.3.3"
4
+ s.version = "0.4.0"
5
5
  s.platform = Gem::Platform::RUBY
6
+ s.required_ruby_version = '>= 1.8.7'
6
7
  s.authors = "Sean Caffery"
7
- s.email = "sean@lineonpoint.com"
8
+ s.email = ["sean@lineonpoint.com"]
8
9
  s.summary = "Static analysis tool for Cucumber features"
9
10
  s.homepage = "http://stepdown.lineonpoint.com"
10
11
  s.description = "Stepdown allows you to see where your most used Cucumber steps are, your unused steps and how they are clustered"
@@ -12,9 +13,11 @@ Gem::Specification.new do |s|
12
13
  s.required_rubygems_version = ">= 1.3.6"
13
14
  s.rubyforge_project = "stepdown"
14
15
 
15
- s.add_dependency('haml', '>= 2.0.0')
16
- s.add_development_dependency('rspec', ">= 2.0.0")
16
+ s.add_dependency('haml', '> 2.0.0')
17
+ s.add_development_dependency('rspec', "~> 2.5.0")
18
+ s.add_development_dependency('rake')
17
19
  s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files spec/*`.split("\n")
18
21
  s.executables = ["stepdown"]
19
22
  s.default_executable = "stepdown"
20
23
  s.require_paths = ["lib"]
@@ -112,7 +112,7 @@
112
112
  %th Association count
113
113
  %th Step
114
114
  %tbody
115
- - grouping.in_steps.each do |step|
115
+ - grouping.step_collection.each do |step|
116
116
  %tr
117
- %td= step[1].count
118
- %td= CGI.escapeHTML step[1].regex.inspect
117
+ %td= step.count
118
+ %td= CGI.escapeHTML step.regex.inspect
@@ -1,21 +1,22 @@
1
1
 
2
2
  body
3
3
  :font-family verdana, helvetica, arial
4
+ :font-size 12px
4
5
 
5
6
  #page_container
6
7
  :width 900px
7
8
  :margin auto
8
9
  table
9
- :border 1px solid black
10
+ :border 1px solid #cccccc
10
11
  :border-spacing 0
11
12
  th
12
- :border 1px solid black
13
+ :border 1px solid #999999
13
14
  :text-align left
14
15
  :padding 3px
15
- :background-color #cccccc
16
+ :background-color #999999
16
17
  td
17
18
  :padding 3px
18
- :border 1px solid black
19
+ :border 1px solid #cccccc
19
20
  :vertical-align top
20
21
  #navigation
21
22
  ul
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stepdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 3
10
- version: 0.3.3
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sean Caffery
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-06 00:00:00 +11:00
18
+ date: 2011-03-29 00:00:00 +11:00
19
19
  default_executable: stepdown
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ">"
28
28
  - !ruby/object:Gem::Version
29
29
  hash: 15
30
30
  segments:
@@ -40,18 +40,33 @@ dependencies:
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 15
45
+ hash: 27
46
46
  segments:
47
47
  - 2
48
+ - 5
48
49
  - 0
49
- - 0
50
- version: 2.0.0
50
+ version: 2.5.0
51
51
  type: :development
52
52
  version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :development
66
+ version_requirements: *id003
53
67
  description: Stepdown allows you to see where your most used Cucumber steps are, your unused steps and how they are clustered
54
- email: sean@lineonpoint.com
68
+ email:
69
+ - sean@lineonpoint.com
55
70
  executables:
56
71
  - stepdown
57
72
  extensions: []
@@ -63,27 +78,33 @@ files:
63
78
  - .rspec
64
79
  - Gemfile
65
80
  - Gemfile.lock
81
+ - History.txt
66
82
  - README.rdoc
83
+ - Rakefile
67
84
  - bin/stepdown
68
- - lib/counting_step.rb
69
- - lib/feature_parser.rb
70
- - lib/html_reporter.rb
71
- - lib/options.rb
72
- - lib/reporter.rb
73
- - lib/scenario.rb
74
- - lib/step.rb
75
- - lib/step_down.rb
76
- - lib/step_group.rb
77
- - lib/step_instance.rb
78
- - lib/step_usage.rb
79
- - lib/text_reporter.rb
85
+ - lib/stepdown.rb
86
+ - lib/stepdown/analyzer.rb
87
+ - lib/stepdown/feature_parser.rb
88
+ - lib/stepdown/html_reporter.rb
89
+ - lib/stepdown/options.rb
90
+ - lib/stepdown/reporter.rb
91
+ - lib/stepdown/scenario.rb
92
+ - lib/stepdown/step.rb
93
+ - lib/stepdown/step_collection.rb
94
+ - lib/stepdown/step_group.rb
95
+ - lib/stepdown/step_instance.rb
96
+ - lib/stepdown/step_usage.rb
97
+ - lib/stepdown/text_reporter.rb
80
98
  - public/jquery-1.4.3.min.js
81
99
  - public/step_down.js
82
- - spec/lib/feature_parser_spec.rb
83
- - spec/lib/options_spec.rb
84
- - spec/lib/scenario_spec.rb
85
- - spec/lib/step_group_spec.rb
86
- - spec/lib/step_instance_spec.rb
100
+ - spec/lib/stepdown/feature_parser_spec.rb
101
+ - spec/lib/stepdown/options_spec.rb
102
+ - spec/lib/stepdown/reporter_spec.rb
103
+ - spec/lib/stepdown/scenario_spec.rb
104
+ - spec/lib/stepdown/step_collection_spec.rb
105
+ - spec/lib/stepdown/step_group_spec.rb
106
+ - spec/lib/stepdown/step_instance_spec.rb
107
+ - spec/spec_helper.rb
87
108
  - stepdown.gemspec
88
109
  - templates/main.html.haml
89
110
  - templates/style.sass
@@ -101,10 +122,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
122
  requirements:
102
123
  - - ">="
103
124
  - !ruby/object:Gem::Version
104
- hash: 3
125
+ hash: 57
105
126
  segments:
106
- - 0
107
- version: "0"
127
+ - 1
128
+ - 8
129
+ - 7
130
+ version: 1.8.7
108
131
  required_rubygems_version: !ruby/object:Gem::Requirement
109
132
  none: false
110
133
  requirements:
@@ -119,9 +142,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
142
  requirements: []
120
143
 
121
144
  rubyforge_project: stepdown
122
- rubygems_version: 1.4.2
145
+ rubygems_version: 1.5.3
123
146
  signing_key:
124
147
  specification_version: 3
125
148
  summary: Static analysis tool for Cucumber features
126
- test_files: []
127
-
149
+ test_files:
150
+ - spec/lib/stepdown/feature_parser_spec.rb
151
+ - spec/lib/stepdown/options_spec.rb
152
+ - spec/lib/stepdown/reporter_spec.rb
153
+ - spec/lib/stepdown/scenario_spec.rb
154
+ - spec/lib/stepdown/step_collection_spec.rb
155
+ - spec/lib/stepdown/step_group_spec.rb
156
+ - spec/lib/stepdown/step_instance_spec.rb
157
+ - spec/spec_helper.rb