acts_as_fu 0.0.2 → 0.0.3
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.
- data/lib/acts_as_fu.rb +3 -5
- data/lib/acts_as_fu/{helper.rb → base.rb} +16 -10
- metadata +3 -4
- data/lib/acts_as_fu/constants.rb +0 -2
data/lib/acts_as_fu.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
%w(rubygems activerecord).each { |lib| require lib }
|
2
|
+
|
3
|
+
RAILS_ROOT = File.join(File.dirname(__FILE__), '..') unless defined?(RAILS_ROOT)
|
4
|
+
RAILS_ENV = 'test' unless defined?(RAILS_ENV)
|
5
|
+
|
1
6
|
module ActsAsFu
|
2
7
|
class << self
|
3
8
|
attr_reader :log
|
@@ -5,12 +10,13 @@ module ActsAsFu
|
|
5
10
|
def connect!(config={})
|
6
11
|
@log = ""
|
7
12
|
ActiveRecord::Base.logger = Logger.new(StringIO.new(log))
|
13
|
+
ActiveRecord::Base.connection.disconnect! rescue nil
|
8
14
|
ActiveRecord::Base.establish_connection(config)
|
9
15
|
end
|
10
16
|
end
|
11
17
|
|
12
18
|
def build_model(name, options={}, &block)
|
13
|
-
connect!
|
19
|
+
connect! unless connected?
|
14
20
|
|
15
21
|
super_class = options[:superclass] || begin
|
16
22
|
ActiveRecord::Base.connection.create_table(name, :force => true) { }
|
@@ -30,18 +36,18 @@ module ActsAsFu
|
|
30
36
|
Object.const_set(klass_name, klass)
|
31
37
|
|
32
38
|
model_eval(klass, &block)
|
39
|
+
klass
|
33
40
|
end
|
34
41
|
|
35
42
|
def connect!
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
43
|
+
ActsAsFu.connect!({
|
44
|
+
:adapter => "sqlite3",
|
45
|
+
:database => ":memory:"
|
46
|
+
})
|
47
|
+
end
|
48
|
+
|
49
|
+
def connected?
|
50
|
+
ActiveRecord::Base.connected?
|
45
51
|
end
|
46
52
|
|
47
53
|
def model_eval(klass, &block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Nakajima
|
@@ -33,8 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- lib/acts_as_fu
|
35
35
|
- lib/acts-as-fu.rb
|
36
|
-
- lib/acts_as_fu/
|
37
|
-
- lib/acts_as_fu/helper.rb
|
36
|
+
- lib/acts_as_fu/base.rb
|
38
37
|
- lib/acts_as_fu.rb
|
39
38
|
has_rdoc: true
|
40
39
|
homepage:
|
@@ -58,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements: []
|
59
58
|
|
60
59
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.3.
|
60
|
+
rubygems_version: 1.3.1
|
62
61
|
signing_key:
|
63
62
|
specification_version: 2
|
64
63
|
summary: Generate ActiveRecord models on the fly for your tests
|
data/lib/acts_as_fu/constants.rb
DELETED