test-unit-activesupport 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aed9d1a340f08ed230f9ee71a37ef837fad81b46
4
- data.tar.gz: 3219a38b5460b420224b92b51bc068297709f798
2
+ SHA256:
3
+ metadata.gz: 72fb6f3db588c7c5fa4538ea41afb3946b625f619648b7dd5e3e7cb193cd0dc1
4
+ data.tar.gz: '0887c23e8337a1bc12aa7d2cef2055d451b414b0eea049bc5023b9ce54aa7d26'
5
5
  SHA512:
6
- metadata.gz: 444784182d3328b2326f1272e293f81fe4e57a678b69e949f1344e7c2b5eea146ec9f869388c8d0e3630a09837c9ba4f4ac07b1426bf955e2234cdc78f8fc87a
7
- data.tar.gz: ee73e619f1e793c6a6b9285246ebfd38c702d1a681963851998a8a7e1ffb2434209d343683939f6e3948203a683004280c78e2d4731004e0012ac3b0d253390d
6
+ metadata.gz: 2b8506271e926f244864c9207ad4080b63bbfc80de7460032b20df8a87f7e319b4a653f50c4969210596c5fbb6a496a819a259fb09adc0347d7d89cfcf459fa7
7
+ data.tar.gz: 4c851c2b43def691b781fb5d48ef3115edf7299dd1204f6496a04b5b0e1eba1ddb19e4251c477a6df18e3821c9152ff177f6e01f0a01ff0b6de3b141d84f8acb
data/doc/text/news.md CHANGED
@@ -1,5 +1,17 @@
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
+
3
15
  ## 1.0.9 - 2017-07-26 {#1-0-9}
4
16
 
5
17
  ### Improvements
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2016 Kouhei Sutou <kou@clear-code.com>
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.9"
20
+ VERSION = "1.1.0"
21
21
  end
22
22
  end
23
23
  end
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
@@ -25,6 +23,11 @@ begin
25
23
  rescue LoadError
26
24
  # Active Support < 5 doesn't have file_fixtures
27
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
28
31
 
29
32
  as_test_case_name = "active_support/test_case.rb"
30
33
  unless $LOADED_FEATURES.any? {|feature| feature.end_with?(as_test_case_name)}
@@ -45,8 +48,11 @@ module ActiveSupport
45
48
  end
46
49
 
47
50
  class TestCase < ::Test::Unit::TestCase
51
+ alias_method :assert_nothing_raised_original, :assert_nothing_raised
48
52
  include ActiveSupport::Testing::Assertions
53
+ alias_method :assert_nothing_raised, :assert_nothing_raised_original
49
54
  include ActiveSupport::Testing::FileFixtures if defined?(ActiveSupport::Testing::FileFixtures)
55
+ include ActiveSupport::Testing::TaggedLogging if defined?(ActiveSupport::Testing::TaggedLogging)
50
56
 
51
57
  # shoulda needs ActiveSupport::TestCase::Assertion, which is not
52
58
  # set in test-unit 3
@@ -80,5 +86,22 @@ module ActiveSupport
80
86
  def mu_pp(object)
81
87
  AssertionMessage.convert(object)
82
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
83
106
  end
84
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
- exit(Test::Unit::AutoRunner.run(true))
25
+ test_dir = File.join(base_dir, "test")
26
+ exit(Test::Unit::AutoRunner.run(true, test_dir))
@@ -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.9
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: 2017-07-26 00:00:00.000000000 Z
11
+ date: 2022-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -143,12 +143,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubyforge_project:
147
- rubygems_version: 2.5.2
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
153
+ - test/test_assertions.rb