assert 2.19.0 → 2.19.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/assert.gemspec +11 -6
  4. data/bin/assert +1 -0
  5. data/lib/assert.rb +20 -6
  6. data/lib/assert/actual_value.rb +11 -6
  7. data/lib/assert/assert_runner.rb +38 -17
  8. data/lib/assert/assertions.rb +85 -50
  9. data/lib/assert/cli.rb +32 -70
  10. data/lib/assert/clirb.rb +55 -0
  11. data/lib/assert/config.rb +22 -8
  12. data/lib/assert/config_helpers.rb +57 -22
  13. data/lib/assert/context.rb +16 -18
  14. data/lib/assert/context/let_dsl.rb +8 -2
  15. data/lib/assert/context/method_missing.rb +3 -0
  16. data/lib/assert/context/setup_dsl.rb +24 -16
  17. data/lib/assert/context/subject_dsl.rb +9 -7
  18. data/lib/assert/context/suite_dsl.rb +5 -1
  19. data/lib/assert/context/test_dsl.rb +58 -19
  20. data/lib/assert/context_info.rb +2 -0
  21. data/lib/assert/default_runner.rb +2 -0
  22. data/lib/assert/default_suite.rb +27 -15
  23. data/lib/assert/default_view.rb +49 -30
  24. data/lib/assert/factory.rb +2 -0
  25. data/lib/assert/file_line.rb +8 -6
  26. data/lib/assert/macro.rb +3 -1
  27. data/lib/assert/macros/methods.rb +73 -45
  28. data/lib/assert/result.rb +114 -62
  29. data/lib/assert/runner.rb +70 -51
  30. data/lib/assert/stub.rb +44 -3
  31. data/lib/assert/suite.rb +69 -28
  32. data/lib/assert/test.rb +43 -36
  33. data/lib/assert/utils.rb +22 -11
  34. data/lib/assert/version.rb +3 -1
  35. data/lib/assert/view.rb +46 -18
  36. data/lib/assert/view_helpers.rb +102 -92
  37. data/test/helper.rb +8 -4
  38. data/test/support/factory.rb +40 -21
  39. data/test/support/inherited_stuff.rb +2 -0
  40. data/test/system/stub_tests.rb +182 -144
  41. data/test/system/test_tests.rb +88 -60
  42. data/test/unit/actual_value_tests.rb +71 -50
  43. data/test/unit/assert_tests.rb +42 -23
  44. data/test/unit/assertions/assert_block_tests.rb +12 -10
  45. data/test/unit/assertions/assert_changes_tests.rb +27 -21
  46. data/test/unit/assertions/assert_empty_tests.rb +16 -12
  47. data/test/unit/assertions/assert_equal_tests.rb +28 -26
  48. data/test/unit/assertions/assert_file_exists_tests.rb +17 -13
  49. data/test/unit/assertions/assert_includes_tests.rb +12 -10
  50. data/test/unit/assertions/assert_instance_of_tests.rb +16 -14
  51. data/test/unit/assertions/assert_is_a_tests.rb +128 -0
  52. data/test/unit/assertions/assert_match_tests.rb +12 -10
  53. data/test/unit/assertions/assert_nil_tests.rb +18 -12
  54. data/test/unit/assertions/assert_raises_tests.rb +29 -20
  55. data/test/unit/assertions/assert_respond_to_tests.rb +12 -10
  56. data/test/unit/assertions/assert_same_tests.rb +26 -24
  57. data/test/unit/assertions/assert_true_false_tests.rb +34 -24
  58. data/test/unit/assertions_tests.rb +16 -9
  59. data/test/unit/config_helpers_tests.rb +17 -10
  60. data/test/unit/config_tests.rb +36 -9
  61. data/test/unit/context/let_dsl_tests.rb +2 -0
  62. data/test/unit/context/setup_dsl_tests.rb +26 -14
  63. data/test/unit/context/subject_dsl_tests.rb +5 -3
  64. data/test/unit/context/suite_dsl_tests.rb +6 -4
  65. data/test/unit/context/test_dsl_tests.rb +39 -17
  66. data/test/unit/context_info_tests.rb +6 -4
  67. data/test/unit/context_tests.rb +112 -54
  68. data/test/unit/default_runner_tests.rb +2 -0
  69. data/test/unit/default_suite_tests.rb +12 -6
  70. data/test/unit/factory_tests.rb +4 -2
  71. data/test/unit/file_line_tests.rb +9 -7
  72. data/test/unit/macro_tests.rb +13 -11
  73. data/test/unit/result_tests.rb +49 -41
  74. data/test/unit/runner_tests.rb +33 -18
  75. data/test/unit/suite_tests.rb +39 -15
  76. data/test/unit/test_tests.rb +65 -50
  77. data/test/unit/utils_tests.rb +52 -37
  78. data/test/unit/view_helpers_tests.rb +23 -14
  79. data/test/unit/view_tests.rb +7 -5
  80. metadata +26 -11
  81. data/test/unit/assertions/assert_kind_of_tests.rb +0 -66
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9486fb389a6e45657eaf3c79f7c2cfea3e8cd6d9b8593c28597b716f9316c86b
4
- data.tar.gz: dea0bd1b5061630fddad2f2feaa43e3faf0e64504bf444599747035b3ca8e40f
3
+ metadata.gz: 35f8f95e4407b3f78d1f7f1c764bb22c0287bbdb8cf44574c50c43bb9f30732c
4
+ data.tar.gz: 1c1ab4b120c4b8e006971b492ec5ac776d5cd4e55ac9df85f387d5065801d7fc
5
5
  SHA512:
