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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 131d9f66d84ad2ae5b8b0f768c773337f7c0b2b8
4
- data.tar.gz: ade67cd29e944b8facff11bb2446e5c89825f96a
3
+ metadata.gz: da434b55f9d4ed35cb0b4626491918baad34d2c6
4
+ data.tar.gz: fa181a3a6db96c67e27bd82d475914da91ae81d1
5
5
  SHA512:
6
- metadata.gz: 465ddf9b61d4ef86f834dd84458ac6ad81d26a2db4945b110656cd99c7d7f400451598628862ff5d1fb1fc0835a9c01fdfd2eb05cbb99822fe66c5fab27f6024
7
- data.tar.gz: 0fe8d8c2d274ef123a0ca2f8c5aa56d5ad6919738c29939c12158cccb4c2a2473ec6f2687c686071756d9c3c3bc0be63e2bf3ecabeafabb075546893185ac7ac
6
+ metadata.gz: 74b44dd2b05f9fa695ef8754188dea4ce85aca22807d0367d6b8ac4a2c80e8ec0be4cfba814f31878760ccc3767a6b087a9f5459311fa349b2842e46c304183f
7
+ data.tar.gz: efbd6eb349c5d7a60bb34044b7a9b0767db6c0356f7f5740e738826de1dcc219525d0bb1de9aa5ecf1fd7b7c861259e1f708cfe9edb49bfe43b2b431ca8102b2
@@ -1,5 +1,8 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
 
4
- - **1.0.0 - UNRELEASED**
4
+ - **1.0.1 - July 11, 2018**
5
+ - Fix incorrect assertions when using `:to` option
6
+ - Fix tests
7
+ - **1.0.0 - July 11, 2018**
5
8
  - Initial Gem Release
@@ -7,16 +7,21 @@ Minitest::Assertions.module_eval do
7
7
  end
8
8
 
9
9
  if opts.key?(:to)
10
- expected = opts[:to]
10
+ to = opts[:to]
11
11
  elsif opts.key?('to')
12
- expected = opts['to']
12
+ to = opts['to']
13
13
  else
14
14
  expected = e.call
15
15
  end
16
16
 
17
17
  block.call
18
18
 
19
- refute_equal expected, e.call
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
- expected = opts[:to]
35
+ to = opts[:to]
31
36
  elsif opts.key?('to')
32
- expected = opts['to']
37
+ to = opts['to']
33
38
  else
34
39
  expected = e.call
35
40
  end
36
41
 
37
42
  block.call
38
43
 
39
- assert_equal expected, e.call
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
@@ -1,3 +1,3 @@
1
1
  module MinitestChangeAssertions
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -16,42 +16,50 @@ class AssertionsTest < MiniTest::Test
16
16
  end
17
17
 
18
18
  def test_assert_changed
19
- assert_changed 'user.name' do
20
- user.name = 'Bob'
19
+ name = 'Allen'
20
+
21
+ assert_changed 'name' do
22
+ name = 'Bob'
21
23
  end
22
24
 
23
- assert_changed -> { user.name } do
24
- user.name = 'Bob'
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 'user.name', to: 'Bob' do
30
- user.name = 'Bob'
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 -> { user.name }, to: 'Bob' do
34
- user.name = 'Bob'
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
- assert_not_changed 'user.name' do
40
- user.update(attrs)
45
+ name = 'Allen'
46
+
47
+ assert_not_changed 'name' do
48
+ name = 'Allen'
41
49
  end
42
50
 
43
- assert_not_changed -> { user.name } do
44
- user.update(attrs)
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 'user.name', to: 'Allen' do
50
- user.name = 'Bob'
57
+ assert_not_changed 'name', to: 'Greg' do
58
+ name = 'Bob'
51
59
  end
52
60
 
53
- assert_not_changed -> { user.name }, to: 'Allen' do
54
- user.name = 'Bob'
61
+ assert_not_changed -> { name }, to: 'Greg' do
62
+ name = 'Bob'
55
63
  end
56
64
  end
57
65
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest_change_assertions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger