test-unit-activesupport 1.0.6 → 1.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.
- checksums.yaml +5 -5
- data/README.md +2 -4
- data/doc/text/news.md +49 -0
- data/lib/test/unit/active_support/version.rb +2 -2
- data/lib/test/unit/active_support.rb +42 -3
- data/test/run-test.rb +5 -4
- data/test/test_assertions.rb +27 -1
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 72fb6f3db588c7c5fa4538ea41afb3946b625f619648b7dd5e3e7cb193cd0dc1
|
4
|
+
data.tar.gz: '0887c23e8337a1bc12aa7d2cef2055d451b414b0eea049bc5023b9ce54aa7d26'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b8506271e926f244864c9207ad4080b63bbfc80de7460032b20df8a87f7e319b4a653f50c4969210596c5fbb6a496a819a259fb09adc0347d7d89cfcf459fa7
|
7
|
+
data.tar.gz: 4c851c2b43def691b781fb5d48ef3115edf7299dd1204f6496a04b5b0e1eba1ddb19e4251c477a6df18e3821c9152ff177f6e01f0a01ff0b6de3b141d84f8acb
|
data/README.md
CHANGED
@@ -12,16 +12,14 @@ test-unit-activesupport is an ActiveSupport adapter for test-unit 3. You can use
|
|
12
12
|
|
13
13
|
Require `test/unit/active_support`:
|
14
14
|
|
15
|
-
```
|
15
|
+
```ruby
|
16
16
|
require "test/unit/active_support"
|
17
17
|
require "active_support"
|
18
18
|
```
|
19
19
|
|
20
20
|
Now you can use full test-unit 3.x features with ActiveSupport.
|
21
21
|
|
22
|
-
```
|
23
|
-
require "test/unit/active_support"
|
24
|
-
require "active_support"
|
22
|
+
```ruby
|
25
23
|
|
26
24
|
class YourTest < ActiveSupport::TestCase
|
27
25
|
# ...
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,54 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 1.1.0 - 2021-02-20 {#1-1-0}
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Added support for exception in assertions defined by Active
|
8
|
+
Support 6 or later.
|
9
|
+
[GitHub#14][Reported by Yuki Morohoshi]
|
10
|
+
|
11
|
+
### Thanks
|
12
|
+
|
13
|
+
* Yuki Morohoshi
|
14
|
+
|
15
|
+
## 1.0.9 - 2017-07-26 {#1-0-9}
|
16
|
+
|
17
|
+
### Improvements
|
18
|
+
|
19
|
+
* Supported `#before_setup` and `#after_teardown`.
|
20
|
+
[GitHub:test-unit-rails#15][Reported by naofumi-fujii]
|
21
|
+
|
22
|
+
### Thanks
|
23
|
+
|
24
|
+
* naofumi-fujii
|
25
|
+
|
26
|
+
## 1.0.8 - 2016-12-20 {#1-0-8}
|
27
|
+
|
28
|
+
### Fixes
|
29
|
+
|
30
|
+
* Supported Active Support 4 again.
|
31
|
+
[GitHub#12][Patch by Akira Matsuda]
|
32
|
+
|
33
|
+
### Thanks
|
34
|
+
|
35
|
+
* Akira Matsuda
|
36
|
+
|
37
|
+
## 1.0.7 - 2016-12-15 {#1-0-7}
|
38
|
+
|
39
|
+
### Improvements
|
40
|
+
|
41
|
+
* Supported `ActiveSupport::Testing::FileFixtures`.
|
42
|
+
|
43
|
+
### Fixes
|
44
|
+
|
45
|
+
* Removed duplicated description in README.
|
46
|
+
[GitHub#11][Patch by James Pinto]
|
47
|
+
|
48
|
+
### Thanks
|
49
|
+
|
50
|
+
* James Pinto
|
51
|
+
|
3
52
|
## 1.0.6 - 2016-05-20 {#1-0-6}
|
4
53
|
|
5
54
|
Rails 5.0 RC1 support release.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -17,7 +17,7 @@
|
|
17
17
|
module Test
|
18
18
|
module Unit
|
19
19
|
module ActiveSupport
|
20
|
-
VERSION = "1.0
|
20
|
+
VERSION = "1.1.0"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2012-2022 Sutou Kouhei <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -17,7 +15,19 @@
|
|
17
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
16
|
|
19
17
|
require "test-unit"
|
18
|
+
require "active_support"
|
19
|
+
require 'active_support/core_ext/class/attribute'
|
20
20
|
require "active_support/testing/assertions"
|
21
|
+
begin
|
22
|
+
require 'active_support/testing/file_fixtures'
|
23
|
+
rescue LoadError
|
24
|
+
# Active Support < 5 doesn't have file_fixtures
|
25
|
+
end
|
26
|
+
begin
|
27
|
+
require "active_support/testing/tagged_logging"
|
28
|
+
rescue LoadError
|
29
|
+
# Active Support < 7 doesn't have tagged_logging
|
30
|
+
end
|
21
31
|
|
22
32
|
as_test_case_name = "active_support/test_case.rb"
|
23
33
|
unless $LOADED_FEATURES.any? {|feature| feature.end_with?(as_test_case_name)}
|
@@ -38,12 +48,24 @@ module ActiveSupport
|
|
38
48
|
end
|
39
49
|
|
40
50
|
class TestCase < ::Test::Unit::TestCase
|
51
|
+
alias_method :assert_nothing_raised_original, :assert_nothing_raised
|
41
52
|
include ActiveSupport::Testing::Assertions
|
53
|
+
alias_method :assert_nothing_raised, :assert_nothing_raised_original
|
54
|
+
include ActiveSupport::Testing::FileFixtures if defined?(ActiveSupport::Testing::FileFixtures)
|
55
|
+
include ActiveSupport::Testing::TaggedLogging if defined?(ActiveSupport::Testing::TaggedLogging)
|
42
56
|
|
43
57
|
# shoulda needs ActiveSupport::TestCase::Assertion, which is not
|
44
58
|
# set in test-unit 3
|
45
59
|
Assertion = Test::Unit::AssertionFailedError
|
46
60
|
|
61
|
+
setup :before => :prepend
|
62
|
+
def before_setup
|
63
|
+
end
|
64
|
+
|
65
|
+
teardown :after => :append
|
66
|
+
def after_teardown
|
67
|
+
end
|
68
|
+
|
47
69
|
# rails 4.1 (action dispatch assertions) needs the 'message'
|
48
70
|
# method which is not defined in test-unit 3
|
49
71
|
def message(msg=nil, ending=nil, &default)
|
@@ -64,5 +86,22 @@ module ActiveSupport
|
|
64
86
|
def mu_pp(object)
|
65
87
|
AssertionMessage.convert(object)
|
66
88
|
end
|
89
|
+
|
90
|
+
if private_method_defined?(:_assert_nothing_raised_or_warn)
|
91
|
+
def _assert_nothing_raised_or_warn(assertion, &block)
|
92
|
+
assert_nothing_raised(&block)
|
93
|
+
rescue Test::Unit::AssertionFailedError => e
|
94
|
+
if tagged_logger && tagged_logger.warn?
|
95
|
+
warning = <<~MSG
|
96
|
+
#{self.class} - #{name}: #{e.error.class} raised.
|
97
|
+
If you expected this exception, use `assert_raise` as near to the code that raises as possible.
|
98
|
+
Other block based assertions (e.g. `#{assertion}`) can be used, as long as `assert_raise` is inside their block.
|
99
|
+
MSG
|
100
|
+
tagged_logger.warn warning
|
101
|
+
end
|
102
|
+
|
103
|
+
raise
|
104
|
+
end
|
105
|
+
end
|
67
106
|
end
|
68
107
|
end
|
data/test/run-test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
3
|
+
# Copyright (C) 2015-2022 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -16,10 +16,11 @@
|
|
16
16
|
# License along with this library; if not, write to the Free Software
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
|
-
base_dir = File.expand_path("..")
|
20
|
-
lib_dir = File.join(base_dir)
|
19
|
+
base_dir = File.expand_path(File.join(__dir__, ".."))
|
20
|
+
lib_dir = File.join(base_dir, "lib")
|
21
21
|
$LOAD_PATH.unshift(lib_dir)
|
22
22
|
|
23
23
|
require "test/unit/active_support"
|
24
24
|
|
25
|
-
|
25
|
+
test_dir = File.join(base_dir, "test")
|
26
|
+
exit(Test::Unit::AutoRunner.run(true, test_dir))
|
data/test/test_assertions.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2015-2022 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -26,12 +26,38 @@ class TestAssertions < ActiveSupport::TestCase
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
test "assert_difference: raise" do
|
30
|
+
x = 1
|
31
|
+
if ActiveSupport.version < Gem::Version.new("6")
|
32
|
+
assert_raise(RuntimeError.new("Unexpected")) do
|
33
|
+
assert_difference("x", 1) do
|
34
|
+
raise "Unexpected"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
assert_raise(Test::Unit::AssertionFailedError) do
|
39
|
+
assert_difference("x", 1) do
|
40
|
+
raise "Unexpected"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
29
46
|
test "assert_no_difference" do
|
30
47
|
x = 1
|
31
48
|
assert_no_difference("x") do
|
32
49
|
end
|
33
50
|
end
|
34
51
|
|
52
|
+
|
53
|
+
test "assert_nothing_raised" do
|
54
|
+
assert_raise(Test::Unit::AssertionFailedError) do
|
55
|
+
assert_nothing_raised do
|
56
|
+
raise "Unexpected"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
35
61
|
test "message method" do
|
36
62
|
delayed_message = message("test", "bernd") do
|
37
63
|
"hans"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit-activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -143,13 +143,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.5.1
|
146
|
+
rubygems_version: 3.4.0.dev
|
148
147
|
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: test-unit-activesupport is an ActiveSupport adapter for test-unit 3. You
|
151
150
|
can use full test-unit 3 features with `ActiveSupport::TestCase`.
|
152
151
|
test_files:
|
153
|
-
- test/test_assertions.rb
|
154
152
|
- test/run-test.rb
|
155
|
-
|
153
|
+
- test/test_assertions.rb
|