Sha256: 72a807fea46f1718bf96f5b22c6dc029962a157b9d8de3527bb1ca132435bcc3

Contents?: true

Size: 1.83 KB

Versions: 7

Compression:

Stored size: 1.83 KB

Contents

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

    context "error within `with_versioning` block" do
      it "should revert the value of `PaperTrail.enabled?` to it's previous state" do
        ::PaperTrail.should_not be_enabled
        expect { with_versioning { raise } }.to raise_error
        ::PaperTrail.should_not be_enabled
      end
    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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
paper_trail-3.0.9 spec/paper_trail_spec.rb
paper_trail-3.0.8 spec/paper_trail_spec.rb
paper_trail-3.0.7 spec/paper_trail_spec.rb
paper_trail-3.0.6 spec/paper_trail_spec.rb
paper_trail-3.0.5 spec/paper_trail_spec.rb
paper_trail-3.0.2 spec/paper_trail_spec.rb
paper_trail-3.0.1 spec/paper_trail_spec.rb