Module: NullDB::RSpec::NullifiedDatabase

Defined in:
lib/nulldb_rspec.rb

Defined Under Namespace

Classes: HaveExecuted

Constant Summary collapse

NullDBAdapter =
ActiveRecord::ConnectionAdapters::NullDBAdapter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.contextually_nullify_database(context) ⇒ Object



48
49
50
# File 'lib/nulldb_rspec.rb', line 48

def self.contextually_nullify_database(context)
  nullify_database(context)
end

.globally_nullify_databaseObject



39
40
41
42
43
44
45
46
# File 'lib/nulldb_rspec.rb', line 39

def self.globally_nullify_database
  block = lambda { |config| nullify_database(config) }
  if defined?(RSpec)
    RSpec.configure(&block)
  else
    Spec::Runner.configure(&block)
  end
end

Instance Method Details

#have_executed(entry_point) ⇒ Object

A matcher for asserting that database statements have (or have not) been executed. Usage:

ActiveRecord::Base.connection.should have_executed(:insert)

The types of statement that can be matched mostly mirror the public operations available in ActiveRecord::ConnectionAdapters::DatabaseStatements:

  • :select_one

  • :select_all

  • :select_value

  • :insert

  • :update

  • :delete

  • :execute

There is also a special :anything symbol that will match any operation.



69
70
71
# File 'lib/nulldb_rspec.rb', line 69

def have_executed(entry_point)
  HaveExecuted.new(entry_point)
end