Skip to content

Instantly share code, notes, and snippets.

@diogob
Created October 22, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogob/8c7b00ab992bd217c429 to your computer and use it in GitHub Desktop.
Save diogob/8c7b00ab992bd217c429 to your computer and use it in GitHub Desktop.
require File.dirname(File.expand_path(__FILE__)) + '/test_helper'
describe AttributeNormalizer do
let(:klass) do
Class.new do
include AttributeNormalizer
end
end
describe '.normalize_attributes' do
it 'should exist when included' do
expect(klass).to respond_to(:normalize_attributes)
end
end
describe '.normalize_attribute' do
it 'should exist when included' do
expect(klass).to respond_to(:normalize_attribute)
end
end
describe '.table_exists?' do
it 'should not fail due to database exceptions' do
class PGError < RuntimeError; end
Class.new(ActiveRecord::Base) do
def self.table_exists?
raise PGError, "FATAL: something bad happened trying to probe for table existence"
end
include AttributeNormalizer
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment