assert 2.18.2 → 2.19.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/README.md +7 -6
  4. data/assert.gemspec +5 -2
  5. data/bin/assert +1 -0
  6. data/lib/assert.rb +2 -0
  7. data/lib/assert/actual_value.rb +143 -0
  8. data/lib/assert/assert_runner.rb +2 -0
  9. data/lib/assert/assertions.rb +82 -20
  10. data/lib/assert/cli.rb +2 -0
  11. data/lib/assert/config.rb +2 -0
  12. data/lib/assert/config_helpers.rb +2 -0
  13. data/lib/assert/context.rb +33 -37
  14. data/lib/assert/context/let_dsl.rb +16 -0
  15. data/lib/assert/context/method_missing.rb +22 -0
  16. data/lib/assert/context/setup_dsl.rb +3 -0
  17. data/lib/assert/context/subject_dsl.rb +26 -24
  18. data/lib/assert/context/suite_dsl.rb +3 -0
  19. data/lib/assert/context/test_dsl.rb +3 -0
  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 +2 -0
  23. data/lib/assert/default_view.rb +2 -0
  24. data/lib/assert/factory.rb +2 -0
  25. data/lib/assert/file_line.rb +2 -0
  26. data/lib/assert/macro.rb +2 -0
  27. data/lib/assert/macros/methods.rb +6 -4
  28. data/lib/assert/result.rb +8 -1
  29. data/lib/assert/runner.rb +2 -0
  30. data/lib/assert/stub.rb +45 -0
  31. data/lib/assert/suite.rb +9 -10
  32. data/lib/assert/test.rb +3 -9
  33. data/lib/assert/utils.rb +3 -1
  34. data/lib/assert/version.rb +3 -1
  35. data/lib/assert/view.rb +2 -0
  36. data/lib/assert/view_helpers.rb +2 -0
  37. data/test/helper.rb +28 -28
  38. data/test/support/factory.rb +17 -0
  39. data/test/support/inherited_stuff.rb +2 -0
  40. data/test/system/stub_tests.rb +334 -333
  41. data/test/system/test_tests.rb +101 -109
  42. data/test/unit/actual_value_tests.rb +373 -0
  43. data/test/unit/assert_tests.rb +79 -61
  44. data/test/unit/assertions/assert_block_tests.rb +32 -31
  45. data/test/unit/assertions/assert_changes_tests.rb +99 -0
  46. data/test/unit/assertions/assert_empty_tests.rb +35 -32
  47. data/test/unit/assertions/assert_equal_tests.rb +96 -74
  48. data/test/unit/assertions/assert_file_exists_tests.rb +34 -33
  49. data/test/unit/assertions/assert_includes_tests.rb +40 -37
  50. data/test/unit/assertions/assert_instance_of_tests.rb +36 -33
  51. data/test/unit/assertions/assert_kind_of_tests.rb +36 -33
  52. data/test/unit/assertions/assert_match_tests.rb +36 -33
  53. data/test/unit/assertions/assert_nil_tests.rb +32 -31
  54. data/test/unit/assertions/assert_raises_tests.rb +57 -55
  55. data/test/unit/assertions/assert_respond_to_tests.rb +38 -35
  56. data/test/unit/assertions/assert_same_tests.rb +88 -81
  57. data/test/unit/assertions/assert_true_false_tests.rb +62 -60
  58. data/test/unit/assertions_tests.rb +28 -24
  59. data/test/unit/config_helpers_tests.rb +45 -38
  60. data/test/unit/config_tests.rb +40 -34
  61. data/test/unit/context/let_dsl_tests.rb +12 -0
  62. data/test/unit/context/setup_dsl_tests.rb +72 -81
  63. data/test/unit/context/subject_dsl_tests.rb +17 -43
  64. data/test/unit/context/suite_dsl_tests.rb +17 -16
  65. data/test/unit/context/test_dsl_tests.rb +52 -52
  66. data/test/unit/context_info_tests.rb +25 -15
  67. data/test/unit/context_tests.rb +186 -179
  68. data/test/unit/default_runner_tests.rb +4 -5
  69. data/test/unit/default_suite_tests.rb +59 -53
  70. data/test/unit/factory_tests.rb +7 -3
  71. data/test/unit/file_line_tests.rb +35 -35
  72. data/test/unit/macro_tests.rb +16 -10
  73. data/test/unit/result_tests.rb +161 -183
  74. data/test/unit/runner_tests.rb +67 -65
  75. data/test/unit/suite_tests.rb +58 -59
  76. data/test/unit/test_tests.rb +120 -139
  77. data/test/unit/utils_tests.rb +45 -45
  78. data/test/unit/view_helpers_tests.rb +56 -52
  79. data/test/unit/view_tests.rb +24 -23
  80. metadata +29 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93616ac8a1849d9f356088b0386907f946cf89465e84aaa6321ceff60f7012de