6
- metadata.gz: c6e57f7df5c6b7273a3ccb190ecc77f014fe597fa15fb6cc72f4bdadd77a12066736e9dffc12cc02d4854f7cf92751fe1994d5142ad24c44eb196906eb079d64
7
- data.tar.gz: cd2c4c0ef5c647abab8a9aac3340d17219ccd5b9d8eed5df34f47238296187122ee4b0df2c09aa9989e7dc8ddcb5d0529e3c615f539cf22e3e4f5d35a8b81575
6
+ metadata.gz: 77ffacb188ba7c3accba0ece4702a8695dd6735a09e2c86183c0e0a4106946b28d7e18bf8e4ead82046bd9376697fc45886b1e6bc43098f6c5eeaf4e78350037
7
+ data.tar.gz: 633e0ca4b3e75f7a653ff301cfebe98b76cd55a0665c3082dfb3cbd9b24e0d582e4f5aa752ec42a76e0c7035b61502f03cb4eddfd94662e9f797c04e093f4dd4
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- ruby "~>2.4"
5
+ ruby "~> 2.5"
4
6
 
5
7
  gemspec
6
8
 
7
- gem "pry", "~> 0.12.2"
9
+ gem "pry"
@@ -1,4 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
2
4
  lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require "assert/version"
@@ -8,19 +10,22 @@ Gem::Specification.new do |gem|
8
10
  gem.version = Assert::VERSION
9
11
  gem.authors = ["Kelly Redding", "Collin Redding"]
10
12
  gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
11
- gem.summary = %q{Assertion style testing framework.}
12
- gem.description = %q{Assertion style testing framework.}
13
+ gem.summary = "Assertion style testing framework."
14
+ gem.description = "Assertion style testing framework."
13
15
  gem.homepage = "http://github.com/redding/assert"
14
16
  gem.license = "MIT"
15
17
 
16
- gem.files = `git ls-files | grep "^[^.]"`.split($/)
18
+ gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
19
+
17
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
22
  gem.require_paths = ["lib"]
20
23
 
21
24
  gem.required_ruby_version = "~> 2.5"
22
25
 
23
- gem.add_dependency("much-factory", ["~> 0.1.0"])
24
- gem.add_dependency("much-not-given", ["~> 0.1.0"])
25
- gem.add_dependency("much-stub", ["~> 0.1.4"])
26
+ gem.add_development_dependency("much-style-guide", ["~> 0.5.0"])
27
+
28
+ gem.add_dependency("much-factory", ["~> 0.2.1"])
29
+ gem.add_dependency("much-not-given", ["~> 0.1.2"])
30
+ gem.add_dependency("much-stub", ["~> 0.1.7"])
26
31
  end
data/bin/assert CHANGED
@@ -2,6 +2,7 @@
2
2
  #
3
3
  # Copyright (c) 2011-Present Kelly Redding and Collin Redding
4
4
  #
5
+ # frozen_string_literal: true
5
6
 
6
7
  require "assert"
7
8
  require "assert/cli"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/version"
2
4
 
3
5
  require "assert/config"
@@ -9,16 +11,28 @@ require "assert/utils"
9
11
  require "assert/view"
10
12
 
11
13
  module Assert
12
- def self.config; @config ||= Config.new; end
13
- def self.configure; yield self.config if block_given?; end
14
+ def self.config
15
+ @config ||= Config.new
16
+ end
17
+
18
+ def self.configure
19
+ yield config if block_given?
20
+ end
21
+
22
+ def self.view
23
+ config.view
24
+ end
14
25
 
15
- def self.view; self.config.view; end
16
- def self.suite; self.config.suite; end
17
- def self.runner; self.config.runner; end
26
+ def self.suite
27
+ config.suite
28
+ end
29
+
30
+ def self.runner
31
+ config.runner
32
+ end
18
33
 
19
34
  # unstub all stubs automatically (see stub.rb)
20
35
  class Context
21
36
  teardown{ Assert.unstub! }
22
37
  end
23
38
  end
24
-
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "much-not-given"
2
4
  require "much-stub"
3
5
 
4
6
  module Assert; end
7
+
5
8
  class Assert::ActualValue
6
9
  include MuchNotGiven
7
10
 
@@ -34,15 +37,17 @@ class Assert::ActualValue
34
37
  @context.assert_not_changes(*args, &@value)
35
38
  end
36
39
 
37
- def is_a_kind_of(expected_class, *args)
38
- @context.assert_kind_of(expected_class, @value, *args)
40
+ def is_a(expected_class, *args)
41
+ @context.assert_is_a(expected_class, @value, *args)
39
42
  end
40
- alias_method :is_kind_of, :is_a_kind_of
43
+ alias_method :is_a_kind_of, :is_a
44
+ alias_method :is_kind_of, :is_a
41
45
 
42
- def is_not_a_kind_of(expected_class, *args)
43
- @context.assert_not_kind_of(expected_class, @value, *args)
46
+ def is_not_a(expected_class, *args)
47
+ @context.assert_is_not_a(expected_class, @value, *args)
44
48
  end
45
- alias_method :is_not_kind_of, :is_not_a_kind_of
49
+ alias_method :is_not_a_kind_of, :is_not_a
50
+ alias_method :is_not_kind_of, :is_not_a
46
51
 
47
52
  def is_an_instance_of(expected_class, *args)
48
53
  @context.assert_instance_of(expected_class, @value, *args)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/cli"
2
4
 
3
5
  module Assert
@@ -23,24 +25,29 @@ module Assert
23
25
 
24
26
  def init(test_files, test_dir)
25
27
  # load any test helper file
26
- if test_dir && (h = File.join(test_dir, self.config.test_helper)) && File.exists?(h)
28
+ if (
29
+ test_dir &&
30
+ (h = File.join(test_dir, config.test_helper)) &&
31
+ File.exist?(h)
32
+ )
27
33
  Assert::CLI.bench("Requiring test helper"){ require h }
28
34
  end
29
35
 
30
- if self.config.list
36
+ if config.list
31
37
  $stdout.puts test_files
32
38
  halt
33
39
  end
34
40
 
35
41
  # load the test files
