assert-moar 0.0.8 → 0.0.9

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
2
  SHA1:
3
- metadata.gz: f530f1dad82d4ffe2b1c1cdee8a186f3b0ba1eb9
4
- data.tar.gz: 6a65ac645a2ba0b6eeb0ca449162b883e243f868
3
+ metadata.gz: dcd60df7200e675f3b89415c79d21500d35ae834
4
+ data.tar.gz: cd7d45a1d3b8dbf95932fbfbd16d591fb9fe5f8f
5
5
  SHA512:
6
- metadata.gz: 07218e00c8a3309559af3a17a8e4d2ae3627ce18d8422e0c2de3c37e542b3ed406220271c8a547906c8d23128c295948fc5c11fe2dd758c88c2d01a7db138d43
7
- data.tar.gz: 8923bbad1292e0a4fd13a7ef6d890c62e38058c34cf66566074bde833827126c9652c69fbfd9831604a29dc6cfbfb45b3f0fa06034618ae0d20309c010a4aa08
6
+ metadata.gz: ff85988edecf6d579d47c1f9b0ede6d25a5ea3c955cedcee2822407ad607c8b4f4c78d384ae5e721537a1660f07237012c8c22e5de8cbca4c9edaa9aaf74e421
7
+ data.tar.gz: f4d9d78fcc7f7b911610e3331b037bf0257d9d6b233d9d4f7e0348892c81671b14ee6f5f0c9e70cd88669911ef7a9fa3b474115d806e3536b1660ca61cdab971
data/README.md CHANGED
@@ -35,6 +35,8 @@ Available methods:
35
35
  #refute_validates_uniqueness_of
36
36
  #assert_validates_with_callback
37
37
  #refute_validates_with_callback
38
+ #assert_memoizes_method_result
39
+ #refute_memoizes_method_result
38
40
  ```
39
41
 
40
42
  ## Contributing
@@ -57,6 +57,16 @@ module AssertMoar::Assertions
57
57
  refute object.valid?, "Expected object to not be valid"
58
58
  end
59
59
 
60
+ def assert_memoizes_method_result(object, method)
61
+ result = object.send(method)
62
+ assert_same object.send(method), result
63
+ end
64
+
65
+ def refute_memoizes_method_result(object, method)
66
+ result = object.send(method)
67
+ refute_same object.send(method), result
68
+ end
69
+
60
70
  private
61
71
  def has_validator?(object_or_class, property, validator_class)
62
72
  klass = object_or_class.class
@@ -1,3 +1,3 @@
1
1
  module AssertMoar
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -77,6 +77,16 @@ class AssertMoar::AssertionTest < Minitest::Test
77
77
  @tc.refute_validates_with_callback(double, :callback)
78
78
  end
79
79
 
80
+ def test_assert_memoizes_method_result
81
+ double = ActiveRecordDouble.new()
82
+ @tc.assert_memoizes_method_result(double, :memoized_method)
83
+ end
84
+
85
+ def test_refute_memoizes_method_result
86
+ double = ActiveRecordDouble.new()
87
+ @tc.refute_memoizes_method_result(double, :non_memoized_method)
88
+ end
89
+
80
90
  def teardown
81
91
  assert_equal(@assertion_count, @tc.assertions,
82
92
  "expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
@@ -28,6 +28,14 @@ class ActiveRecordDouble
28
28
  @@error_map = error_map.to_h
29
29
  end
30
30
 
31
+ def memoized_method
32
+ @object ||= BasicObject.new
33
+ end
34
+
35
+ def non_memoized_method
36
+ BasicObject.new
37
+ end
38
+
31
39
  def valid?
32
40
  @valid == true
33
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert-moar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Bohn