4
- data.tar.gz: a4436d1c9d437cb56343318885b1a32d804ad2e71c956408cd877d695f3d9675
3
+ metadata.gz: e3b20f41e3b589e8ae182a0da975229922e825b024d4bd8e35d886345728e6e7
4
+ data.tar.gz: 5e2c9057744017ab8a1da1033a15f5c3b3fab0b93f62b7b9aa9fc2bcf07f5cdf
5
5
  SHA512:
6
- metadata.gz: 424110cb0d83c44fcdc66129532bc53859a74a0b2f63f2b08081955d6aee813a9df11f37afbdc325f464866ca0263fc98164992d08949fa2573410f9056334c6
7
- data.tar.gz: 25b2980b91b9e4dddf9724f64cbdc81214c910008157f0ac88f3e3a1c6f4ae8162065d08ef4a2c2eb78ff2211cdc49fdac893397e50e04b5816174eb8293c01b
6
+ metadata.gz: 250ff1cbe8a89cadf674b2cb15d4ec2dce7d3de676c69b3462d06b12a4c4230766fe9a35d1ea5c1599fb7045b4cdf25c4e3d99cf862ea45bf70f20d354d073ab
7
+ data.tar.gz: de2c80f03461272a22c8f5f89f45e753fce2b0cadaed129f94b7fb3c7916df5aae1a14dec0cef2f0b37bb14e23e6898dc4a569cd7ed4a0cc9dad0adf78fde8cd
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"
data/README.md CHANGED
@@ -9,7 +9,7 @@ require "assert"
9
9
 
10
10
  class MyTests < Assert::Context
11
11
  test "something" do
12
- assert_equal 1, 1
12
+ assert_that(1).equals(1)
13
13
  end
14
14
  end