36
- runner, suite, view = self.config.runner, self.config.suite, self.config.view
42
+ runner, suite, view =
43
+ config.runner, config.suite, config.view
37
44
  runner.before_load(test_files)
38
45
  suite.before_load(test_files)
39
46
  view.before_load(test_files)
40
47
  Assert::CLI.bench("Requiring #{test_files.size} test files") do
41
48
  test_files.each{ |p| require p }
42
49
  end
43
- if self.config.debug
50
+ if config.debug
44
51
  puts Assert::CLI.debug_msg("Test files:")
45
52
  test_files.each{ |f| puts Assert::CLI.debug_msg(" #{f}") }
46
53
  end
@@ -50,7 +57,7 @@ module Assert
50
57
  end
51
58
 
52
59
  def run
53
- self.config.runner.run
60
+ config.runner.run
54
61
  end
55
62
 
56
63
  private
@@ -64,22 +71,27 @@ module Assert
64
71
  end
65
72
 
66
73
  def apply_local_settings
67
- safe_require(ENV["ASSERT_LOCALFILE"] || path_of(LOCAL_SETTINGS_FILE, Dir.pwd))
74
+ safe_require(
75
+ ENV["ASSERT_LOCALFILE"] ||
76
+ path_of(LOCAL_SETTINGS_FILE, Dir.pwd),
77
+ )
68
78
  end
69
79
 
70
80
  def apply_env_settings
71
- self.config.runner_seed ENV["ASSERT_RUNNER_SEED"].to_i if ENV["ASSERT_RUNNER_SEED"]
81
+ if ENV["ASSERT_RUNNER_SEED"]
82
+ config.runner_seed ENV["ASSERT_RUNNER_SEED"].to_i
83
+ end
72
84
  end
73
85
 
74
86
  def apply_option_settings(options)
75
- self.config.apply(options)
87
+ config.apply(options)
76
88
  end
77
89
 
78
90
  def lookup_test_files(test_paths)
79
- file_paths = if self.config.changed_only
91
+ file_paths = if config.changed_only
80
92
  changed_test_files(test_paths)
81
- elsif self.config.single_test?
82
- globbed_test_files([self.config.single_test_file_path])
93
+ elsif config.single_test?
94
+ globbed_test_files([config.single_test_file_path])
83
95
  else
84
96
  globbed_test_files(test_paths)
85
97
  end
@@ -88,33 +100,42 @@ module Assert
88
100
  end
89
101
 
90
102
  def changed_test_files(test_paths)
91
- globbed_test_files(self.config.changed_proc.call(self.config, test_paths))
103
+ globbed_test_files(config.changed_proc.call(config, test_paths))
92
104
  end
93
105
 
94
106
  def globbed_test_files(test_paths)
95
107
  test_paths.inject(Set.new) do |paths, path|
96
108
  p = File.expand_path(path, Dir.pwd)
97
- paths += Dir.glob("#{p}*") + Dir.glob("#{p}*/**/*")
109
+ paths + Dir.glob("#{p}*") + Dir.glob("#{p}*/**/*")
98
110
  end
99
111
  end
100
112
 
101
113
  def is_test_file?(path)
102
- self.config.test_file_suffixes.inject(false) do |result, suffix|
114
+ config.test_file_suffixes.inject(false) do |result, suffix|
103
115
  result || path =~ /#{suffix}$/
104
116
  end
105
117
  end
106
118
 
107
119
  def safe_require(settings_file)
108
- require settings_file if File.exists?(settings_file)
120
+ require settings_file if File.exist?(settings_file)
109
121
  end
110
122
 
111
123
  def path_of(segment, a_path)
112
124
  # this method inspects a test path and finds the test dir path.
113
125
  full_path = File.expand_path(a_path || ".", Dir.pwd)
114
126
  seg_pos = full_path.index(segment_regex(segment))
