simple_approvals-rspec 1.1.1 → 3.1.2

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: 8c20a53cf7f893c8d8f0f9a58e2a64e6a5a682bb
4
- data.tar.gz: 0ed1fd3bb0196f4eda2706f46bcb15872b1c0e33
2
+ SHA256:
3
+ metadata.gz: f71df43a87b07fe15b71e6cc0c24c3482c2aff226ff36714be8a988d919edfd2
4
+ data.tar.gz: 3cfe824a91b39e426f1e101616a558c787f4104e24e8117b1707112e5f1a923c
5
5
  SHA512:
6
- metadata.gz: dd650c025baabbf738ba6387850104387666db9488d8e0a57c784daebfcd1436a9e50647698cbacf4498bfa9d346e8e78dd9584d50344c7e4e28d39dfc26d007
7
- data.tar.gz: 49c001062ba5562c699b57e021b25516166b25004b2a09c7752568df45421880bbb5f019d8b7dd6bc5d324fa4d4258d227a224e3630161b48b9a63140e03d66c
6
+ metadata.gz: 25605c30b71b93bab1ededdc8ade9f8fbfefaa64c513eee4d0972792687fb399fe68cbb3287f76602bbe6b8146ac84af08be0fc11f2cd02828d87ac18a069359
7
+ data.tar.gz: 817c7d0811dfeea3e111ed9d99dd45149bb41ba72305666dff71c26d05d31c3f0a7e52f8d3eaa5cede99154b670b470ea44d12670bc36daca903e1678b24689d
@@ -5,33 +5,33 @@ class Approvals
5
5
  scrubbed_content = apply_optional_scrubber(rendered_content, options)
6
6
  pre_approve_if_asked(approved_path, scrubbed_content, options)
7
7
 
8
- expected_content = load_expected_content(approved_path, **options)
8
+ expected_content = load_expected_content(approved_path, options)
9
9
  received_path = received_path_for approved_path
10
10
 
11
11
  if scrubbed_content.strip.empty?
12
- raise_verify_error_with_diff(approved_path, received_path, scrubbed_content, **options) unless options[:allow_empty]
12
+ raise_verify_error_with_diff(approved_path, received_path, scrubbed_content, options) unless options[:allow_empty]
13
13
  elsif scrubbed_content.strip == expected_content.strip
14
- handle_match(received_path, scrubbed_content, **options)
14
+ handle_match(received_path, scrubbed_content, options)
15
15
  else
16
- raise_verify_error_with_diff(approved_path, received_path, scrubbed_content, **options)
16
+ raise_verify_error_with_diff(approved_path, received_path, scrubbed_content, options)
17
17
  end
18
18
  end
19
19
 
20
20
  private
21
21
 
22
- def apply_optional_scrubber(content, **options)
23
- if options.key?(:scrubber) && options[:scrubber]
22
+ def apply_optional_scrubber(content, options)
23
+ if options.has_key?(:scrubber) && options[:scrubber]
24
24
  options[:scrubber].call(content)
25
25
  else
26
26
  content
27
27
  end
28
28
  end
29
29
 
30
- def pre_approve_if_asked(approved_path, scrubbed_content, **options)
30
+ def pre_approve_if_asked(approved_path, scrubbed_content, options)
31
31
  File.write(approved_path, scrubbed_content) if options[:approve_all] || options[:accept_all] || ENV['APPROVE_ALL']
32
32
  end
33
33
 
34
- def handle_match(received_path, received_content, **options)
34
+ def handle_match(received_path, received_content, options)
35
35
  if options[:keep_received_file] == true
36
36
  File.write(received_path, received_content)
37
37
  elsif File.file?(received_path)
@@ -43,7 +43,7 @@ class Approvals
43
43
  "#{approved_path}.received"
44
44
  end
45
45
 
46
- def load_expected_content(approved_path, **options)
46
+ def load_expected_content(approved_path, options)
47
47
  if File.file? approved_path
48
48
  File.read(approved_path)
49
49
  else
@@ -52,7 +52,7 @@ class Approvals
52
52
  end
53
53
  end
54
54
 
55
- def raise_verify_error_with_diff(approved_path, received_path, received_content, **options)
55
+ def raise_verify_error_with_diff(approved_path, received_path, received_content, options)
56
56
  File.write(received_path, received_content)
57
57
 
58
58
  # and generate a diff for the console
@@ -61,8 +61,18 @@ class Approvals
61
61
  message << %(- writing received content to: "#{received_path}")
62
62
  message << "\n"
63
63
 
64
- expected_content = load_expected_content(approved_path)
65
- ::RSpec::Expectations.fail_with message, expected_content, received_content
64
+ expected_content = load_expected_content(approved_path, options)
65
+
66
+ if !expected_content.include?("\n") || !received_content.include?("\n")
67
+ # work around a bug in rspec-support 3.12.0's differ
68
+ # where it shows nothing when both strings are single line
69
+ # https://github.com/rspec/rspec-support/blob/v3.12.0/lib/rspec/support/differ.rb#L16-L18
70
+ message << "expected: #{expected_content.inspect}\n"
71
+ message << "received: #{received_content.inspect}\n"
72
+ ::RSpec::Expectations.fail_with message
73
+ else
74
+ ::RSpec::Expectations.fail_with message, expected_content, received_content
75
+ end
66
76
  end
67
77
  end
68
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_approvals-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Alpert
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2023-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,24 +122,23 @@ files:
122
122
  homepage: https://github.com/davidalpert/simple_approvals-rspec/
123
123
  licenses: []
124
124
  metadata: {}
125
- post_install_message:
125
+ post_install_message:
126
126
  rdoc_options: []
127
127
  require_paths:
128
128
  - lib
129
129
  required_ruby_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ">="
131
+ - - "~>"
132
132
  - !ruby/object:Gem::Version
133
- version: '0'
133
+ version: 3.1.0
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.6.11
142
- signing_key:
140
+ rubygems_version: 3.3.7
141
+ signing_key:
143
142
  specification_version: 4
144
143
  summary: ''
145
144
  test_files: []