15
15
  ```
@@ -33,13 +33,13 @@ Running tests in random order, seeded with "56382"
33
33
 
34
34
  ## What Assert is not
35
35
 
36
- * **RSpec/spec-anything**: define tests using assertion statements
37
- * **Unit/Functional/Integration/etc**: Assert is agnostic - you define whatever kinds of tests you like (one or more of the above) and assert runs them in context
38
- * **Mock/Spec/BDD/etc**: Assert is the framework and there are a variety of 3rd party tools to do such things - feel free to use whatever you like
36
+ * **RSpec/spec-anything**: define tests using assertion statements.
37
+ * **Unit/Functional/Integration/etc**: Assert is agnostic - you define whatever kinds of tests you like and Assert runs them in context.
38
+ * **Mock/Spec/BDD/etc**: Assert is the framework and there are a variety of 3rd party tools to do such things. Feel free to use whatever you like.
39
39
 
40
40
  ## Description
41
41
 
42
- Assert is an assertion style testing framework, meaning you use assertion statements to define your tests and create results. Assert uses class-based contexts so if you want to nest your contexts, use inheritance.
42
+ Assert is an assertion-style testing framework, meaning you use assertion statements to define your tests and create results. Assert uses class-based contexts so if you want to nest your contexts, use inheritance.
43
43
 
44
44
  ### Features
45
45
 
@@ -50,6 +50,7 @@ Assert is an assertion style testing framework, meaning you use assertion statem
50
50
  * class-based contexts
51
51
  * multiple before/setup & after/teardown blocks
52
52
  * around blocks
53
+ * `let` value declarations
53
54
  * full backtrace for errors
54
55
  * optionally pretty print objects in failure descriptions
55
56
  * [stubbing API](https://github.com/redding/assert#stub)
@@ -666,4 +667,4 @@ If submitting a Pull Request, please:
666
667
 
667
668
  One note: please respect that Assert itself is intended to be the flexible, base-level, framework-type logic that should change little if at all. Pull requests for niche functionality or personal testing philosphy stuff will likely not be accepted.
668
669
 
669
- If you wish to extend Assert for your niche purpose/desire/philosophy, please do so in it's own gem (preferrably named `assert-<whatever>`) that uses Assert as a dependency.
670
+ If you wish to extend Assert for your niche purpose/desire/philosophy, please do so in its own gem (preferrably named `assert-<whatever>`) that uses Assert as a dependency.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- encoding: utf-8 -*-
2
4
  lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -20,6 +22,7 @@ Gem::Specification.new do |gem|
20
22
 
21
23
  gem.required_ruby_version = "~> 2.5"
22
24
 
23
- gem.add_dependency("much-factory", ["~> 0.1.0"])
24
- gem.add_dependency("much-stub", ["~> 0.1.3"])
25
+ gem.add_dependency("much-factory", ["~> 0.2.0"])
26
+ gem.add_dependency("much-not-given", ["~> 0.1.1"])
27
+ gem.add_dependency("much-stub", ["~> 0.1.6"])
25
28
  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"
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "much-not-given"
4
+ require "much-stub"
5
+
6
+ module Assert; end
7
+
8
+ class Assert::ActualValue
9
+ include MuchNotGiven
10
+
11
+ def initialize(value = self.class.not_given, context:, &value_block)
12
+ @value = self.class.given?(value) ? value : value_block
13
+ @context = context
14
+ end
15
+
16
+ def returns_true(*args)
17
+ @context.assert_block(*args, &@value)
18
+ end
19
+
20
+ def does_not_return_true(*args)
21
+ @context.assert_not_block(*args, &@value)
22
+ end
23
+
24
+ def raises(*expected_exceptions)
25
+ @context.assert_raises(*expected_exceptions, &@value)
26
+ end
27
+
28
+ def does_not_raise(*expected_exceptions)
29
+ @context.assert_nothing_raised(*expected_exceptions, &@value)
30
+ end
31
+
32
+ def changes(*args)
33
+ @context.assert_changes(*args, &@value)
34
+ end
35
+
36
+ def does_not_change(*args)
37
+ @context.assert_not_changes(*args, &@value)
38
+ end
39
+
40
+ def is_a_kind_of(expected_class, *args)
41
+ @context.assert_kind_of(expected_class, @value, *args)
42
+ end
43
+ alias_method :is_kind_of, :is_a_kind_of
44
+
45
+ def is_not_a_kind_of(expected_class, *args)
46
+ @context.assert_not_kind_of(expected_class, @value, *args)
47
+ end
48
+ alias_method :is_not_kind_of, :is_not_a_kind_of
49
+
50
+ def is_an_instance_of(expected_class, *args)
51
+ @context.assert_instance_of(expected_class, @value, *args)
52
+ end
53
+ alias_method :is_instance_of, :is_an_instance_of
54
+
55
+ def is_not_an_instance_of(expected_class, *args)
56
+ @context.assert_not_instance_of(expected_class, @value, *args)
57
+ end
58
+ alias_method :is_not_instance_of, :is_not_an_instance_of
59
+
60
+ def responds_to(expected_method_name, *args)
61
+ @context.assert_responds_to(expected_method_name, @value, *args)
62
+ end
63
+
64
+ def does_not_respond_to(expected_method_name, *args)
65
+ @context.assert_not_responds_to(expected_method_name, @value, *args)
66
+ end
67
+
68
+ def is_the_same_as(expected_object, *args)
69
+ @context.assert_same(expected_object, @value, *args)
70
+ end
71
+ alias_method :is, :is_the_same_as
72
+
73
+ def is_not_the_same_as(expected_object, *args)
74
+ @context.assert_not_same(expected_object, @value, *args)
75
+ end
76
+ alias_method :is_not, :is_not_the_same_as
77
+
78
+ def equals(expected_value, *args)
79
+ @context.assert_equal(expected_value, @value, *args)
80
+ end
81
+ alias_method :is_equal_to, :equals
82
+
83
+ def does_not_equal(expected_value, *args)
84
+ @context.assert_not_equal(expected_value, @value, *args)
85
+ end
86
+ alias_method :is_not_equal_to, :does_not_equal
87
+
88
+ def matches(expected_regex, *args)
89
+ @context.assert_match(expected_regex, @value, *args)
90
+ end
91
+
92
+ def does_not_match(expected_regex, *args)
93
+ @context.assert_not_match(expected_regex, @value, *args)
94
+ end
95
+
96
+ def is_empty(*args)
97
+ @context.assert_empty(@value, *args)
98
+ end
99
+
100
+ def is_not_empty(*args)
101
+ @context.assert_not_empty(@value, *args)
102
+ end
103
+
104
+ def includes(object, *args)
105
+ @context.assert_includes(object, @value, *args)
106
+ end
107
+
108
+ def does_not_include(object, *args)
109
+ @context.assert_not_includes(object, @value, *args)
110
+ end
111
+
112
+ def is_nil(*args)
113
+ @context.assert_nil(@value, *args)
114
+ end
115
+
116
+ def is_not_nil(*args)
117
+ @context.assert_not_nil(@value, *args)
118
+ end
119
+
120
+ def is_true(*args)
121
+ @context.assert_true(@value, *args)
122
+ end
123
+
124
+ def is_not_true(*args)
125
+ @context.assert_not_true(@value, *args)
126
+ end
127
+
128
+ def is_false(*args)
129
+ @context.assert_false(@value, *args)
130
+ end
131
+
132
+ def is_not_false(*args)
133
+ @context.assert_not_false(@value, *args)
134
+ end
135
+
136
+ def is_a_file(*args)
137
+ @context.assert_file_exists(@value, *args)
138
+ end
139
+
140
+ def is_not_a_file(*args)
141
+ @context.assert_not_file_exists(@value, *args)
142
+ end
143
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/cli"
2
4
 
3
5
  module Assert
@@ -1,7 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/utils"
2
4
 
3
5
  module Assert
4
6
  module Assertions
7
+ IGNORED_ASSERTION_HELPERS =
8
+ [
9
+ :assert_throws, :assert_nothing_thrown,
10
+ :assert_operator, :refute_operator,
11
+ :assert_in_epsilon, :refute_in_epsilon,
12
+ :assert_in_delta, :refute_in_delta,
13
+ :assert_send
14
+ ]
15
+
5
16
  def assert_block(desc = nil)
6
17
  assert(yield, desc){ "Expected block to return a true value." }
7
18
  end
@@ -25,7 +36,7 @@ module Assert
25
36
  alias_method :refute_empty, :assert_not_empty
26
37
 
27
38
  def assert_equal(exp, act, desc = nil)
28
- assert(exp == act, desc) do
39
+ assert(act == exp, desc) do
29
40
  c = __assert_config__
30
41
  exp_show = Assert::U.show_for_diff(exp, c)
31
42
  act_show = Assert::U.show_for_diff(act, c)
@@ -40,7 +51,7 @@ module Assert
40
51
  end
41
52
 
42
53
  def assert_not_equal(exp, act, desc = nil)
43
- assert(exp != act, desc) do
54
+ assert(act != exp, desc) do
44
55
  c = __assert_config__
45
56
  exp_show = Assert::U.show_for_diff(exp, c)
46
57
  act_show = Assert::U.show_for_diff(act, c)
@@ -189,6 +200,75 @@ module Assert
189
200
  alias_method :assert_not_raises, :assert_nothing_raised
190
201
  alias_method :assert_not_raise, :assert_nothing_raised
191
202
 
203
+ def assert_changes(
204
+ ruby_string_to_eval,
205
+ desc: nil,
206
+ from: Assert::ActualValue.not_given,
207
+ to: Assert::ActualValue.not_given,
208
+ &block
209
+ )
210
+ desc_msg = desc ? "#{desc}\n" : ""
211
+ from_eval = instance_eval(ruby_string_to_eval)
212
+ if Assert::ActualValue.given?(from)
213
+ assert_equal(
214
+ from,
215
+ from_eval,
216
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to change from `#{from.inspect}`."
217
+ )
218
+ end
219
+
220
+ block.call
221
+
222
+ to_eval = instance_eval(ruby_string_to_eval)
223
+ if Assert::ActualValue.given?(to)
224
+ assert_equal(
225
+ to,
226
+ to_eval,
227
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to change to `#{to.inspect}`."
228
+ )
229
+ end
230
+
231
+ if (
232
+ Assert::ActualValue.not_given?(from) &&
233
+ Assert::ActualValue.not_given?(to)
234
+ )
235
+ assert_not_equal(
236
+ from_eval,
237
+ to_eval,
238
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to change; "\
239
+ "it was `#{from_eval.inspect}` and didn't change."
240
+ )
241
+ end
242
+ end
243
+
244
+ def assert_not_changes(
245
+ ruby_string_to_eval,
246
+ desc: nil,
247
+ from: Assert::ActualValue.not_given,
248
+ &block
249
+ )
250
+ desc_msg = desc ? "#{desc}\n" : ""
251
+ from_eval = instance_eval(ruby_string_to_eval)
252
+ if Assert::ActualValue.given?(from)
253
+ assert_equal(
254
+ from,
255
+ from_eval,
256
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to not change from `#{from.inspect}`."
257
+ )
258
+ end
259
+
260
+ block.call
261
+
262
+ to_eval = instance_eval(ruby_string_to_eval)
263
+ assert_equal(
264
+ from_eval,
265
+ to_eval,
266
+ "#{desc_msg}Expected `#{ruby_string_to_eval}` to not change; "\
267
+ "it was `#{from_eval.inspect}` and changed to `#{to_eval.inspect}`."
268
+ )
269
+ end
270
+ alias_method :refute_changes, :assert_not_changes
271
+
192
272
  def assert_respond_to(method, object, desc = nil)