115
- File.join(seg_pos && (seg_pos > 0) ? full_path[0..(seg_pos-1)] : full_path, segment)
127
+ File.join(
128
+ if seg_pos && (seg_pos > 0)
129
+ full_path[0..(seg_pos - 1)]
130
+ else
131
+ full_path
132
+ end,
133
+ segment,
134
+ )
116
135
  end
117
136
 
118
- def segment_regex(seg); /^#{seg}$|^#{seg}\/|\/#{seg}\/|\/#{seg}$/; end
137
+ def segment_regex(seg)
138
+ %r{^#{seg}$|^#{seg}/|/#{seg}/|/#{seg}$}
139
+ end
119
140
  end
120
141
  end
@@ -1,14 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/utils"
2
4
 
3
5
  module Assert
4
6
  module Assertions
5
7
  IGNORED_ASSERTION_HELPERS =
6
8
  [
7
- :assert_throws, :assert_nothing_thrown,
8
- :assert_operator, :refute_operator,
9
- :assert_in_epsilon, :refute_in_epsilon,
10
- :assert_in_delta, :refute_in_delta,
11
- :assert_send
9
+ :assert_throws,
10
+ :assert_nothing_thrown,
11
+ :assert_operator,
12
+ :refute_operator,
13
+ :assert_in_epsilon,
14
+ :refute_in_epsilon,
15
+ :assert_in_delta,
16
+ :refute_in_delta,
17
+ :assert_send,
12
18
  ]
13
19
 
14
20
  def assert_block(desc = nil)
@@ -22,13 +28,15 @@ module Assert
22
28
 
23
29
  def assert_empty(collection, desc = nil)
24
30
  assert(collection.empty?, desc) do
25
- "Expected #{Assert::U.show(collection, __assert_config__)} to be empty."
31
+ "Expected #{Assert::U.show(collection, __assert_config__)} to "\
32
+ "be empty."
26
33
  end
27
34
  end
28
35
 
29
36
  def assert_not_empty(collection, desc = nil)
30
37
  assert(!collection.empty?, desc) do
31
- "Expected #{Assert::U.show(collection, __assert_config__)} to not be empty."
38
+ "Expected #{Assert::U.show(collection, __assert_config__)} to "\
39
+ "not be empty."
32
40
  end
33
41
  end
34
42
  alias_method :refute_empty, :assert_not_empty
@@ -43,7 +51,8 @@ module Assert
43
51
  "Expected does not equal actual, diff:\n"\
44
52
  "#{c.run_diff_proc.call(exp_show, act_show)}"
45
53
  else
46
- "Expected #{Assert::U.show(act, c)} to be equal to #{Assert::U.show(exp, c)}."
54
+ "Expected #{Assert::U.show(act, c)} to "\
55
+ "be equal to #{Assert::U.show(exp, c)}."
47
56
  end
48
57
  end
49
58
  end
@@ -58,20 +67,21 @@ module Assert
58
67
  "Expected equals actual, diff:\n"\
59
68
  "#{c.run_diff_proc.call(exp_show, act_show)}"
60
69
  else
61
- "Expected #{Assert::U.show(act, c)} to not be equal to #{Assert::U.show(exp, c)}."
70
+ "Expected #{Assert::U.show(act, c)} to "\
71
+ "not be equal to #{Assert::U.show(exp, c)}."
62
72
  end
63
73
  end
64
74
  end
65
75
  alias_method :refute_equal, :assert_not_equal
66
76
 
67
77
  def assert_file_exists(file_path, desc = nil)
68
- assert(File.exists?(File.expand_path(file_path)), desc) do
78
+ assert(File.exist?(File.expand_path(file_path)), desc) do
69
79
  "Expected #{Assert::U.show(file_path, __assert_config__)} to exist."
70
80
  end
71
81
  end
72
82
 
73
83
  def assert_not_file_exists(file_path, desc = nil)
74
- assert(!File.exists?(File.expand_path(file_path)), desc) do
84
+ assert(!File.exist?(File.expand_path(file_path)), desc) do
75
85
  "Expected #{Assert::U.show(file_path, __assert_config__)} to not exist."
76
86
  end
77
87
  end
@@ -97,36 +107,41 @@ module Assert
97
107
 
98
108
  def assert_instance_of(klass, instance, desc = nil)
99
109
  assert(instance.instance_of?(klass), desc) do
100
- "Expected #{Assert::U.show(instance, __assert_config__)} (#{instance.class})"\
101
- " to be an instance of #{klass}."
110
+ "Expected #{Assert::U.show(instance, __assert_config__)} "\
111
+ "(#{instance.class}) to be an instance of #{klass}."
102
112
  end
103
113
  end
104
114
 
105
115
  def assert_not_instance_of(klass, instance, desc = nil)
106
116
  assert(!instance.instance_of?(klass), desc) do
107
- "Expected #{Assert::U.show(instance, __assert_config__)} (#{instance.class})"\
108
- " to not be an instance of #{klass}."
117
+ "Expected #{Assert::U.show(instance, __assert_config__)} "\
118
+ "(#{instance.class}) to not be an instance of #{klass}."
109
119
  end
110
120
  end
111
121
  alias_method :refute_instance_of, :assert_not_instance_of
112
122
 
113
- def assert_kind_of(klass, instance, desc = nil)
114
- assert(instance.kind_of?(klass), desc) do
115
- "Expected #{Assert::U.show(instance, __assert_config__)} (#{instance.class})"\
116
- " to be a kind of #{klass}."
123
+ def assert_is_a(klass, instance, desc = nil)
124
+ assert(instance.is_a?(klass), desc) do
125
+ "Expected #{Assert::U.show(instance, __assert_config__)} "\
126
+ "(#{instance.class}) to be a `#{klass}`."
117
127
  end
118
128
  end
129
+ alias_method :assert_kind_of, :assert_is_a
119
130
 
120
- def assert_not_kind_of(klass, instance, desc = nil)
121
- assert(!instance.kind_of?(klass), desc) do
122
- "Expected #{Assert::U.show(instance, __assert_config__)} (#{instance.class})"\
123
- " to not be a kind of #{klass}."
131
+ def assert_is_not_a(klass, instance, desc = nil)
132
+ assert(!instance.is_a?(klass), desc) do
133
+ "Expected #{Assert::U.show(instance, __assert_config__)} "\
134
+ "(#{instance.class}) to not be a `#{klass}`."
124
135
  end
125
136
  end
126
- alias_method :refute_kind_of, :assert_not_kind_of
137
+ alias_method :assert_not_a, :assert_is_not_a
138
+ alias_method :assert_not_kind_of, :assert_is_not_a
139
+ alias_method :refute_is_a, :assert_is_not_a
140
+ alias_method :refute_kind_of, :assert_is_not_a
127
141
 
128
142
  def assert_match(exp, act, desc = nil)
129
- exp_regex = String === exp && String === act ? /#{Regexp.escape(exp)}/ : exp
143
+ exp_regex =
144
+ String === exp && String === act ? /#{Regexp.escape(exp)}/ : exp
130
145
  assert(act =~ exp_regex, desc) do
131
146
  "Expected #{Assert::U.show(act, __assert_config__)}"\
132
147
  " to match #{Assert::U.show(exp, __assert_config__)}."
@@ -183,7 +198,7 @@ module Assert
183
198
  alias_method :refute_false, :assert_not_false
184
199
 
185
200
  def assert_raises(*exceptions, &block)
186
- desc = exceptions.last.kind_of?(String) ? exceptions.pop : nil
201
+ desc = exceptions.last.is_a?(String) ? exceptions.pop : nil
187
202
  err = RaisedException.new(exceptions, &block)
188
203
  assert(err.raised?, desc){ err.msg }
189
204
  err.exception
@@ -191,7 +206,7 @@ module Assert
191
206
  alias_method :assert_raise, :assert_raises
192
207
 
193
208
  def assert_nothing_raised(*exceptions, &block)
194
- desc = exceptions.last.kind_of?(String) ? exceptions.pop : nil
209
+ desc = exceptions.last.is_a?(String) ? exceptions.pop : nil
195
210
  err = NoRaisedException.new(exceptions, &block)
196
211
  assert(!err.raised?, desc){ err.msg }
197
212
  end
@@ -203,15 +218,15 @@ module Assert
203
218
  desc: nil,
204
219
  from: Assert::ActualValue.not_given,
205
220
  to: Assert::ActualValue.not_given,
206
- &block
207
- )
221
+ &block)
208
222
  desc_msg = desc ? "#{desc}\n" : ""
