Module: CouchRestRails::Tests

Extended by:
Tests
Included in:
Tests
Defined in:
lib/couch_rest_rails/tests.rb

Instance Method Summary collapse

Instance Method Details

#reset_fixturesObject



21
22
23
24
# File 'lib/couch_rest_rails/tests.rb', line 21

def reset_fixtures
  CouchRestRails::Database.delete("*") unless fixtures_loaded.empty?
  fixtures_loaded.clear
end

#setup(database_name = '*', opts = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/couch_rest_rails/tests.rb', line 8

def setup(database_name = '*', opts = {})
  res = ''
  ENV['RAILS_ENV'] = CouchRestRails.test_environment
  unless opts[:skip_if_fixtures_loaded] && fixtures_loaded.include?(database_name)
    res += CouchRestRails::Database.delete(database_name, opts)
    res += CouchRestRails::Database.create(database_name, opts)
    res += CouchRestRails::Fixtures.load(database_name, opts)
    res += CouchRestRails::Views.push(database_name, opts)
    fixtures_loaded << database_name
  end
  res
end

#teardown(database_name = "*") ⇒ Object



26
27
28
29
30
# File 'lib/couch_rest_rails/tests.rb', line 26

def teardown(database_name = "*")
  ENV['RAILS_ENV'] = CouchRestRails.test_environment
  CouchRestRails::Database.delete(database_name)
  fixtures_loaded.delete(database_name)
end