This repository has been archived by the owner on Oct 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add find_duplicates method to Rails, remove dedupe method from Rails,…
… add minitest assertions `assert_changed` and `assert_not_changed`
- Loading branch information
1 parent
16f4878
commit 2c5d288
Showing
9 changed files
with
183 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
|
||
gem 'minitest' | ||
|
||
group :rails do | ||
gem 'rails', '>= 3.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
if defined?(Minitest::Assertions) | ||
|
||
enabled = Rearmed.enabled_patches[:minitest] == true | ||
|
||
Minitest::Assertions.module_eval do | ||
|
||
if enabled || Rearmed.dig(Rearmed.enabled_patches, :minitest, :assert_changed) | ||
def assert_changed(expression, &block) | ||
#unless expression.respond_to?(:call) | ||
# expression = lambda{ eval(expression, block.binding) } | ||
# expression = lambda{ block.binding.eval("#{expression}") } | ||
#end | ||
old = expression.call | ||
block.call | ||
refute_equal old, expression.call | ||
end | ||
end | ||
|
||
if enabled || Rearmed.dig(Rearmed.enabled_patches, :minitest, :assert_not_changed) | ||
def assert_not_changed(expression, &block) | ||
unless expression.respond_to?(:call) | ||
expression = lambda{ eval(expression, block.binding) } | ||
end | ||
old = expression.call | ||
block.call | ||
assert_equal old, expression.call | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Rearmed | ||
VERSION = "1.1.1" | ||
VERSION = "1.2.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters