Skip to content

Commit

Permalink
Tweak syntax for PR from #394 to improve performance; Update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
batter committed Aug 29, 2014
1 parent 1b5e9ec commit e73b7f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
## 3.1.0 (Unreleased)

- [#394](https://github.com/airblade/paper_trail/pull/394) - Add RSpec matcher `have_a_version_with` for easier testing.


## 3.0.4

- [#401](https://github.com/airblade/paper_trail/issues/401) / [#406](https://github.com/airblade/paper_trail/issues/406)
Expand Down
10 changes: 2 additions & 8 deletions lib/paper_trail/frameworks/rspec.rb
Expand Up @@ -25,11 +25,5 @@

RSpec::Matchers.define :have_a_version_with do |attributes|
# check if the model has a version with the specified attributes
match do |actual|
mathing_version = actual.versions.select do |version|
object = version.object ? PaperTrail.serializer.load(version.object) : {}
(HashWithIndifferentAccess.new(attributes).to_a - object.to_a).empty?
end
mathing_version.present?
end
end
match { |actual| actual.versions.where_object(attributes).any? }
end

0 comments on commit e73b7f6

Please sign in to comment.