Sha256: 8235ff0577d7633278ef5912eead5ab6e2efd47abb94cc3fcf8e6e7ae37f47e6

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require "rspec/core"
require "rspec/matchers"
require "paper_trail/frameworks/rspec/helpers"

RSpec.configure do |config|
  config.include ::PaperTrail::RSpec::Helpers::InstanceMethods
  config.extend ::PaperTrail::RSpec::Helpers::ClassMethods

  config.before(:each) do
    ::PaperTrail.enabled = false
    ::PaperTrail.enabled_for_controller = true
    ::PaperTrail.whodunnit = nil
    ::PaperTrail.controller_info = {} if defined?(::Rails) && defined?(::RSpec::Rails)
  end

  config.before(:each, versioning: true) do
    ::PaperTrail.enabled = true
  end
end

RSpec::Matchers.define :be_versioned do
  # check to see if the model has `has_paper_trail` declared on it
  match { |actual| actual.is_a?(::PaperTrail::Model::InstanceMethods) }
end

RSpec::Matchers.define :have_a_version_with do |attributes|
  # check if the model has a version with the specified attributes
  match { |actual| actual.versions.where_object(attributes).any? }
end

RSpec::Matchers.define :have_a_version_with_changes do |attributes|
  # check if the model has a version changes with the specified attributes
  match { |actual| actual.versions.where_object_changes(attributes).any? }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paper_trail-6.0.2 lib/paper_trail/frameworks/rspec.rb
paper_trail-6.0.1 lib/paper_trail/frameworks/rspec.rb
paper_trail-6.0.0 lib/paper_trail/frameworks/rspec.rb