rubyunit 0.2.12 → 0.2.13

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: fbf27d6a6e8ba4a5897fab6597681d0f111882ee
4
- data.tar.gz: 138330d193919d74c327d2b30cd2ccdc96610243
3
+ metadata.gz: a1b6f9831dc4e7b9f1764b157d1320600730bc6e
4
+ data.tar.gz: a4dc1ce088ce56e36ca70c0219698a72029fc27c
5
5
  SHA512:
6
- metadata.gz: 0b71cdf88ad315fdcdea0aaa6bed6e839adee6415cb72689078aa19cfe592822ea14ddd133625b880ec688cf0e162147dfd8c386ac2ac3daa1f5c5fe335b7848
7
- data.tar.gz: 30985acf14c6a098442926676e015a04a1bed99a5d422c2882e43d7cf1ee86b7dce92f80b659ba42d9478b6c60ac77e250c442727164cb8aaae76acdcd078255
6
+ metadata.gz: 8741adb6fb0ed18fd208ab9dd6492dab1bd7ea508dc2e1ef5b3f787e77b801f9ade9d92008eb931e2339c8f91d5f4f437278ac1746ce0cc8c65c46eedaec2f3c
7
+ data.tar.gz: 8e740f6ffcaa0bbec4b1dfe45fb723d3c861ab37fafe0dc9283808b5c5fa99a413120d005ac37e1f1c3f7bb532c35936603914761afdf8b4c56db136e5bda91d
@@ -3,30 +3,33 @@
3
3
  # IMPORTANT
4
4
  # require relative RubyUnit framework for local so that the tests are run on the build
5
5
  # in this repository
6
- $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if not ARGV.include? '--gem'
6
+ path = File.dirname(__FILE__)
7
+
8
+ $LOAD_PATH.unshift("#{path}/lib") if not ARGV.include? '--gem'
9
+ $LOAD_PATH.unshift("#{path}/tests")
7
10
 
8
11
  require 'RubyUnit'
9
12
 
10
13
  # Test Cases
11
14
 
12
15
  # RubyUnit module => RubyUnit.rb
13
- require_relative 'TEST_RubyUnit'
14
- require_relative 'TEST_GemInfo'
16
+ require 'TEST_RubyUnit'
17
+ require 'TEST_GemInfo'
15
18
 
16
19
  # AssertionFailure exception => RubyUnit/AssertionFailure.rb
17
- require_relative 'TEST_AssertionFailure'
20
+ require 'TEST_AssertionFailure'
18
21
 
19
22
  # Assertions module => RubyUnit/Assertions.rb
20
- require_relative 'TEST_Assertions'
23
+ require 'TEST_Assertions'
21
24
 
22
25
  # IncompleteTest exception => RubyUnit/IncompleteTest.rb
23
- require_relative 'TEST_IncompleteTest'
26
+ require 'TEST_IncompleteTest'
24
27
 
25
28
  # Runner class => RubyUnit/Runner.rb
26
- require_relative 'TEST_Runner'
29
+ require 'TEST_Runner'
27
30
 
28
31
  # SkippedTest exception => RubyUnit/SkippedTest.rb
29
- require_relative 'TEST_SkippedTest'
32
+ require 'TEST_SkippedTest'
30
33
 
31
34
  # TestCase class => RubyUnit/TestCase.rb
32
- require_relative 'TEST_TestCase'
35
+ require 'TEST_TestCase'
@@ -3,5 +3,8 @@ module RubyUnit
3
3
  # Exception that is raised when a test assertion fails.
4
4
  #
5
5
  class AssertionFailure < StandardError
6
+ # Error messages
7
+ FAILING = 'Failing test'
8
+
6
9
  end
7
10
  end
@@ -21,7 +21,7 @@ module RubyUnit
21
21
  # fail "I wasn't expecting the moon to fall into Lake Michigan" # => fail
22
22
  #
23
23
  def fail message = nil, data = {}
24
- build_message 'Failing test', message, data
24
+ build_message AssertionFailure::FAILING, message, data
25
25
  end
26
26
 
27
27
  #
@@ -56,6 +56,54 @@ module RubyUnit
56
56
  __reject value, 'Value should NOT be false or nil', message, {:value=>value}
57
57
  end
58
58
 
59
+ #
60
+ # Assert that a test condition is exactly true.
61
+ # * raises RubyUnit::AssertionFailure unless _value_ is true
62
+ #
63
+ # value::
64
+ # The value that is being checked by the assertion
65
+ #
66
+ # message::
67
+ # The message provided to be reported for a failure
68
+ #
69
+ # assertTrue false, "This will fail" # => fail
70
+ #
71
+ def assertTrue value, message = nil
72
+ __assert (true == value), 'Failed to assert that value is EXACTLY true', message, {:value=>value}
73
+ end
74
+
75
+ #
76
+ # Assert that a test condition is exactly false.
77
+ # * raises RubyUnit::AssertionFailure unless _value_ is false
78
+ #
79
+ # value::
80
+ # The value that is being checked by the assertion
81
+ #
82
+ # message::
83
+ # The message provided to be reported for a failure
84
+ #
85
+ # assertNot true, "This will fail" # => fail
86
+ #
87
+ def assertFalse value, message = nil
88
+ __assert (false == value), 'Failed to assert that value is EXACTLY false', message, {:value=>value}
89
+ end
90
+
91
+ #
92
+ # Assert that a test condition is exactly nil.
93
+ # * raises RubyUnit::AssertionFailure unless _value_ is nil
94
+ #
95
+ # value::
96
+ # The value that is being checked by the assertion
97
+ #
98
+ # message::
99
+ # The message provided to be reported for a failure
100
+ #
101
+ # assertNot true, "This will fail" # => fail
102
+ #
103
+ def assertNil value, message = nil
104
+ __assert value, 'Failed to assert that value is EXACTLY nil', message, {:value=>value}
105
+ end
106
+
59
107
  #
