GUnit 0.1.2

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.
@@ -0,0 +1,48 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ class GUnit::TestSuiteTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @test_suite = GUnit::TestSuite.new
7
+ end
8
+
9
+ def test_it_is_a_test_suite
10
+ assert @test_suite.is_a?(GUnit::TestSuite)
11
+ end
12
+
13
+ def test_tests_getter_setter
14
+ tests = [GUnit::TestSuite.new, GUnit::TestCase.new]
15
+ assert @test_suite.tests != tests
16
+ @test_suite.tests = tests
17
+ assert @test_suite.tests == tests
18
+ end
19
+
20
+ def test_tests_set_nil_has_empty_tests
21
+ @test_suite.tests = nil
22
+ assert @test_suite.tests.empty?
23
+ assert @test_suite.tests.is_a?(Enumerable)
24
+ end
25
+
26
+ def test_run_runs_all_tests_saves_responses
27
+ test_response1 = GUnit::PassResponse.new
28
+ test_response2 = GUnit::FailResponse.new
29
+ test_response3 = GUnit::ExceptionResponse.new
30
+
31
+ test_suite = GUnit::TestSuite.new
32
+ test_suite.expects(:run).multiple_yields(test_response1, test_response2)
33
+
34
+ test_case = GUnit::TestCase.new
35
+ test_case.expects(:run).returns(test_response3)
36
+
37
+ @test_suite.tests = [test_suite, test_case]
38
+
39
+ responses = []
40
+ @test_suite.run{|r| responses << r }
41
+
42
+ assert responses.include?(test_response1)
43
+ assert responses.include?(test_response2)
44
+ assert responses.include?(test_response3)
45
+ assert responses.length == 3
46
+ end
47
+
48
+ end
@@ -0,0 +1,107 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ # class MyClassTest < GUnit::TestCase
4
+ # verify_is_a @my_class, MyClass
5
+ #
6
+ # context "An instance of MyClass"
7
+ #
8
+ # verify "true is true" do
9
+ # verify true != nil
10
+ # verify true == true
11
+ # verify true === true
12
+ # end
13
+ # end
14
+ # end
15
+
16
+ class GUnit::VerificationTest < Test::Unit::TestCase
17
+
18
+ def setup
19
+ @verification1 = GUnit::Verification.new
20
+ end
21
+
22
+ def test_it_is_a_verification
23
+ assert @verification1.is_a?(GUnit::Verification)
24
+ end
25
+
26
+ def test_has_default_message
27
+ assert_not_nil @verification1.message
28
+ end
29
+
30
+ def test_message_setter
31
+ message = "Whoops"
32
+ @verification1.message = message
33
+ assert_equal message, @verification1.message
34
+ end
35
+
36
+ # Verification.new('one is less than two')
37
+ def test_initialize_with_one_arg
38
+ message = 'one is less than two'
39
+ @verification2 = GUnit::Verification.new(message)
40
+ assert @verification2.message === message
41
+ end
42
+
43
+ # Verification.new('one is less than two'){ assert 1<2 }
44
+ def test_initialize_with_one_arg_and_block
45
+ message = 'one is less than two'
46
+ task = 'my task'
47
+ @verification2 = GUnit::Verification.new(message) { task }
48
+ assert message === @verification2.message
49
+ assert task === @verification2.task.call
50
+ end
51
+
52
+ def test_run_with_task_called_returns_true
53
+ @verification1.task = lambda { true }
54
+ response = @verification1.run
55
+ assert response.is_a?(GUnit::TestResponse)
56
+ assert response.is_a?(GUnit::PassResponse)
57
+ end
58
+
59
+ def test_run_with_task_called_returns_false
60
+ @verification1.task = lambda { false }
61
+ response = @verification1.run
62
+ assert response.is_a?(GUnit::TestResponse)
63
+ assert response.is_a?(GUnit::PassResponse)
64
+ end
65
+
66
+ def test_run_with_task_is_false
67
+ @verification1.task = false
68
+ response = @verification1.run
69
+ assert response.is_a?(GUnit::TestResponse)
70
+ assert response.is_a?(GUnit::ToDoResponse)
71
+ end
72
+
73
+ def test_run_with_task_is_nil
74
+ @verification1.task = nil
75
+ response = @verification1.run
76
+ assert response.is_a?(GUnit::TestResponse)
77
+ assert response.is_a?(GUnit::ToDoResponse)
78
+ end
79
+
80
+ def test_run_with_binding
81
+ obj = Object.new
82
+ obj.instance_variable_set("@foo", "bar")
83
+ @verification1.task = Proc.new { instance_variable_set("@foo", "zip") }
84
+ @verification1.run
85
+ assert_equal "bar", obj.instance_variable_get("@foo")
86
+ @verification1.run(obj)
87
+ assert_equal "zip", obj.instance_variable_get("@foo")
88
+ end
89
+
90
+ def test_run_with_assertion_failure_exception
91
+ message = "boooooooom"
92
+ assertion_failure = GUnit::AssertionFailure.new(message)
93
+ @verification1.task = lambda { raise assertion_failure }
94
+ response = @verification1.run
95
+ assert response.is_a?(GUnit::TestResponse)
96
+ assert response.is_a?(GUnit::FailResponse)
97
+ assert_equal message, response.message
98
+ end
99
+
100
+ def test_run_with_random_exception
101
+ @verification1.task = lambda { raise 'Boom' }
102
+ response = @verification1.run
103
+ assert response.is_a?(GUnit::TestResponse)
104
+ assert response.is_a?(GUnit::ExceptionResponse)
105
+ end
106
+
107
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: GUnit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Greg Sterndale
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-22 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: GUnit is a fresh new XUnit Test implementation, poppin' a cap in the ass of TestUnit. Just playin'. TestUnit is our boy.
17
+ email: gsterndale@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - gunit.gemspec
33
+ - lib/gunit.rb
34
+ - lib/gunit/assertions.rb
35
+ - lib/gunit/context.rb
36
+ - lib/gunit/exception_response.rb
37
+ - lib/gunit/exercise.rb
38
+ - lib/gunit/fail_response.rb
39
+ - lib/gunit/pass_response.rb
40
+ - lib/gunit/proc_extensions.rb
41
+ - lib/gunit/setup.rb
42
+ - lib/gunit/teardown.rb
43
+ - lib/gunit/test_case.rb
44
+ - lib/gunit/test_response.rb
45
+ - lib/gunit/test_runner.rb
46
+ - lib/gunit/test_suite.rb
47
+ - lib/gunit/to_do_response.rb
48
+ - lib/gunit/verification.rb
49
+ - test/integration/foo_test.rb
50
+ - test/test_helper.rb
51
+ - test/unit/assertions_test.rb
52
+ - test/unit/context_test.rb
53
+ - test/unit/fail_response_test.rb
54
+ - test/unit/proc_extensions_test.rb
55
+ - test/unit/setup_test.rb
56
+ - test/unit/teardown_test.rb
57
+ - test/unit/test_case_test.rb
58
+ - test/unit/test_runner_test.rb
59
+ - test/unit/test_suite_test.rb
60
+ - test/unit/verification_test.rb
61
+ has_rdoc: true
62
+ homepage: http://github.com/gsterndale/gunit
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --charset=UTF-8
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.3.5
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: XUnit Test. Gangsta style.
89
+ test_files:
90
+ - test/integration/foo_test.rb
91
+ - test/test_helper.rb
92
+ - test/unit/assertions_test.rb
93
+ - test/unit/context_test.rb
94
+ - test/unit/fail_response_test.rb
95
+ - test/unit/proc_extensions_test.rb
96
+ - test/unit/setup_test.rb
97
+ - test/unit/teardown_test.rb
98
+ - test/unit/test_case_test.rb
99
+ - test/unit/test_runner_test.rb
100
+ - test/unit/test_suite_test.rb
101
+ - test/unit/verification_test.rb