minitest_change_assertions 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 131d9f66d84ad2ae5b8b0f768c773337f7c0b2b8
4
+ data.tar.gz: ade67cd29e944b8facff11bb2446e5c89825f96a
5
+ SHA512:
6
+ metadata.gz: 465ddf9b61d4ef86f834dd84458ac6ad81d26a2db4945b110656cd99c7d7f400451598628862ff5d1fb1fc0835a9c01fdfd2eb05cbb99822fe66c5fab27f6024
7
+ data.tar.gz: 0fe8d8c2d274ef123a0ca2f8c5aa56d5ad6919738c29939c12158cccb4c2a2473ec6f2687c686071756d9c3c3bc0be63e2bf3ecabeafabb075546893185ac7ac
@@ -0,0 +1,5 @@
1
+ CHANGELOG
2
+ ---------
3
+
4
+ - **1.0.0 - UNRELEASED**
5
+ - Initial Gem Release
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2018 Weston Ganger
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # Minitest Change Assertions
2
+
3
+ <a href="https://badge.fury.io/rb/minitest_change_assertions" target="_blank"><img height="21" style='border:0px;height:21px;' border='0' src="https://badge.fury.io/rb/minitest_change_assertions.svg" alt="Gem Version"></a>
4
+ <a href='https://travis-ci.org/westonganger/minitest_change_assertions' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://api.travis-ci.org/westonganger/minitest_change_assertions.svg?branch=master' border='0' alt='Build Status' /></a>
5
+ <a href='https://rubygems.org/gems/minitest_change_assertions' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://ruby-gem-downloads-badge.herokuapp.com/minitest_change_assertions?label=rubygems&type=total&total_label=downloads&color=brightgreen' border='0' alt='RubyGems Downloads' /></a>
6
+ <a href='https://ko-fi.com/A5071NK' target='_blank'><img height='22' style='border:0px;height:22px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=a' border='0' alt='Buy Me a Coffee' /></a>
7
+
8
+ Provides assertions for your Minitest suite to determine if an object has been changed.
9
+
10
+ # Install
11
+
12
+ ```ruby
13
+ gem 'minitest_change_assertions'
14
+ ```
15
+
16
+ # Usage
17
+
18
+ ## `assert_changed`
19
+
20
+ ```ruby
21
+ assert_changed 'user.name' do
22
+ user.name = 'Bob'
23
+ end
24
+
25
+ assert_changed -> { user.name } do
26
+ user.name = 'Bob'
27
+ end
28
+
29
+ ### OR with optional :to argument
30
+
31
+ assert_changed 'user.name', to: 'Bob' do
32
+ user.name = 'Bob'
33
+ end
34
+
35
+ assert_changed -> { user.name }, to: 'Bob' do
36
+ user.name = 'Bob'
37
+ end
38
+ ```
39
+
40
+ ## `assert_not_changed`
41
+
42
+ ```ruby
43
+ assert_not_changed 'user.name' do
44
+ user.update(attrs)
45
+ end
46
+
47
+ assert_not_changed -> { user.name } do
48
+ user.update(attrs)
49
+ end
50
+
51
+ ### OR with optional :to argument
52
+
53
+ assert_not_changed 'user.name', to: 'Allen' do
54
+ user.name = 'Bob'
55
+ end
56
+
57
+ assert_not_changed -> { user.name }, to: 'Allen' do
58
+ user.name = 'Bob'
59
+ end
60
+ ```
61
+
62
+ # Credits
63
+ Created by [Weston Ganger](https://westonganger.com) - [@westonganger](https://github.com/westonganger)
64
+
65
+ For any consulting or contract work please contact me via my company website: [Solid Foundation Web Development](https://solidfoundationwebdev.com)
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/lib/minitest_change_assertions/version.rb')
2
+ require 'bundler/gem_tasks'
3
+
4
+ task :test do
5
+ require 'rake/testtask'
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << 'test'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ t.verbose = true
11
+ end
12
+ end
13
+
14
+ task :console do
15
+ require 'minitest_change_assertions'
16
+
17
+ require 'irb'
18
+ binding.irb
19
+ end
20
+
21
+ task default: :test
@@ -0,0 +1,9 @@
1
+ require 'minitest_change_assertions/version'
2
+
3
+ if defined?(Minitest::Assertions)
4
+ require 'minitest_change_assertions/assertions'
5
+ end
6
+
7
+ module MinitestChangeAssertions
8
+
9
+ end
@@ -0,0 +1,41 @@
1
+ Minitest::Assertions.module_eval do
2
+ def assert_changed(expression, opts={}, &block)
3
+ if expression.respond_to?(:call)
4
+ e = expression
5
+ else
6
+ e = lambda{ block.binding.eval(expression) }
7
+ end
8
+
9
+ if opts.key?(:to)
10
+ expected = opts[:to]
11
+ elsif opts.key?('to')
12
+ expected = opts['to']
13
+ else
14
+ expected = e.call
15
+ end
16
+
17
+ block.call
18
+
19
+ refute_equal expected, e.call
20
+ end
21
+
22
+ def assert_not_changed(expression, opts={}, &block)
23
+ if expression.respond_to?(:call)
24
+ e = expression
25
+ else
26
+ e = lambda{ block.binding.eval(expression) }
27
+ end
28
+
29
+ if opts.key?(:to)
30
+ expected = opts[:to]
31
+ elsif opts.key?('to')
32
+ expected = opts['to']
33
+ else
34
+ expected = e.call
35
+ end
36
+
37
+ block.call
38
+
39
+ assert_equal expected, e.call
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module MinitestChangeAssertions
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'minitest'
7
+ require 'minitest/autorun'
8
+
9
+ require 'minitest_change_assertions'
10
+
11
+ class AssertionsTest < MiniTest::Test
12
+ def setup
13
+ end
14
+
15
+ def teardown
16
+ end
17
+
18
+ def test_assert_changed
19
+ assert_changed 'user.name' do
20
+ user.name = 'Bob'
21
+ end
22
+
23
+ assert_changed -> { user.name } do
24
+ user.name = 'Bob'
25
+ end
26
+
27
+ ### OR with optional :to argument
28
+
29
+ assert_changed 'user.name', to: 'Bob' do
30
+ user.name = 'Bob'
31
+ end
32
+
33
+ assert_changed -> { user.name }, to: 'Bob' do
34
+ user.name = 'Bob'
35
+ end
36
+ end
37
+
38
+ def test_assert_not_changed
39
+ assert_not_changed 'user.name' do
40
+ user.update(attrs)
41
+ end
42
+
43
+ assert_not_changed -> { user.name } do
44
+ user.update(attrs)
45
+ end
46
+
47
+ ### OR with optional :to argument
48
+
49
+ assert_not_changed 'user.name', to: 'Allen' do
50
+ user.name = 'Bob'
51
+ end
52
+
53
+ assert_not_changed -> { user.name }, to: 'Allen' do
54
+ user.name = 'Bob'
55
+ end
56
+ end
57
+
58
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest_change_assertions
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Weston Ganger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Provides assertions for your Minitest suite to determine if an object
56
+ has been changed.
57
+ email: weston@westonganger.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG.md
63
+ - LICENSE
64
+ - README.md
65
+ - Rakefile
66
+ - lib/minitest_change_assertions.rb
67
+ - lib/minitest_change_assertions/assertions.rb
68
+ - lib/minitest_change_assertions/version.rb
69
+ - test/assertions_test.rb
70
+ homepage: https://github.com/westonganger/minitest_change_assertions
71
+ licenses: []
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 1.9.3
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.6.11
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Provides assertions for your Minitest suite to determine if an object has
93
+ been changed.
94
+ test_files:
95
+ - test/assertions_test.rb