193
273
  assert(object.respond_to?(method), desc) do
194
274
  "Expected #{Assert::U.show(object, __assert_config__)} (#{object.class})"\
@@ -244,24 +324,6 @@ module Assert
244
324
  end
245
325
  alias_method :refute_same, :assert_not_same
246
326
 
247
- # ignored assertion helpers
248
-
249
- IGNORED_ASSERTION_HELPERS = [
250
- :assert_throws, :assert_nothing_thrown,
251
- :assert_operator, :refute_operator,
252
- :assert_in_epsilon, :refute_in_epsilon,
253
- :assert_in_delta, :refute_in_delta,
254
- :assert_send
255
- ]
256
- def method_missing(method, *args, &block)
257
- if IGNORED_ASSERTION_HELPERS.include?(method.to_sym)
258
- ignore "The assertion `#{method}` is not supported."\
259
- " Please use another assertion or the basic `assert`."
260
- else
261
- super
262
- end
263
- end
264
-
265
327
  private
266
328
 
267
329
  def __assert_config__
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "benchmark"
2
4
  require "set"
3
5
  require "assert/assert_runner"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/default_runner"
2
4
  require "assert/default_suite"
3
5
  require "assert/default_view"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Assert
2
4
  module ConfigHelpers
3
5
  def runner; self.config.runner; end
