minicrest 1.0.18 → 1.0.20

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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Minicrest
4
- VERSION = '1.0.18'
4
+ VERSION = '1.0.20'
5
5
  end
data/lib/minicrest.rb CHANGED
@@ -77,7 +77,6 @@ end
77
77
 
78
78
  require_relative 'minicrest/matcher'
79
79
  require_relative 'minicrest/is'
80
- require_relative 'minicrest/descends_from'
81
80
  require_relative 'minicrest/value_matchers'
82
81
  require_relative 'minicrest/responds_to'
83
82
  require_relative 'minicrest/equals'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minicrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.18
4
+ version: 1.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillermo Gutierrez Almazor
@@ -41,6 +41,7 @@ files:
41
41
  - LICENSE
42
42
  - README.md
43
43
  - Rakefile
44
+ - USAGE.md
44
45
  - lib/minicrest.rb
45
46
  - lib/minicrest/all_items.rb
46
47
  - lib/minicrest/anything.rb
@@ -53,7 +54,6 @@ files:
53
54
  - lib/minicrest/comparison_matcher.rb
54
55
  - lib/minicrest/contains.rb
55
56
  - lib/minicrest/contains_exactly.rb
56
- - lib/minicrest/descends_from.rb
57
57
  - lib/minicrest/empty.rb
58
58
  - lib/minicrest/ends_with.rb
59
59
  - lib/minicrest/equals.rb
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Minicrest
4
- # Matcher that checks if a value is an instance of a given type.
5
- #
6
- # Uses Ruby's `is_a?` method which checks class hierarchy and module inclusion.
7
- #
8
- # @example Basic usage
9
- # descends_from(String).matches?("hello") # => true
10
- # descends_from(Integer).matches?(42) # => true
11
- # descends_from(Enumerable).matches?([]) # => true (module inclusion)
12
- #
13
- # @example With inheritance
14
- # descends_from(Exception).matches?(StandardError.new) # => true (subclass)
15
- # @see InstanceOf
16
- class DescendsFrom < Matcher
17
- # Creates a new type matcher.
18
- #
19
- # @param expected_type [Class, Module] the expected type
20
- def initialize(expected_type)
21
- super()
22
- @expected_type = expected_type
23
- end
24
-
25
- # Checks if actual is an instance of the expected type.
26
- #
27
- # @param actual [Object] the value to check
28
- # @return [Boolean] true if actual.is_a?(expected_type)
29
- def matches?(actual)
30
- actual.is_a?(@expected_type)
31
- end
32
-
33
- # Returns a description of what this matcher expects.
34
- #
35
- # @return [String] description of expected type
36
- def description
37
- "an instance of #{@expected_type}"
38
- end
39
-
40
- # Returns the failure message when the match fails.
41
- #
42
- # @param actual [Object] the value that was checked
43
- # @return [String] message showing expected vs actual type
44
- def failure_message(actual)
45
- <<~MSG.chomp
46
- expected #{actual.inspect}
47
- to be an instance of #{@expected_type}
48
- but was #{actual.class}
49
- MSG
50
- end
51
-
52
- # Returns the failure message when a negated match fails.
53
- #
54
- # @param actual [Object] the value that was checked
55
- # @return [String] message indicating unexpected type match
56
- def negated_failure_message(actual)
57
- <<~MSG.chomp
58
- expected #{actual.inspect}
59
- not to be an instance of #{@expected_type}
60
- but it is
61
- MSG
62
- end
63
- end
64
- end