assertions-eb 1.7.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,71 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../test_helper", __FILE__)
3
+
4
+ require "foo"
5
+ require "seahawk"
6
+
7
+ class AssertSortedByTest < Test::Unit::TestCase
8
+ def test_assert_sorted_by_number_fails
9
+ assert_raise_message("key must be symbol or string", ArgumentError) do
10
+ assert_sorted_by 12, []
11
+ end
12
+ end
13
+
14
+ def test_assert_sorted_by_on_number_fails
15
+ assert_raise_message("enum must be enumerable", ArgumentError) do
16
+ assert_sorted_by :foo, 1
17
+ end
18
+ end
19
+
20
+ def test_assert_sorted_by_on_hash_that_doesnt_respond_to_sort_key_fails
21
+ assert_raise_message("enum's elements don't respond to the key", ArgumentError) do
22
+ assert_sorted_by :bar, [{:bar => 1}, {:cow => 2}]
23
+ end
24
+ end
25
+
26
+ def test_assert_sorted_by_on_array_of_objects_that_dont_respond_to_sort_key_fails
27
+ assert_raise_message("enum's elements don't respond to the key", ArgumentError) do
28
+ assert_sorted_by :bar, [Foo.new(2), Seahawk.new(3)]
29
+ end
30
+ end
31
+
32
+ def test_assert_sorted_by_on_array_of_objects_and_hash_that_dont_respond_to_sort_key_fails
33
+ assert_raise_message("enum's elements don't respond to the key", ArgumentError) do
34
+ assert_sorted_by :bar, [Foo.new(1), {:moo => 2}]
35
+ end
36
+ end
37
+
38
+ def test_assert_sorted_by_on_sorted_array_with_symbol_keys_succeeds
39
+ assert_sorted_by :bar, [{:bar => 1}, {:bar => 2}, {:bar => 3}]
40
+ end
41
+
42
+ def test_assert_sorted_by_on_sorted_array_with_string_keys_succeeds
43
+ assert_sorted_by "bar", [{"bar" => 1}, {"bar" => 2}, {"bar" => 3}]
44
+ end
45
+
46
+ def test_assert_sorted_by_on_unsorted_array_fails
47
+ assert_raises(Test::Unit::AssertionFailedError) do
48
+ assert_sorted_by :bar, [{:bar => 2}, {:bar => 1}, {:bar => 3}]
49
+ end
50
+ end
51
+
52
+ def test_assert_sorted_by_on_sorted_array_of_objects_succeeds
53
+ foos = [Foo.new(1), Foo.new(2), Foo.new(3)]
54
+ assert_sorted_by :bar, foos
55
+ end
56
+
57
+ def test_assert_sorted_by_on_unsorted_array_of_objects_fails
58
+ foos = [Foo.new(3), Foo.new(1), Foo.new(2)]
59
+ assert_raises(Test::Unit::AssertionFailedError) { assert_sorted_by :bar, foos }
60
+ end
61
+
62
+ def test_assert_sorted_by_on_sorted_object_mash_succeeds
63
+ assert_sorted_by :bar, [{:bar => 1}, Foo.new(2)]
64
+ end
65
+
66
+ def test_assert_sorted_by_on_unsorted_object_mash_fails
67
+ assert_raises(Test::Unit::AssertionFailedError) do
68
+ assert_sorted_by :bar, [Foo.new(2), {:bar => 1}]
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../test_helper", __FILE__)
3
+
4
+ class AssertSortedDescTest < Test::Unit::TestCase
5
+ def test_assert_sorted_desc_on_1_fails
6
+ assert_raise_message("enum must be enumerable", ArgumentError) do
7
+ assert_sorted_desc 1
8
+ end
9
+ end
10
+
11
+ def test_assert_sorted_desc_on_empty_array_succeeds
12
+ assert_sorted_desc []
13
+ end
14
+
15
+ def test_assert_sorted_desc_on_length_one_array_succeeds
16
+ assert_sorted_desc [1]
17
+ end
18
+
19
+ def test_assert_sorted_desc_on_desc_sorted_array_succeeds
20
+ assert_sorted_desc [8,4,2,1]
21
+ end
22
+
23
+ def test_assert_sorted_desc_on_unsorted_array
24
+ assert_raises(Test::Unit::AssertionFailedError) { assert_sorted_desc [4,2,1,8] }
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../test_helper", __FILE__)
3
+
4
+ class AssertSortedTest < Test::Unit::TestCase
5
+ def test_assert_sorted_on_1_fails
6
+ assert_raise_message("enum must be enumerable", ArgumentError) do
7
+ assert_sorted 1
8
+ end
9
+ end
10
+
11
+ def test_assert_sorted_on_empty_array_succeeds
12
+ assert_sorted []
13
+ end
14
+
15
+ def test_assert_sorted_on_length_one_array_succeeds
16
+ assert_sorted [1]
17
+ end
18
+
19
+ def test_assert_sorted_on_sorted_array_succeeds
20
+ assert_sorted [1,2,4,8]
21
+ end
22
+
23
+ def test_assert_sorted_on_unsorted_array
24
+ assert_raises(Test::Unit::AssertionFailedError) { assert_sorted [4,2,1,8] }
25
+ end
26
+ end
data/test/foo.rb ADDED
@@ -0,0 +1,7 @@
1
+ class Foo
2
+ attr_accessor :bar
3
+
4
+ def initialize(bar)
5
+ self.bar = bar
6
+ end
7
+ end
data/test/seahawk.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Seahawk
2
+ attr_accessor :caw
3
+ def initialize(caw)
4
+ self.caw = caw
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.push(File.expand_path "../../test", __FILE__)
2
+ require "test/unit"
3
+ require "assertions"
4
+
5
+ # 1.9 compatibility patch for test/unit
6
+ module Test
7
+ module Unit
8
+ if defined?(MiniTest) && !defined?(AssertionFailedError)
9
+ AssertionFailedError = MiniTest::Assertion
10
+ end
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assertions-eb
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.7.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - DesigningPatterns
9
+ - Expected Behavior
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-02-17 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: This project adds some additional assertions to Test::Unit::Assertions,
16
+ including assert_raise_message (allowing verification of error messages) and assert_greater_than.
17
+ email:
18
+ - technical.inquiries@designingpatterns.com
19
+ - joel@expectedbehavior.com
20
+ - chris@monoclesoftware.com
21
+ executables: []
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - .gitignore
26
+ - Gemfile
27
+ - History.txt
28
+ - LICENSE
29
+ - Manifest.txt
30
+ - README.rdoc
31
+ - README.txt
32
+ - Rakefile
33
+ - assertions.gemspec
34
+ - examples/example.rb
35
+ - lib/assertions.rb
36
+ - lib/assertions/version.rb
37
+ - test/assert_between_test.rb
38
+ - test/assert_fail_test.rb
39
+ - test/assert_greater_than_or_equal_to_test.rb
40
+ - test/assert_greater_than_test.rb
41
+ - test/assert_less_than_test.rb
42
+ - test/assert_less_than_test_or_equal_to_test.rb
43
+ - test/assert_negative_test.rb
44
+ - test/assert_not_test.rb
45
+ - test/assert_positive_test.rb
46
+ - test/assert_raise_message_test.rb
47
+ - test/assert_sorted_by_desc_test.rb
48
+ - test/assert_sorted_by_test.rb
49
+ - test/assert_sorted_desc_test.rb
50
+ - test/assert_sorted_test.rb
51
+ - test/foo.rb
52
+ - test/seahawk.rb
53
+ - test/test_helper.rb
54
+ homepage: http://www.expectedbehavior.com
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.10
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: More Assertions for Test::Unit::Assertions
78
+ test_files:
79
+ - test/assert_between_test.rb
80
+ - test/assert_fail_test.rb
81
+ - test/assert_greater_than_or_equal_to_test.rb
82
+ - test/assert_greater_than_test.rb
83
+ - test/assert_less_than_test.rb
84
+ - test/assert_less_than_test_or_equal_to_test.rb
85
+ - test/assert_negative_test.rb
86
+ - test/assert_not_test.rb
87
+ - test/assert_positive_test.rb
88
+ - test/assert_raise_message_test.rb
89
+ - test/assert_sorted_by_desc_test.rb
90
+ - test/assert_sorted_by_test.rb
91
+ - test/assert_sorted_desc_test.rb
92
+ - test/assert_sorted_test.rb
93
+ - test/foo.rb
94
+ - test/seahawk.rb
95
+ - test/test_helper.rb