dkastner-moneta 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,9 +13,12 @@ module Moneta
13
13
  @options = options
14
14
  unless self.class.const_defined?('Store')
15
15
  self.class.const_set('Store', Class.new(::ActiveRecord::Base)) # this prevents loading issues when active_record gem is unavailable
16
+ Store.set_table_name(@options[:table] || 'moneta_store')
17
+ end
18
+
19
+ if @options[:connection]
20
+ Store.establish_connection @options[:connection]
16
21
  end
17
- Store.establish_connection(@options[:connection] || raise("Must specify :connection"))
18
- Store.set_table_name(@options[:table] || 'moneta_store')
19
22
  end
20
23
 
21
24
  def migrate
@@ -1,3 +1,3 @@
1
1
  module Moneta
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -4,18 +4,34 @@ require 'moneta/adapters/active_record'
4
4
 
5
5
  if defined?(ActiveRecord)
6
6
  describe 'Moneta::ActiveRecord' do
7
- before(:each) do
8
- @cache = Moneta::Adapters::ActiveRecord.new(:connection => {
9
- :adapter => 'sqlite3',
10
- :database => 'reports_test.sqlite3'
11
- })
12
- @cache.migrate
13
- @cache.clear
14
- end
15
7
  after :all do
16
8
  FileUtils.rm_f File.expand_path('../reports_test.sqlite3', File.dirname(__FILE__))
17
9
  end
18
10
 
19
- it_should_behave_like "a read/write Moneta cache"
11
+ context 'with connection option set' do
12
+ before(:each) do
13
+ @cache = Moneta::Adapters::ActiveRecord.new(:connection => {
14
+ :adapter => 'sqlite3',
15
+ :database => 'reports_test.sqlite3'
16
+ })
17
+ @cache.migrate
18
+ @cache.clear
19
+ end
20
+
21
+ it_should_behave_like "a read/write Moneta cache"
22
+ end
23
+
24
+ context 'using preexisting ActiveRecord connection' do
25
+ describe '#initialize' do
26
+ it 'uses an existing connection' do
27
+ ActiveRecord::Base.establish_connection :adapter => 'sqlite3',
28
+ :database => 'reports_test.sqlite3'
29
+
30
+ cache = Moneta::Adapters::ActiveRecord.new
31
+ cache.migrate
32
+ Moneta::Adapters::ActiveRecord::Store.table_exists?.should be_true
33
+ end
34
+ end
35
+ end
20
36
  end
21
37
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Yehuda Katz
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- hash: -3802511716438480578
139
+ hash: -2240309769819464001
140
140
  segments:
141
141
  - 0
142
142
  version: "0"
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
- hash: -3802511716438480578
148
+ hash: -2240309769819464001
149
149
  segments:
150
150
  - 0
151
151
  version: "0"