File tree Expand file tree Collapse file tree 2 files changed +71
-13
lines changed Expand file tree Collapse file tree 2 files changed +71
-13
lines changed Original file line number Diff line number Diff line change @@ -14,20 +14,12 @@ def initialize(raw_value)
14
14
@raw_value = raw_value
15
15
end
16
16
17
- # Delegate all missing methods to the raw value.
17
+ # Returns a string containing a human-readable representation of
18
+ # the object, including the inspection of the underlying value.
18
19
#
19
- # @param [ String, Symbol ] method_name The name of the method.
20
- # @param [ Array ] args The arguments passed to the method.
21
- ruby2_keywords def method_missing ( method_name , *args , &block )
22
- raw_value . send ( method_name , *args , &block )
23
- end
24
-
25
- # Delegate all missing methods to the raw value.
26
- #
27
- # @param [ String, Symbol ] method_name The name of the method.
28
- # @param [ true | false ] include_private Whether to check private methods.
29
- def respond_to_missing? ( method_name , include_private = false )
30
- raw_value . respond_to? ( method_name , include_private )
20
+ # @return [ String ] The object inspection.
21
+ def inspect
22
+ "RawValue: #{ raw_value . inspect } "
31
23
end
32
24
end
33
25
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Mongoid ::RawValue do
6
+
7
+ describe "::()" do
8
+ subject { Mongoid ::RawValue ( raw_value ) . raw_value }
9
+
10
+ context 'when raw_value is a String' do
11
+ let ( :raw_value ) { 'Hello World!' }
12
+
13
+ it 'returns the value' do
14
+ is_expected . to eq 'Hello World!'
15
+ end
16
+ end
17
+
18
+ context 'when raw_value is an Integer' do
19
+ let ( :raw_value ) { 42 }
20
+
21
+ it 'returns the value' do
22
+ is_expected . to eq 42
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "#raw_value" do
28
+ subject { described_class . new ( raw_value ) . raw_value }
29
+
30
+ context 'when raw_value is a String' do
31
+ let ( :raw_value ) { 'Hello World!' }
32
+
33
+ it 'returns the value' do
34
+ is_expected . to eq 'Hello World!'
35
+ end
36
+ end
37
+
38
+ context 'when raw_value is an Integer' do
39
+ let ( :raw_value ) { 42 }
40
+
41
+ it 'returns the value' do
42
+ is_expected . to eq 42
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "#inspect" do
48
+ subject { described_class . new ( raw_value ) . inspect }
49
+
50
+ context 'when raw_value is a String' do
51
+ let ( :raw_value ) { 'Hello World!' }
52
+
53
+ it 'returns the inspection' do
54
+ is_expected . to eq 'RawValue: "Hello World!"'
55
+ end
56
+ end
57
+
58
+ context 'when raw_value is an Integer' do
59
+ let ( :raw_value ) { 42 }
60
+
61
+ it 'returns the inspection' do
62
+ is_expected . to eq 'RawValue: 42'
63
+ end
64
+ end
65
+ end
66
+ end
You can’t perform that action at this time.
0 commit comments