dcov 0.1.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.
File without changes
data/spec/dcov_spec.rb ADDED
@@ -0,0 +1,101 @@
1
+ # TODO: Make these platform independent (they're UNIX only right now)
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper.rb'
4
+ require File.dirname(__FILE__) + '/../lib/dcov.rb'
5
+
6
+ describe "A new Dcov::Coverage object" do
7
+ before(:each) do
8
+ @myopts = OptionsMock.new
9
+ end
10
+
11
+ before(:all) do
12
+ @myopts = OptionsMock.new
13
+
14
+ @analyzer = Dcov::Analyzer.new(@myopts)
15
+ end
16
+
17
+ it "should be of class Dcov::Coverage." do
18
+ @analyzer.class.should == Dcov::Analyzer
19
+ end
20
+
21
+ it "should have the given hierarchy in an attribute." do
22
+ puts @analyzer.hierarchy
23
+ end
24
+
25
+ it "should give correct coverage information on classes." do
26
+ @analyzer.stats.coverage_rating(:class).should == 20
27
+ end
28
+
29
+ it "should give correct coverage information on modules." do
30
+ @analyzer.stats.coverage_rating(:module).should == 33
31
+ end
32
+
33
+ it "should give correct coverage information on methods." do
34
+ @analyzer.stats.coverage_rating(:method).should == 50
35
+ end
36
+
37
+ it "should properly process a class." do
38
+ @myopts[:files] = 'spec/just_a_class.rb'
39
+ coverage_is_zero = Dcov::Analyzer.new(@myopts)
40
+
41
+ coverage_is_zero.stats.coverage_rating(:class).should == 50
42
+ end
43
+
44
+ it "should properly process a module." do
45
+ @myopts[:files] = 'spec/just_a_module.rb'
46
+ coverage_is_zero = Dcov::Analyzer.new(@myopts)
47
+
48
+ coverage_is_zero.stats.coverage_rating(:module).should == 50
49
+ end
50
+
51
+ it "should properly process a method." do
52
+ @myopts[:files] = 'spec/just_a_method.rb'
53
+ coverage_is_zero = Dcov::Analyzer.new(@myopts)
54
+
55
+ coverage_is_zero.stats.coverage_rating(:method).should == 50
56
+ end
57
+
58
+ it "should generate HTML." do
59
+ File.exists?('coverage.html').should == true
60
+ end
61
+
62
+ it "should go through the whole process without breaking!" do
63
+ lambda { Dcov::Analyzer.new(@myopts) }.should_not raise_error(Exception)
64
+ end
65
+
66
+ it "should give an exception if no files are given." do
67
+ @myopts[:files] = ''
68
+ lambda { Dcov::Analyzer.new(@myopts) }.should raise_error(RuntimeError)
69
+
70
+ @myopts[:files] = nil
71
+ lambda { Dcov::Analyzer.new(@myopts) }.should raise_error(RuntimeError)
72
+ end
73
+
74
+ it "should raise an exception if told to process the wrong object." do
75
+ # TODO: make a mock object
76
+ end
77
+
78
+ it "should raise a (sane, readable) exception if the HTML file isn't writable." do
79
+ `touch coverage.html; chmod 000 coverage.html`
80
+ lambda { Dcov::Analyzer.new(@myopts) }.should raise_error(RuntimeError)
81
+ `chmod 744 coverage.html`
82
+ end
83
+
84
+ it "should still analyze if the structure is invalid." do
85
+ # TODO: Make a mock structure
86
+ end
87
+
88
+ it "should return zero for coverage if the structure is empty." do
89
+ @myopts[:files] = 'spec/blank_code.rb'
90
+ coverage_is_zero = Dcov::Analyzer.new(@myopts)
91
+
92
+ coverage_is_zero.stats.coverage_rating(:class).should == 0
93
+ coverage_is_zero.stats.coverage_rating(:module).should == 0
94
+ coverage_is_zero.stats.coverage_rating(:method).should == 0
95
+ end
96
+
97
+ after(:all) do
98
+ `chmod 744 coverage.html; rm coverage.html`
99
+ end
100
+
101
+ end
@@ -0,0 +1,6 @@
1
+ class Undocumented
2
+ end
3
+
4
+ # I am documented.
5
+ class Documented
6
+ end
@@ -0,0 +1,7 @@
1
+ class CoverMe
2
+ def undocumented
3
+ end
4
+
5
+ # I am documented.
6
+ def documented
7
+ end
@@ -0,0 +1,6 @@
1
+ module Undocumented
2
+ end
3
+
4
+ # I am documented.
5
+ module Documented
6
+ end
data/spec/mock_code.rb ADDED
@@ -0,0 +1,35 @@
1
+ # Hello.
2
+ class Paragraph
3
+ class Sentence
4
+ end
5
+
6
+ # Hey, hi!
7
+ def initialize
8
+ end
9
+ end
10
+
11
+ module Document
12
+ module HTML
13
+ class HTMLElement
14
+
15
+ end
16
+ end
17
+
18
+ class Element
19
+ def initialize
20
+ end
21
+
22
+ def parse
23
+ end
24
+
25
+ # The main method
26
+ def elementize
27
+ end
28
+ end
29
+ end
30
+
31
+ # Module to hold all our math functions
32
+ module Math
33
+ class Sin
34
+ end
35
+ end
@@ -0,0 +1,11 @@
1
+ class OptionsMock < Hash
2
+ def initialize
3
+ self[:files] = "spec/mock_code.rb"
4
+ self[:output_format] = "html"
5
+ self[:path] = Dir.getwd
6
+ end
7
+
8
+ def method_missing(*args)
9
+ false
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: dcov
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-07-07 00:00:00 -04:00
8
+ summary: A documentation analysis tool for Ruby.
9
+ require_paths:
10
+ - lib
11
+ email: jeremymcanally@gmail.com
12
+ homepage: http://dcov.rubyforge.org
13
+ rubyforge_project: dcov
14
+ description: A documentation analysis tool for Ruby.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Jeremy McAnally
31
+ files:
32
+ - History.txt
33
+ - License.txt
34
+ - Manifest.txt
35
+ - README.txt
36
+ - Rakefile
37
+ - bin/dcov
38
+ - lib/dcov.rb
39
+ - lib/dcov/analyzer.rb
40
+ - lib/dcov/version.rb
41
+ - lib/dcov/stats.rb
42
+ - lib/dcov/analyzed_token.rb
43
+ - lib/dcov/generators/html/generator.rb
44
+ - lib/dcov/analyzers/coverage_analyzer.rb
45
+ - setup.rb
46
+ - spec/dcov_spec.rb
47
+ - spec/spec_helper.rb
48
+ - spec/blank_code.rb
49
+ - spec/just_a_class.rb
50
+ - spec/just_a_method.rb
51
+ - spec/just_a_module.rb
52
+ - spec/mock_code.rb
53
+ test_files: []
54
+
55
+ rdoc_options:
56
+ - --main
57
+ - README.txt
58
+ extra_rdoc_files:
59
+ - History.txt
60
+ - License.txt
61
+ - Manifest.txt
62
+ - README.txt
63
+ executables:
64
+ - dcov
65
+ extensions: []
66
+
67
+ requirements: []
68
+
69
+ dependencies:
70
+ - !ruby/object:Gem::Dependency
71
+ name: ruport
72
+ version_requirement:
73
+ version_requirements: !ruby/object:Gem::Version::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 0.0.1
78
+ version: