Skip to content

Commit

Permalink
refactor spec to match other spec style
Browse files Browse the repository at this point in the history
  • Loading branch information
doits committed Nov 5, 2021
1 parent c36333c commit 0afd7f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
25 changes: 15 additions & 10 deletions spec/mobility/backends/active_record/container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@
include_dup_examples 'ContainerPost'
include_cache_key_examples 'ContainerPost'

it 'does not change translations on access' do
post = ContainerPost.new

expect { post.title }.not_to change { post.translations }.from({})
end

it 'does not mix up dirty tracking on access' do
post = ContainerPost.new
it 'does not change translations and dirty tracking' do
post = ContainerPost.create!

aggregate_failures "on access" do
expect { post.title }
.to not_change { post.translations }.from({})
.and not_change { post.changes }.from({})
.and not_change { post.changed? }.from(false)
end

expect { post.title }.not_to change { post.changes }.from({})
expect(post.changed?).to be(false)
aggregate_failures "on reload" do
expect { post.reload }
.to not_change { post.translations }.from({})
.and not_change { post.changes }.from({})
.and not_change { post.changed? }.from(false)
end
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/support/matchers/not_change.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RSpec::Matchers.define_negated_matcher :not_change, :change

0 comments on commit 0afd7f8

Please sign in to comment.