209
223
  from_eval = instance_eval(ruby_string_to_eval)
210
224
  if Assert::ActualValue.given?(from)
211
225
  assert_equal(
212
226
  from,
213
227
  from_eval,
214
- "#{desc_msg}Expected `#{ruby_string_to_eval}` to change from `#{from.inspect}`."
228
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to "\
229
+ "change from `#{from.inspect}`.",
215
230
  )
216
231
  end
217
232
 
@@ -222,7 +237,8 @@ module Assert
222
237
  assert_equal(
223
238
  to,
224
239
  to_eval,
225
- "#{desc_msg}Expected `#{ruby_string_to_eval}` to change to `#{to.inspect}`."
240
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to "\
241
+ "change to `#{to.inspect}`.",
226
242
  )
227
243
  end
228
244
 
@@ -234,7 +250,7 @@ module Assert
234
250
  from_eval,
235
251
  to_eval,
236
252
  "#{desc_msg}Expected `#{ruby_string_to_eval}` to change; "\
237
- "it was `#{from_eval.inspect}` and didn't change."
253
+ "it was `#{from_eval.inspect}` and didn't change.",
238
254
  )
239
255
  end
240
256
  end
@@ -243,15 +259,15 @@ module Assert
243
259
  ruby_string_to_eval,
244
260
  desc: nil,
245
261
  from: Assert::ActualValue.not_given,
246
- &block
247
- )
262
+ &block)
248
263
  desc_msg = desc ? "#{desc}\n" : ""
249
264
  from_eval = instance_eval(ruby_string_to_eval)
250
265
  if Assert::ActualValue.given?(from)
251
266
  assert_equal(
252
267
  from,
253
268
  from_eval,
254
- "#{desc_msg}Expected `#{ruby_string_to_eval}` to not change from `#{from.inspect}`."
269
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to "\
270
+ "not change from `#{from.inspect}`.",
255
271
  )
256
272
  end
257
273
 
@@ -262,23 +278,23 @@ module Assert
262
278
  from_eval,
263
279
  to_eval,
264
280
  "#{desc_msg}Expected `#{ruby_string_to_eval}` to not change; "\
265
- "it was `#{from_eval.inspect}` and changed to `#{to_eval.inspect}`."
281
+ "it was `#{from_eval.inspect}` and changed to `#{to_eval.inspect}`.",
266
282
  )
267
283
  end
268
284
  alias_method :refute_changes, :assert_not_changes
269
285
 
270
286
  def assert_respond_to(method, object, desc = nil)
271
287
  assert(object.respond_to?(method), desc) do
272
- "Expected #{Assert::U.show(object, __assert_config__)} (#{object.class})"\
273
- " to respond to `#{method}`."
288
+ "Expected #{Assert::U.show(object, __assert_config__)} "\
289
+ "(#{object.class}) to respond to `#{method}`."
274
290
  end
275
291
  end
276
292
  alias_method :assert_responds_to, :assert_respond_to
277
293
 
278
294
  def assert_not_respond_to(method, object, desc = nil)
279
295
  assert(!object.respond_to?(method), desc) do
280
- "Expected #{Assert::U.show(object, __assert_config__)} (#{object.class})"\
281
- " to not respond to `#{method}`."
296
+ "Expected #{Assert::U.show(object, __assert_config__)} "\
297
+ "(#{object.class}) to not respond to `#{method}`."
282
298
  end
283
299
  end
284
300
  alias_method :assert_not_responds_to, :assert_not_respond_to
@@ -297,8 +313,8 @@ module Assert
297
313
  "Expected #{act_id} to be the same as #{exp_id}, diff:\n"\
298
314
  "#{c.run_diff_proc.call(exp_show, act_show)}"
299
315
  else
300
- "Expected #{Assert::U.show(act, c)} (#{act_id}) to be the same as"\
301
- " #{Assert::U.show(exp, c)} (#{exp_id})."
316
+ "Expected #{Assert::U.show(act, c)} (#{act_id}) to "\
317
+ "be the same as #{Assert::U.show(exp, c)} (#{exp_id})."
302
318
  end
303
319
  end
304
320
  end
@@ -315,8 +331,8 @@ module Assert
315
331
  "Expected #{act_id} to not be the same as #{exp_id}, diff:\n"\
316
332
  "#{c.run_diff_proc.call(exp_show, act_show)}"
317
333
  else
318
- "Expected #{Assert::U.show(act, c)} (#{act_id}) to not be the same as"\
319
- " #{Assert::U.show(exp, c)} (#{exp_id})."
334
+ "Expected #{Assert::U.show(act, c)} (#{act_id}) to "\
335
+ "not be the same as #{Assert::U.show(exp, c)} (#{exp_id})."
320
336
  end
321
337
  end
322
338
  end
@@ -335,7 +351,16 @@ module Assert
335
351
 
336
352
  def initialize(exceptions, &block)
337
353
  @exceptions = exceptions
338
- begin; block.call; rescue Exception => @exception; end
354
+ # rubocop:disable Lint/SuppressedException
355
+ # rubocop:disable Lint/RescueException
356
+ # rubocop:disable Naming/RescuedExceptionsVariableName
357
+ begin
358
+ block.call
359
+ rescue Exception => @exception
360
+ end
361
+ # rubocop:enable Lint/SuppressedException
362
+ # rubocop:enable Lint/RescueException
363
+ # rubocop:enable Naming/RescuedExceptionsVariableName
339
364
  @msg = "#{exceptions_sentence(@exceptions)} #{exception_details}"
340
365
  end
341
366
 
@@ -347,7 +372,11 @@ module Assert
347
372
 
348
373
  def is_one_of?(exception, exceptions)
349
374
  exceptions.empty? || exceptions.any? do |exp|
350
- exp.instance_of?(Module) ? exception.kind_of?(exp) : exception.class == exp
375
+ if exp.instance_of?(Module)
376
+ exception.is_a?(exp)
377
+ else
378
+ exception.class == exp
379
+ end
351
380
  end
352
381
  end
353
382
 
@@ -362,13 +391,16 @@ module Assert
362
391
  def exception_details(raised_msg = nil, no_raised_msg = nil)
363
392
  if @exception
364
393
  backtrace = Assert::Result::Backtrace.new(@exception.backtrace)
365
- [ raised_msg,
394
+ [
395
+ raised_msg,
366
396
  "Class: `#{@exception.class}`",
367
397
  "Message: `#{@exception.message.inspect}`",
368
398
  "---Backtrace---",
369
399
  backtrace.filtered.to_s,
370
- "---------------"
371
- ].compact.join("\n")
400
+ "---------------",
401
+ ]
402
+ .compact
403
+ .join("\n")
372
404
  else
373
405
  no_raised_msg
374
406
  end
@@ -377,7 +409,10 @@ module Assert
377
409
 
378
410
  class RaisedException < CheckException
379
411
  def exception_details
380
- super("exception expected, not:", "exception expected but nothing raised.")
412
+ super(
413
+ "exception expected, not:",
414
+ "exception expected but nothing raised."
415
+ )
381
416
  end
382
417
  end
383
418