From 49d119ae84bbb7cd180ca855cf48997dc731554c Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sat, 16 May 2009 21:13:32 -0400 Subject: Adding spec:mysql and spec:sqlite3 tasks --- spec/spec_helper.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'spec/spec_helper.rb') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce539b6ffa..8d515d66f1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,10 +11,25 @@ require 'arel' Dir["#{dir}/#{helper}/*"].each { |m| require "#{dir}/#{helper}/#{File.basename(m)}" } end +module AdapterGuards + def adapter_is(name) + yield if name.to_s == adapter_name + end + + def adapter_is_not(name) + yield if name.to_s != adapter_name + end + + def adapter_name + Arel::Table.engine.connection.class.name.underscore.split("/").last.gsub(/_adapter/, '') + end +end + Spec::Runner.configure do |config| - config.include(BeLikeMatcher, HashTheSameAsMatcher, DisambiguateAttributesMatcher) + config.include BeLikeMatcher, HashTheSameAsMatcher, DisambiguateAttributesMatcher + config.include AdapterGuards config.mock_with :rr config.before do - Arel::Table.engine = Arel::Engine.new(Fake::Engine.new) + Arel::Table.engine = Arel::Engine.new(ActiveRecord::Base) end end -- cgit v1.2.3 From bdca9ed42ffea10aa6989ea3ecebedb424fa01ed Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 17 May 2009 14:20:29 -0400 Subject: moved sql related code to its own engine area Conflicts: lib/arel/engine.rb lib/arel/extensions/object.rb lib/arel/predicates.rb lib/arel/primitives/attribute.rb lib/arel/primitives/expression.rb lib/arel/primitives/value.rb lib/arel/relations/operations/join.rb lib/arel/relations/relation.rb lib/arel/relations/utilities/externalization.rb lib/arel/relations/utilities/nil.rb lib/arel/relations/writes/delete.rb lib/arel/relations/writes/insert.rb lib/arel/relations/writes/update.rb spec/arel/unit/relations/skip_spec.rb spec/arel/unit/relations/take_spec.rb spec/spec_helper.rb --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/spec_helper.rb') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8d515d66f1..6a9a2ef23c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,6 +30,6 @@ Spec::Runner.configure do |config| config.include AdapterGuards config.mock_with :rr config.before do - Arel::Table.engine = Arel::Engine.new(ActiveRecord::Base) + Arel::Table.engine = Arel::Sql::Engine.new(ActiveRecord::Base) end end -- cgit v1.2.3 From d2988420fc6dd91ca751d96ed648fd1ed52ce342 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 17 May 2009 17:53:40 -0400 Subject: Added PostgreSQL to build --- spec/spec_helper.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'spec/spec_helper.rb') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6a9a2ef23c..beb634fbd3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,15 +13,27 @@ end module AdapterGuards def adapter_is(name) + verify_adapter_name(name) yield if name.to_s == adapter_name end def adapter_is_not(name) + verify_adapter_name(name) yield if name.to_s != adapter_name end def adapter_name - Arel::Table.engine.connection.class.name.underscore.split("/").last.gsub(/_adapter/, '') + name = ActiveRecord::Base.configurations["unit"][:adapter] + verify_adapter_name(name) + name + end + + def verify_adapter_name(name) + raise "Invalid adapter name: #{name}" unless valid_adapters.include?(name.to_s) + end + + def valid_adapters + %w[mysql postgresql sqlite3] end end -- cgit v1.2.3