60
108
  # Assert that two values are equal.
61
109
  # * raises RubyUnit::AssertionFailure unless _expected_ equals _actual_
data/lib/RubyUnit.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  module RubyUnit
7
7
  # Current RubyUnit version
8
- VERSION = '0.2.12'
8
+ VERSION = '0.2.13'
9
9
 
10
10
  #
11
11
  # RubyUnit::GemInfo contains data and functionality needed by the gem builder
@@ -13,8 +13,9 @@ module RubyUnit
13
13
  #
14
14
  module GemInfo
15
15
  FILES = ['README.md', 'LICENSE.md'] + # base files at root level
16
- Dir['lib/**/*.rb'] + # library files
17
- Dir['example/*.rb'] + # example files
16
+ Dir['lib/**/*.rb'] + # library files
17
+ Dir['example/*.rb'] + # example files
18
+ ['TestSuite.rb'] + # Test Suite
18
19
  Dir['tests/**/*.rb'] # TESTS
19
20
 
20
21
  DESCRIPTION = 'Unit testing and test-driven development are crucial parts of ' +
@@ -1,7 +1,36 @@
1
1
  require 'RubyUnit/Assertions'
2
2
 
3
+ # Data provider for RubyUnit::TestCase tests
4
+ require_relative 'data/Assertions'
5
+
3
6
  #
4
- # Test Case for RubyUnit::Assertions
7
+ # Test Case for RubyUnit::Assertions module
5
8
  #
6
9
  class TEST_Assertions < RubyUnit::TestCase
10
+ @assertions
11
+
12
+ #
13
+ # Setup tests
14
+ #
15
+ def setup
16
+ @assertions = RubyUnit::TestCase.assertions
17
+ end
18
+
19
+ #
20
+ # Wrapper to rescue assertions
21
+ #
22
+ def rescue_assertion pattern = '', &block
23
+ assertRaiseExpected RubyUnit::AssertionFailure, pattern do
24
+ yield
25
+ end
26
+ end
27
+
28
+ #
29
+ # Test for default failure
30
+ #
31
+ def failTest
32
+ rescue_assertion /#{RubyUnit::AssertionFailure::FAILING}/ do
33
+ fail
34
+ end
35
+ end
7
36
  end
@@ -65,17 +65,17 @@ class TEST_TestCase < RubyUnit::TestCase
65
65
  end
66
66
 
67
67
  #
68
- # Test that the correct class methods are defined
68
+ # Test that descendents method includes this class
69
69
  #
70
- def classMethodTest method
71
- assertRespondTo RubyUnit::TestCase, method, 'RubyUnit::TestCase missing class method'
70
+ def descendentsTest
71
+ assertInclude RubyUnit::TestCase.descendents, self.class, 'Should be a descendent of RubyUnit::TestCase'
72
72
  end
73
73
 
74
74
  #
75
- # Test that descendents method includes this class
75
+ # Test that the correct class methods are defined
76
76
  #
77
- def descendentsTest
78
- assertInclude RubyUnit::TestCase.descendents, self.class, 'Should be a descendent of RubyUnit::TestCase'
77
+ def classMethodTest method
78
+ assertRespondTo RubyUnit::TestCase, method, 'RubyUnit::TestCase missing class method'
79
79
  end
80
80
 
81
81
  #
@@ -83,7 +83,7 @@ class TEST_TestCase < RubyUnit::TestCase
83
83
  #
84
84
  def instanceMethodTest method
85
85
  test_case = TestCaseFixture.new
86
- assertRespondTo test_case, method, 'Test Case object missing instance method'
86
+ assertRespondTo test_case, method, 'TestCase object missing instance method'
87
87
  end
88
88
 
89
89
  #
@@ -0,0 +1,5 @@
1
+ #
2
+ # Data provider for RubyUnit::TestCase class Test Case
3
+ #
4
+ module AssertionsData
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyunit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Clower
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-16 00:00:00.000000000 Z
11
+ date: 2014-10-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Unit testing and test-driven development are crucial parts of the software
14
14
  development life cycle. This tool is intended to make development and testing in
@@ -22,6 +22,7 @@ extra_rdoc_files:
22
22
  files:
23
23
  - LICENSE.md
24
24
  - README.md
25
+ - TestSuite.rb
25
26
  - example/RealNumber.rb
26
27
  - example/RealNumberData.rb
27
28
  - example/RealNumberTest.rb
@@ -41,7 +42,7 @@ files:
41
42
  - tests/TEST_Runner.rb
42
43
  - tests/TEST_SkippedTest.rb
43
44
  - tests/TEST_TestCase.rb
44
- - tests/TestSuite.rb
45
+ - tests/data/Assertions.rb
45
46
  - tests/data/GemInfo.rb
46
47
  - tests/data/TestCase.rb
47
48
  - tests/fixture/TestCase.rb