rubyunit 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f59c9d974102a2a557aa6bde7e35c49731cf4b6
4
- data.tar.gz: c5eaac709c31dc071c98259bf683ea2cf2070cec
3
+ metadata.gz: 28a9809b472a236515ef571df2e8547159e86069
4
+ data.tar.gz: 0ea9d91b0c0ca5cc31d1a499d55ac511780117ac
5
5
  SHA512:
6
- metadata.gz: 9b0dbdfd91a9855483effd2f3763c5e8e11fb011d9a1af8253f7db2303265299ea6fc54e72dae055311ea046331675df79a916a4b925259c146319a54e37c2b9
7
- data.tar.gz: dec418bbbdd574a48215a87409ed79c5eb185d760907b4d015212bbed9d94e0fff81b8df8c6c412b1d54ee56f7802c75eefd473c3c68998e46298e791c8948be
6
+ metadata.gz: a9ade60f35da0753441b01ac931cda5bf8d224815b7dc2465f00322e7eb8d4ca28b4528b47c481d80efb421cb57874010c3954caa307a742722629a45000d06d
7
+ data.tar.gz: 75897620958a179618807275c86c57e2813eecc712196b407ae125cc7cb37fee90d504f05c7e3c1ba1be93900696a8cdde204a8c41876e0b54a4d38821500b42
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  RubyUnit
2
2
  ========
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/rubyunit@2x.png)](http://badge.fury.io/rb/rubyunit)
4
+ [![Gem Version](https://badge.fury.io/rb/rubyunit.png)](http://badge.fury.io/rb/rubyunit)
5
+ [![Code Climate](https://codeclimate.com/github/RubyUnit/RubyUnit/badges/gpa.svg)](https://codeclimate.com/github/RubyUnit/RubyUnit)
6
+ [![Test Coverage](https://codeclimate.com/github/RubyUnit/RubyUnit/badges/coverage.svg)](https://codeclimate.com/github/RubyUnit/RubyUnit)
5
7
 
6
- <!-- This isn't up yet...
7
- * http://rubyunit.github.io/ -->
8
8
 
9
+ * http://rubyunit.github.io/
9
10
  * https://github.com/RubyUnit/RubyUnit
10
11
 
11
12
 
@@ -0,0 +1,48 @@
1
+ # Extend the class to add data providing functions
2
+ module RealNumberData
3
+ def positiveData
4
+ [
5
+ [ Integer(1),],
6
+ [ Integer(4242),],
7
+ [Integer(100000000000),],
8
+ [Integer(424200000000),],
9
+ [ Float(0.1),],
10
+ [ Float(1.0),],
11
+ [ Float(42.42),],
12
+ [ Rational(1,42),],
13
+ [ Rational(1,1),],
14
+ [ Rational(4242,42),],
15
+ ]
16
+ end
17
+
18
+ def zeroData
19
+ [
20
+ [ Integer(0)],
21
+ [ Float(0.0)],
22
+ [Rational(0,1)],
23
+ ]
24
+ end
25
+
26
+ def negativeData
27
+ [
28
+ [ Integer(-1),],
29
+ [ Integer(-4242),],
30
+ [Integer(-100000000000),],
31
+ [Integer(-424200000000),],
32
+ [ Float(-0.1),],
33
+ [ Float(-1.0),],
34
+ [ Float(-42.42),],
35
+ [ Rational(-1,42),],
36
+ [ Rational(-1,1),],
37
+ [ Rational(-4242,42),],
38
+ ]
39
+ end
40
+
41
+ def notPositiveData
42
+ zeroData + negativeData
43
+ end
44
+
45
+ def notNegativeData
46
+ zeroData + positiveData
47
+ end
48
+ end
@@ -1,7 +1,10 @@
1
1
  require_relative 'RealNumber'
2
+ require_relative 'RealNumberData'
2
3
 
3
4
  # Test for RealNumber mixin
4
5
  class RealNumberTest < RubyUnit::TestCase
6
+ include RealNumberData
7
+
5
8
  def positiveTest value
6
9
  assert value.positive?, "#{value.class}:(#{value}) should be positive!"
7
10
  end
@@ -18,52 +21,3 @@ class RealNumberTest < RubyUnit::TestCase
18
21
  assertNot value.negative?, "#{value.class}:(#{value}) should not be negative!"
19
22
  end
20
23
  end
21
-
22
- # Extend the class to add data providing functions
23
- class RealNumberTest
24
- def positiveData
25
- [
26
- [ Integer(1),],
27
- [ Integer(4242),],
28
- [Integer(100000000000),],
29
- [Integer(424200000000),],
30
- [ Float(0.1),],
31
- [ Float(1.0),],
32
- [ Float(42.42),],
33
- [ Rational(1,42),],
34
- [ Rational(1,1),],
35
- [ Rational(4242,42),],
36
- ]
37
- end
38
-
39
- def zeroData
40
- [
41
- [ Integer(0)],
42
- [ Float(0.0)],
43
- [Rational(0,1)],
44
- ]
45
- end
46
-
47
- def negativeData
48
- [
49
- [ Integer(-1),],
50
- [ Integer(-4242),],
51
- [Integer(-100000000000),],
52
- [Integer(-424200000000),],
53
- [ Float(-0.1),],
54
- [ Float(-1.0),],
55
- [ Float(-42.42),],
56
- [ Rational(-1,42),],
57
- [ Rational(-1,1),],
58
- [ Rational(-4242,42),],
59
- ]
60
- end
61
-
62
- def notPositiveData
63
- zeroData + negativeData
64
- end
65
-
66
- def notNegativeData
67
- zeroData + positiveData
68
- end
69
- end
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Sample Test
3
+ # require RubyUnit framework
4
4
  require 'RubyUnit'
5
+
6
+ # Example test for RealNumber mixin
5
7
  require_relative 'RealNumberTest'
@@ -1,21 +1,23 @@
1
- require 'RubyUnit/TestCase'
2
- require 'RubyUnit/AssertionFailure'
1
+ require_relative 'TestCase'
2
+ require_relative 'AssertionFailure'
3
3
 
4
4
  module RubyUnit
5
5
  class Runner
6
- protected
7
- @@test_cases = []
8
- @@failures = []
9
- @@errors = []
10
- @@tests = 0
11
- @@start = nil
12
- @@finish = nil
13
-
14
6
  class << self
7
+ protected
8
+ @@test_cases = []
9
+ @@failures = []
10
+ @@errors = []
11
+ @@tests = 0
12
+ @@start = nil
13
+ @@finish = nil
14
+ @@autorun = true
15
+
15
16
  public
16
17
  def run
17
- @@start = Time.new
18
- runner = new
18
+ @@autorun = false
19
+ @@start = Time.new
20
+ runner = new
19
21
  TestCase.descendents.each do |object|
20
22
  @@test_cases << object
21
23
 
@@ -39,12 +41,18 @@ module RubyUnit
39
41
  end
40
42
  end
41
43
  @@finish = Time.new
42
- report
44
+ report unless @@tests.zero?
45
+ @@failures.count + @@errors.count
46
+ end
47
+
48
+ def autorun?
49
+ @@autorun
43
50
  end
44
51
 
45
52
  protected
46
53
  def report
47
54
  # haven't figured out what I want to do for reporting yet but I need some results
55
+ puts "RubyUnit #{RubyUnit::version}"
48
56
  puts "Started Tests #{@@start.strftime("%Y-%m-%d %H:%M:%S")}"
49
57
 
50
58
  puts "#{@@errors.count} Errors:\n" if @@errors.count > 0
@@ -68,6 +76,7 @@ module RubyUnit
68
76
  puts "%.3f tests/s, %.3f assertions/s" % [(@@tests * inverse).to_f, (TestCase.assertions * inverse).to_f]
69
77
  puts "%d Tests, %d Assertions, %d Errors, %d Failures" % [@@tests, TestCase.assertions, @@errors.count, @@failures.count]
70
78
  puts
79
+
71
80
  end
72
81
  end
73
82
 
@@ -1,4 +1,4 @@
1
- require 'RubyUnit/AssertionFailure'
1
+ require_relative 'AssertionFailure'
2
2
 
3
3
  module RubyUnit
4
4
  class TestCase
data/lib/RubyUnit.rb CHANGED
@@ -1,12 +1,41 @@
1
1
  module RubyUnit
2
+ @@build = 5
3
+ VERSION = '0.0'
4
+
5
+ protected
6
+ public
7
+ def self.debug?
8
+ @@debug
9
+ end
10
+
11
+ def self.build
12
+ @@build
13
+ end
14
+
15
+ def self.version
16
+ "#{VERSION}.#{build}"
17
+ end
18
+
19
+ class GemInfo
20
+ class << self
21
+ def files
22
+ static = ['README.md', 'LICENSE']
23
+ libs = Dir['lib/**/*.rb']
24
+ examples = Dir['example/*.rb']
25
+
26
+ static + libs + examples
27
+ end
28
+ end
29
+ end
2
30
  end
3
31
 
4
- require 'RubyUnit/TestCase'
5
- require 'RubyUnit/Runner'
32
+ require_relative 'RubyUnit/TestCase'
33
+ require_relative 'RubyUnit/Runner'
34
+
6
35
  # Automatically run test cases
7
36
  Module.new do
8
- if $ERROR_INFO.nil?
9
- at_exit do
37
+ at_exit do
38
+ if $ERROR_INFO.nil? and RubyUnit::Runner.autorun?
10
39
  RubyUnit::Runner.run
11
40
  end
12
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Clower
@@ -21,13 +21,13 @@ files:
21
21
  - LICENSE
22
22
  - README.md
23
23
  - example/RealNumber.rb
24
+ - example/RealNumberData.rb
24
25
  - example/RealNumberTest.rb
25
- - example/test.rb
26
+ - example/TestSet.rb
26
27
  - lib/RubyUnit.rb
27
28
  - lib/RubyUnit/AssertionFailure.rb
28
29
  - lib/RubyUnit/Runner.rb
29
30
  - lib/RubyUnit/TestCase.rb
30
- - lib/RubyUnit/version.rb
31
31
  homepage: http://github.com/RubyUnit/RubyUnit
32
32
  licenses:
33
33
  - LGPL
@@ -1,3 +0,0 @@
1
- module RubyUnit
2
- VERSION = '0.0.4'
3
- end