@@ -1,4 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "assert/actual_value"
1
4
  require "assert/assertions"
5
+ require "assert/context/let_dsl"
6
+ require "assert/context/method_missing"
2
7
  require "assert/context/setup_dsl"
3
8
  require "assert/context/subject_dsl"
4
9
  require "assert/context/suite_dsl"
@@ -10,42 +15,22 @@ require "assert/suite"
10
15
  require "assert/utils"
11
16
 
12
17
  module Assert
18
+ # A Context is a scope for tests to run in. Contexts have setup and teardown
19
+ # blocks, subjects, and descriptions. Tests are run in the scope of a Context
20
+ # instance. Therefore, a Context should have minimal base
21
+ # logic/methods/instance_vars. The instance should remain pure to not pollute
22
+ # test scopes.
13
23
  class Context
14
- # put all logic in DSL methods to keep context instances pure for running tests
24
+ # Put all logic in DSL methods to keep context instances pure.
15
25
  extend SetupDSL
16
26
  extend SubjectDSL
17
27
  extend SuiteDSL
18
28
  extend TestDSL
29
+ extend LetDSL
30
+ include MethodMissing
19
31
  include Assert::Assertions
20
32
  include Assert::Macros::Methods
21
33
 
22
- # a Context is a scope for tests to run in. Contexts have setup and
23
- # teardown blocks, subjects, and descriptions. Tests are run in the
24
- # scope of a Context instance. Therefore, a Context should have
25
- # minimal base logic/methods/instance_vars. The instance should remain
26
- # pure to not pollute test scopes.
27
-
28
- # if a test method is added to a context manually (not using a context helper):
29
- # capture any context info, build a test obj, and add it to the suite
30
- def self.method_added(method_name)
31
- if method_name.to_s =~ Suite::TEST_METHOD_REGEX
32
- klass_method_name = "#{self}##{method_name}"
33
-
34
- if self.suite.test_methods.include?(klass_method_name)
35
- puts "WARNING: redefining "#{klass_method_name}""
36
- puts " from: #{caller_locations(1,1)}"
37
- else
38
- self.suite.test_methods << klass_method_name
39
- end
40
-
41
- self.suite.on_test(Test.for_method(
42
- method_name.to_s,
43
- ContextInfo.new(self, nil, caller_locations(1,1)),
44
- self.suite.config
45
- ))
46
- end
47
- end
48
-
49
34
  def initialize(running_test, config, result_callback)
