Sha256: 98ebddd0bb93b243f31328e1840b98cc989a3a0d83127e24219b82af0aea8cfb

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 KB

Contents

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

$:.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
  # 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_for_should do |actual|
    "expected\n#{strip_indentation(actual).inspect} to == \n#{strip_indentation(expected).inspect} but wasn't."
  end

  failure_message_for_should_not 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

9 entries across 9 versions & 1 rubygems

Version Path
couch_potato-1.4.0 spec/spec_helper.rb
couch_potato-1.3.0 spec/spec_helper.rb
couch_potato-1.2.0 spec/spec_helper.rb
couch_potato-1.1.4 spec/spec_helper.rb
couch_potato-1.1.2 spec/spec_helper.rb
couch_potato-1.1.1 spec/spec_helper.rb
couch_potato-1.1.0 spec/spec_helper.rb
couch_potato-1.0.1 spec/spec_helper.rb
couch_potato-1.0.0 spec/spec_helper.rb