I am trying an example using paper_trail v2.6.3 in Rails 3 by following the Github Documentation for paper_trail. I want to write a spec for a model that lets me check if its versioned under paper_trail something like:
it { should be_trailed }
and be_trailed should be a custom rspec matcher that should check if the model is versioned or not.
How do I write the spec?
P.S. I do not want to revert versions. I just want to check if its versioned.
I am using it on the demo_app following Michael Hartl's Rails Tutorial:
class User < ActiveRecord::Base
attr_accessible :email, :name
has_paper_trail
end
If you're asking how to write RSpec matchers, the documentation is here.
If you're asking what the matcher should do, you could try checking to see if the object responds to the methods provided by paper_trail. For example
RSpec::Matchers.define :be_trailed do
match do |actual|
actual.respond_to?(:versions)
end
end