minitest_change_assertions 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/minitest_change_assertions/assertions.rb +15 -6
- data/lib/minitest_change_assertions/version.rb +1 -1
- data/test/assertions_test.rb +24 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da434b55f9d4ed35cb0b4626491918baad34d2c6
|
4
|
+
data.tar.gz: fa181a3a6db96c67e27bd82d475914da91ae81d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74b44dd2b05f9fa695ef8754188dea4ce85aca22807d0367d6b8ac4a2c80e8ec0be4cfba814f31878760ccc3767a6b087a9f5459311fa349b2842e46c304183f
|
7
|
+
data.tar.gz: efbd6eb349c5d7a60bb34044b7a9b0767db6c0356f7f5740e738826de1dcc219525d0bb1de9aa5ecf1fd7b7c861259e1f708cfe9edb49bfe43b2b431ca8102b2
|
data/CHANGELOG.md
CHANGED
@@ -7,16 +7,21 @@ Minitest::Assertions.module_eval do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
if opts.key?(:to)
|
10
|
-
|
10
|
+
to = opts[:to]
|
11
11
|
elsif opts.key?('to')
|
12
|
-
|
12
|
+
to = opts['to']
|
13
13
|
else
|
14
14
|
expected = e.call
|
15
15
|
end
|
16
16
|
|
17
17
|
block.call
|
18
18
|
|
19
|
-
|
19
|
+
|
20
|
+
if to
|
21
|
+
assert_equal to, e.call
|
22
|
+
else
|
23
|
+
refute_equal expected, e.call
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
def assert_not_changed(expression, opts={}, &block)
|
@@ -27,15 +32,19 @@ Minitest::Assertions.module_eval do
|
|
27
32
|
end
|
28
33
|
|
29
34
|
if opts.key?(:to)
|
30
|
-
|
35
|
+
to = opts[:to]
|
31
36
|
elsif opts.key?('to')
|
32
|
-
|
37
|
+
to = opts['to']
|
33
38
|
else
|
34
39
|
expected = e.call
|
35
40
|
end
|
36
41
|
|
37
42
|
block.call
|
38
43
|
|
39
|
-
|
44
|
+
if to
|
45
|
+
refute_equal to, e.call
|
46
|
+
else
|
47
|
+
assert_equal expected, e.call
|
48
|
+
end
|
40
49
|
end
|
41
50
|
end
|
data/test/assertions_test.rb
CHANGED
@@ -16,42 +16,50 @@ class AssertionsTest < MiniTest::Test
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_assert_changed
|
19
|
-
|
20
|
-
|
19
|
+
name = 'Allen'
|
20
|
+
|
21
|
+
assert_changed 'name' do
|
22
|
+
name = 'Bob'
|
21
23
|
end
|
22
24
|
|
23
|
-
assert_changed -> {
|
24
|
-
|
25
|
+
assert_changed -> { name } do
|
26
|
+
name = 'Greg'
|
25
27
|
end
|
26
28
|
|
27
29
|
### OR with optional :to argument
|
28
30
|
|
29
|
-
assert_changed '
|
30
|
-
|
31
|
+
assert_changed 'name', to: 'Bob' do
|
32
|
+
name = 'Bob'
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_changed -> { name }, to: 'Bob' do
|
36
|
+
name = 'Bob'
|
31
37
|
end
|
32
38
|
|
33
|
-
assert_changed -> {
|
34
|
-
|
39
|
+
assert_changed -> { name }, to: 'Greg' do
|
40
|
+
name = 'Greg'
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
44
|
def test_assert_not_changed
|
39
|
-
|
40
|
-
|
45
|
+
name = 'Allen'
|
46
|
+
|
47
|
+
assert_not_changed 'name' do
|
48
|
+
name = 'Allen'
|
41
49
|
end
|
42
50
|
|
43
|
-
assert_not_changed -> {
|
44
|
-
|
51
|
+
assert_not_changed -> { name } do
|
52
|
+
name = 'Allen'
|
45
53
|
end
|
46
54
|
|
47
55
|
### OR with optional :to argument
|
48
56
|
|
49
|
-
assert_not_changed '
|
50
|
-
|
57
|
+
assert_not_changed 'name', to: 'Greg' do
|
58
|
+
name = 'Bob'
|
51
59
|
end
|
52
60
|
|
53
|
-
assert_not_changed -> {
|
54
|
-
|
61
|
+
assert_not_changed -> { name }, to: 'Greg' do
|
62
|
+
name = 'Bob'
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|