Class: MockDatabase

Inherits:
Sequel::Database show all
Defined in:
lib/sequel/spec/core/spec_helper.rb,
lib/sequel/spec/model/spec_helper.rb,
lib/sequel/spec/extensions/spec_helper.rb

Constant Summary collapse

@@quote_identifiers =
false

Constants inherited from Sequel::Database

Sequel::Database::ADAPTERS, Sequel::Database::AUTOINCREMENT, Sequel::Database::CASCADE, Sequel::Database::COMMA_SEPARATOR, Sequel::Database::MSSQL_DEFAULT_RE, Sequel::Database::MYSQL_TIMESTAMP_RE, Sequel::Database::NOT_NULL, Sequel::Database::NO_ACTION, Sequel::Database::NULL, Sequel::Database::POSTGRES_DEFAULT_RE, Sequel::Database::PRIMARY_KEY, Sequel::Database::RESTRICT, Sequel::Database::SET_DEFAULT, Sequel::Database::SET_NULL, Sequel::Database::SQL_BEGIN, Sequel::Database::SQL_COMMIT, Sequel::Database::SQL_RELEASE_SAVEPOINT, Sequel::Database::SQL_ROLLBACK, Sequel::Database::SQL_ROLLBACK_TO_SAVEPOINT, Sequel::Database::SQL_SAVEPOINT, Sequel::Database::STRING_DEFAULT_RE, Sequel::Database::TEMPORARY, Sequel::Database::TRANSACTION_BEGIN, Sequel::Database::TRANSACTION_COMMIT, Sequel::Database::TRANSACTION_ROLLBACK, Sequel::Database::UNDERSCORE, Sequel::Database::UNIQUE, Sequel::Database::UNSIGNED

Instance Attribute Summary collapse

Attributes inherited from Sequel::Database

#default_schema, #loggers, #opts, #pool, #prepared_statements

Instance Method Summary collapse

Methods inherited from Sequel::Database

#<<, #[], adapter_class, adapter_scheme, #add_column, #add_index, #alter_table, #call, #cast_type_literal, connect, #connect, #create_or_replace_view, #create_table, #create_table!, #create_table?, #create_view, #database_type, #disconnect, #drop_column, #drop_index, #drop_table, #drop_view, #dump_indexes_migration, #dump_schema_migration, #dump_table_schema, #execute_ddl, #execute_dui, #execute_insert, #fetch, #from, #get, identifier_input_method, #identifier_input_method, identifier_input_method=, #identifier_input_method=, #identifier_output_method, identifier_output_method, identifier_output_method=, #identifier_output_method=, #initialize, #inspect, #literal, #log_info, #logger=, #query, #quote_identifiers=, quote_identifiers=, #quote_identifiers?, #rename_column, #rename_table, #run, #select, #serial_primary_key_options, #set_column_default, #set_column_type, single_threaded=, #single_threaded?, #supports_savepoints?, #synchronize, #table_exists?, #test_connection, #typecast_value, #uri, #url

Methods included from Sequel::Metaprogramming

#meta_def

Constructor Details

This class inherits a constructor from Sequel::Database

Instance Attribute Details

#sqlsObject (readonly)

Returns the value of attribute sqls


30
31
32
# File 'lib/sequel/spec/core/spec_helper.rb', line 30

def sqls
  @sqls
end

Instance Method Details

#dataset(opts = nil) ⇒ Object


43
# File 'lib/sequel/spec/core/spec_helper.rb', line 43

def dataset; MockDataset.new(self); end

#execute(sql, opts = {}) ⇒ Object


32
33
34
35
# File 'lib/sequel/spec/core/spec_helper.rb', line 32

def execute(sql, opts={})
  @sqls ||= []
  @sqls << sql
end

#resetObject


37
38
39
# File 'lib/sequel/spec/core/spec_helper.rb', line 37

def reset
  @sqls = []
end

#schema(table_name, opts) ⇒ Object


50
51
52
53
54
55
56
# File 'lib/sequel/spec/model/spec_helper.rb', line 50

def schema(table_name, opts)
  if table_name
    [[:id, {:primary_key=>true}]]
  else
    {table_name=>[[:id, {:primary_key=>true}]]}
  end
end

#transaction(opts = {}) ⇒ Object


41
# File 'lib/sequel/spec/core/spec_helper.rb', line 41

def transaction(opts={}); yield; end