strip_attributes 1.10.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/strip_attributes.rb +2 -0
- data/lib/strip_attributes/matchers.rb +1 -1
- data/lib/strip_attributes/version.rb +1 -1
- data/test/strip_attributes_test.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49befdc57853f5989b4fc51155992959980603b2f6faced6def64dcd79433c6b
|
4
|
+
data.tar.gz: 573f57793b9863e54fdde65b4dbf88e0d145098466e365ba91f595036ef16359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2adee723efb508757540eb6a6fcc87a4fd24408e97174614e36bf29e80b06c0c209e0deb78e9416add3af0bbcb3e7719611d9e5ceefeef4f9cd777c5dde75a7e
|
7
|
+
data.tar.gz: 8cf717ef066842affe6d4f160fca46b2bcec3ea17afbaa03119b7312b2556d859e36b992a904570faa3f12dcbeea02bf5a05fbc3a464d87a17a1335c59ab54e0
|
data/lib/strip_attributes.rb
CHANGED
@@ -52,12 +52,14 @@ module StripAttributes
|
|
52
52
|
|
53
53
|
def self.strip_string(value, options = {})
|
54
54
|
return value unless value.is_a?(String)
|
55
|
+
# TODO: FUTURE CHANGE: return value if value.frozen?
|
55
56
|
|
56
57
|
allow_empty = options[:allow_empty]
|
57
58
|
collapse_spaces = options[:collapse_spaces]
|
58
59
|
replace_newlines = options[:replace_newlines]
|
59
60
|
regex = options[:regex]
|
60
61
|
|
62
|
+
value = value.dup
|
61
63
|
value.gsub!(regex, "") if regex
|
62
64
|
|
63
65
|
if MULTIBYTE_SUPPORTED && Encoding.compatible?(value, MULTIBYTE_SPACE)
|
@@ -54,7 +54,7 @@ module StripAttributes
|
|
54
54
|
alias_method :negative_failure_message, :failure_message_when_negated # RSpec 1.1
|
55
55
|
|
56
56
|
def description
|
57
|
-
"#{expectation(false)} whitespace from ##{
|
57
|
+
"#{expectation(false)} whitespace from #{@attributes.map {|el| "##{el}" }.to_sentence}"
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
@@ -13,6 +13,7 @@ module MockAttributes
|
|
13
13
|
base.attribute :qux
|
14
14
|
base.attribute :strip_me
|
15
15
|
base.attribute :skip_me
|
16
|
+
base.attribute :frozen
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -203,6 +204,12 @@ class StripAttributesTest < Minitest::Test
|
|
203
204
|
assert_equal "", record.bang
|
204
205
|
end
|
205
206
|
|
207
|
+
def test_should_strip_frozen_values
|
208
|
+
record = StripAllMockRecord.new(frozen: " ice ".freeze)
|
209
|
+
record.valid?
|
210
|
+
assert_equal "ice", record.frozen
|
211
|
+
end
|
212
|
+
|
206
213
|
def test_should_collapse_duplicate_spaces
|
207
214
|
record = CollapseDuplicateSpaces.new(@init_params)
|
208
215
|
record.valid?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strip_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan McGeary
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|