rspec-activesupport 0.1.1
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 +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.md +21 -0
- data/lib/rspec/active_support/configuration.rb +17 -0
- data/lib/rspec/active_support/matchers/warn_deprecation.rb +63 -0
- data/lib/rspec/active_support/matchers.rb +10 -0
- data/lib/rspec/active_support/version.rb +22 -0
- data/lib/rspec/active_support.rb +9 -0
- data/lib/rspec-activesupport.rb +4 -0
- data/sig/rspec/activesupport.rbs +6 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d39ec7c661374347656ac150d909a794a90e61a98e17f75f1ceb4e77bf47c898
|
4
|
+
data.tar.gz: ecb972061c5f4a30089024331b55059ac7e75f7bfc3951c1c25b0f1c0202f11a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f87a817810f71a9ccd4dd815915aa71ea7156439cf56c6a5d3344a6fb4af404ca38e4e25fd9dbadd8b86225e1f8b36deff9986555d7b04debc66c7438e482613
|
7
|
+
data.tar.gz: d5c027aa10938d77f53c808158b4c6bbe55ba8b82e24a9ef899613b229fc9a3606b8b6e35588d926524304516984af6443a723ef8b10b8d59fa9095079e56e3e
|
data/CHANGELOG.md
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Ryan Chang
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/deprecation"
|
4
|
+
require "rspec/active_support/matchers"
|
5
|
+
|
6
|
+
module RSpec
|
7
|
+
module ActiveSupport
|
8
|
+
module Configuration
|
9
|
+
def self.initialize_config(config)
|
10
|
+
config.add_setting :deprecator, default: ::ActiveSupport::Deprecation.new
|
11
|
+
config.include RSpec::ActiveSupport::Matchers
|
12
|
+
end
|
13
|
+
|
14
|
+
initialize_config RSpec.configuration
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/testing/deprecation"
|
4
|
+
require "rspec/matchers/composable"
|
5
|
+
|
6
|
+
module RSpec
|
7
|
+
module ActiveSupport
|
8
|
+
module Matchers
|
9
|
+
class DeprecationMatcher
|
10
|
+
include ::RSpec::Matchers::Composable
|
11
|
+
include ::ActiveSupport::Testing::Deprecation
|
12
|
+
|
13
|
+
attr_reader :expected, :deprecator, :deprecations
|
14
|
+
|
15
|
+
def initialize(expected, deprecator)
|
16
|
+
raise ArgumentError, "deprecator must be an instance, got: #{deprecator.inspect}" if deprecator in Class
|
17
|
+
|
18
|
+
@expected = expected
|
19
|
+
@deprecator = deprecator || RSpec.configuration.deprecator
|
20
|
+
end
|
21
|
+
|
22
|
+
def matches?(actual)
|
23
|
+
raise ArgumentError, "warn_deprecation only work with block arguments" unless actual in Proc
|
24
|
+
|
25
|
+
_, @deprecations = collect_deprecations(deprecator, &actual)
|
26
|
+
return false if deprecations.empty?
|
27
|
+
return false if expected && deprecations.none? { |msg| values_match?(expected, msg) }
|
28
|
+
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def failure_message
|
33
|
+
if deprecations.nil? || deprecations.empty?
|
34
|
+
"expected a deprecation warning within the block but received none"
|
35
|
+
elsif expected
|
36
|
+
"no deprecation warning matched #{expected.inspect}: #{deprecations.join(", ")}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def failure_message_when_negated
|
41
|
+
return if deprecations.nil? || deprecations.empty?
|
42
|
+
|
43
|
+
message = deprecations.map { |msg| " #{msg}" }
|
44
|
+
message.unshift("expected no deprecation warning within the block but received #{deprecations.size}:")
|
45
|
+
message.join("\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
def supports_value_expectations?
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
# @api private
|
53
|
+
def supports_block_expectations?
|
54
|
+
true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def warn_deprecation(message = nil, deprecator = nil)
|
59
|
+
DeprecationMatcher.new(message, deprecator)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module ActiveSupport
|
5
|
+
def self.version
|
6
|
+
VERSION::STRING
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.gem_version
|
10
|
+
Gem::Version.new(VERSION::STRING)
|
11
|
+
end
|
12
|
+
|
13
|
+
module VERSION
|
14
|
+
MAJOR = 0
|
15
|
+
MINOR = 1
|
16
|
+
BUILD = 1
|
17
|
+
PRE = nil
|
18
|
+
|
19
|
+
STRING = [MAJOR, MINOR, BUILD, PRE].compact.join(".")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-activesupport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Chang
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-expectations
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- ryancyq@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CHANGELOG.md
|
63
|
+
- LICENSE.md
|
64
|
+
- lib/rspec-activesupport.rb
|
65
|
+
- lib/rspec/active_support.rb
|
66
|
+
- lib/rspec/active_support/configuration.rb
|
67
|
+
- lib/rspec/active_support/matchers.rb
|
68
|
+
- lib/rspec/active_support/matchers/warn_deprecation.rb
|
69
|
+
- lib/rspec/active_support/version.rb
|
70
|
+
- sig/rspec/activesupport.rbs
|
71
|
+
homepage: https://github.com/ryancyq/rspec-activesupport
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata:
|
75
|
+
rubygems_mfa_required: 'true'
|
76
|
+
allowed_push_host: https://rubygems.org
|
77
|
+
homepage_uri: https://github.com/ryancyq/rspec-activesupport
|
78
|
+
source_code_uri: https://github.com/ryancyq/rspec-activesupport
|
79
|
+
changelog_uri: https://github.com/ryancyq/rspec-activesupport/blob/main/CHANGELOG.md
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 3.1.0
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubygems_version: 3.5.11
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: RSpec matcher for active support test helper
|
99
|
+
test_files: []
|