diff options
author | Bryan Helmkamp <bryan@brynary.com> | 2008-04-15 01:24:15 -0400 |
---|---|---|
committer | Bryan Helmkamp <bryan@brynary.com> | 2008-04-15 01:24:15 -0400 |
commit | 5a2d4f5475b8a040e2ed2da826afe50f0b3824c7 (patch) | |
tree | 1f598a69220e5c7c9c97172dafd590ad03af3bfe /spec/fakes | |
parent | 722623dab397427df7a99b7aeefe4356cadcce25 (diff) | |
download | rails-5a2d4f5475b8a040e2ed2da826afe50f0b3824c7.tar.gz rails-5a2d4f5475b8a040e2ed2da826afe50f0b3824c7.tar.bz2 rails-5a2d4f5475b8a040e2ed2da826afe50f0b3824c7.zip |
Fake database implementation. MySQL not required to run the tests
Diffstat (limited to 'spec/fakes')
-rw-r--r-- | spec/fakes/database.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/fakes/database.rb b/spec/fakes/database.rb new file mode 100644 index 0000000000..1b73986e0b --- /dev/null +++ b/spec/fakes/database.rb @@ -0,0 +1,48 @@ +class FakeDatabase + def self.connection + @@conn ||= FakeConnection.new + end +end + +class FakeConnection + include ActiveRecord::ConnectionAdapters::Quoting + + def columns(table_name, comment) + case table_name + when "users" + [ + FakeColumn.new("id", :integer), + FakeColumn.new("name", :string) + ] + when "photos" + [ + FakeColumn.new("id", :integer), + FakeColumn.new("user_id", :integer), + FakeColumn.new("camera_id", :integer) + ] + else + raise "unknown table: #{table_name}" + end + end + + def select_all(*args) + [] + end + + def quote_column_name(column_name) + "`#{column_name}`" + end + + def quote_table_name(table_name) + "`#{table_name}`" + end +end + +class FakeColumn + attr_reader :name, :type + + def initialize(name, type) + @name = name + @type = type + end +end
\ No newline at end of file |