50
35
  @__assert_running_test__ = running_test
51
36
  @__assert_config__ = config
@@ -61,9 +46,8 @@ module Assert
61
46
  end
62
47
  end
63
48
 
64
- # check if the assertion is a truthy value, if so create a new pass result,
65
- # otherwise create a new fail result with the desc and what failed msg.
66
- # all other assertion helpers use this one in the end
49
+ # Check if the result is true. If so, create a new pass result, Otherwise
50
+ # create a new fail result with the desc and fail msg.
67
51
  def assert(assertion, desc = nil)
68
52
  if assertion
69
53
  pass
@@ -78,8 +62,8 @@ module Assert
78
62
  end
79
63
  end
80
64
 
81
- # the opposite of assert, check if the assertion is a false value, if so create a new pass
82
- # result, otherwise create a new fail result with the desc and it's what failed msg
65
+ # The opposite of assert. Check if the result is false. If so, create a new
66
+ # pass result. Otherwise create a new fail result with the desc and fail msg.
83
67
  def assert_not(assertion, fail_desc = nil)
84
68
  assert(!assertion, fail_desc) do
85
69
  "Failed assert_not: assertion was "\
@@ -88,14 +72,23 @@ module Assert
88
72
  end
89
73
  alias_method :refute, :assert_not
90
74
 
75
+ def assert_that(
76
+ actual_value = Assert::ActualValue.not_given,
77
+ &actual_value_block
78
+ )
79
+ Assert::ActualValue.new(actual_value, context: self, &actual_value_block)
80
+ end
81
+
91
82
  # adds a Pass result to the end of the test's results
92
83
  # does not break test execution
93
84
  def pass(pass_msg = nil)
94
85
  if @__assert_pending__ == 0
95
86
  capture_result(Assert::Result::Pass, pass_msg)
96
87
  else
97
- capture_result(Assert::Result::Fail, "Pending pass (make it "\
98
- "not pending)")
88
+ capture_result(
89
+ Assert::Result::Fail,
90
+ "Pending pass (make it not pending)"
91
+ )
99
92
  end
100
93
  end
101
94
 
@@ -157,9 +150,12 @@ module Assert
157
150
  end
158
151
 
159
152
  def subject
160
- if subj = self.class.subject
161
- instance_eval(&subj)
153
+ unless instance_variable_defined?("@__assert_subject__")
154
+ @__assert_subject__ =
155
+ instance_eval(&self.class.subject) if self.class.subject
162
156
  end
157
+
158
+ @__assert_subject__
163
159
  end
164
160
 
165
161
  def inspect