mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Stop testing against columns unsupported by SQLite
This commit is contained in:
parent
72f60fae94
commit
74fa081ef5
2 changed files with 17 additions and 2 deletions
|
@ -5,12 +5,19 @@ module Tests
|
|||
class DatabaseConfiguration < SimpleDelegator
|
||||
ENVIRONMENTS = %w(development test production)
|
||||
|
||||
attr_reader :adapter_class
|
||||
|
||||
def self.for(database_name, adapter_name)
|
||||
config_class = DatabaseConfigurationRegistry.instance.get(adapter_name)
|
||||
config = config_class.new(database_name)
|
||||
new(config)
|
||||
end
|
||||
|
||||
def initialize(config)
|
||||
@adapter_class = config.class.to_s.split('::').last
|
||||
super(config)
|
||||
end
|
||||
|
||||
def to_hash
|
||||
ENVIRONMENTS.each_with_object({}) do |env, config_as_hash|
|
||||
config_as_hash[env] = inner_config_as_hash
|
||||
|
|
|
@ -52,9 +52,17 @@ module UnitTests
|
|||
table_block = lambda do |table|
|
||||
columns.each do |column_name, specification|
|
||||
if specification.is_a?(Hash)
|
||||
table.column column_name, specification[:type], specification[:options]
|
||||
column_type = specification[:type]
|
||||
column_options = specification.fetch(:options, {})
|
||||
else
|
||||
table.column column_name, specification
|
||||
column_type = specification
|
||||
column_options = {}
|
||||
end
|
||||
|
||||
begin
|
||||
table.__send__(column_type, column_name, column_options)
|
||||
rescue NoMethodError
|
||||
raise NoMethodError, "#{Tests::Database.instance.adapter_class} does not support :#{column_type} columns"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue