1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
paper-trail-gem--paper_trail/spec/paper_trail_spec.rb

58 lines
1.5 KiB
Ruby

require 'spec_helper'
describe "PaperTrail RSpec Helper" do
context 'default' do
it 'should have versioning off by default' do
::PaperTrail.should_not be_enabled
end
it 'should turn versioning on in a `with_versioning` block' do
::PaperTrail.should_not be_enabled
with_versioning do
::PaperTrail.should be_enabled
end
::PaperTrail.should_not be_enabled
end
end
context '`versioning: true`', :versioning => true do
it 'should have versioning on by default' do
::PaperTrail.should be_enabled
end
it 'should keep versioning on after a with_versioning block' do
::PaperTrail.should be_enabled
with_versioning do
::PaperTrail.should be_enabled
end
::PaperTrail.should be_enabled
end
end
context '`with_versioning` block at class level' do
it { ::PaperTrail.should_not be_enabled }
with_versioning do
it 'should have versioning on by default' do
::PaperTrail.should be_enabled
end
end
it 'should not leak the `enabled?` state into successive tests' do
::PaperTrail.should_not be_enabled
end
end
describe :whodunnit do
before(:all) { ::PaperTrail.whodunnit = 'foobar' }
it "should get set to `nil` by default" do
::PaperTrail.whodunnit.should be_nil
end
end
describe :controller_info do
before(:all) { ::PaperTrail.controller_info = {:foo => 'bar'} }
it "should get set to an empty hash before each test" do
::PaperTrail.controller_info.should == {}
end
end
end