Skip to content

Commit

Permalink
Add rspec matcher: act_as_paranoid
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Connolly authored and radar committed Mar 20, 2014
1 parent 236861d commit f300ef0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,5 @@ def paranoia_column
self.class.paranoia_column
end
end

require 'paranoia/rspec' if defined? RSpec
9 changes: 9 additions & 0 deletions lib/paranoia/rspec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rspec/expectations'

# Validate the subject's class did call "acts_as_paranoid"
RSpec::Matchers.define :act_as_paranoid do
match { |subject| subject.class.ancestors.include?(Paranoia) }

failure_message_for_should { "#{subject.class} should use `acts_as_paranoid`" }
failure_message_for_should_not { "#{subject.class} should not use `acts_as_paranoid`" }
end

0 comments on commit f300ef0

Please sign in to comment.