Sha256: 1c525721b66eb4be33c335e7675c273894b80864fd3a4c5ec0e03b6c936e8c24

Contents?: true

Size: 1.45 KB

Versions: 11

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'rubygems'
require 'rspec'
require 'time'
require 'active_support'
require 'timecop'

$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')

require 'couch_potato'

CouchPotato::Config.database_name = ENV['DATABASE'] || 'couch_potato_test'

# silence deprecation warnings from ActiveModel as the Spec uses Errors#on
begin
  ActiveSupport::Deprecation.silenced = true
rescue StandardError
  # ignore errors, ActiveSupport is probably not installed
end

class Child
  include CouchPotato::Persistence

  property :text
end

class Comment
  include CouchPotato::Persistence

  validates_presence_of :title

  property :title
end

class BigDecimalContainer
  include CouchPotato::Persistence

  property :number, type: BigDecimal
end

def recreate_db
  CouchPotato.couchrest_database.recreate!
end
recreate_db

RSpec::Matchers.define :string_matching do |regex|
  match do |string|
    string =~ regex
  end
end

RSpec::Matchers.define :eql_ignoring_indentation do |expected|
  match do |string|
    strip_indentation(string) == strip_indentation(expected)
  end

  failure_message do |actual|
    "expected\n#{strip_indentation(actual).inspect} to == \n#{strip_indentation(expected).inspect} but wasn't."
  end

  failure_message_when_negated do |actual|
    "expected\n#{strip_indentation(actual).inspect} to not == \n#{strip_indentation(expected).inspect} but wasn."
  end

  def strip_indentation(string)
    string.gsub(/^\s+/m, '')
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
couch_potato-1.17.0 spec/spec_helper.rb
couch_potato-1.16.0 spec/spec_helper.rb
couch_potato-1.15.0 spec/spec_helper.rb
couch_potato-1.14.0 spec/spec_helper.rb
couch_potato-1.13.0 spec/spec_helper.rb
couch_potato-1.12.1 spec/spec_helper.rb
couch_potato-1.12.0 spec/spec_helper.rb
couch_potato-1.11.0 spec/spec_helper.rb
couch_potato-1.10.1 spec/spec_helper.rb
couch_potato-1.10.0 spec/spec_helper.rb
couch_potato-1.9.0 spec/spec_helper.rb