activerecord-simpledb-adapter 0.4.5 → 0.4.6
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/Gemfile +1 -1
- data/Gemfile.lock +9 -10
- data/activerecord-simpledb-adapter.gemspec +6 -20
- data/lib/active_record/connection_adapters/simpledb_adapter.rb +3 -0
- data/lib/active_record/connection_adapters/simpledb_adapter/base.rb +0 -26
- data/lib/active_record/connection_adapters/simpledb_adapter/defaults.rb +35 -0
- metadata +11 -37
- data/spec/active_record/batch_spec.rb +0 -91
- data/spec/active_record/connection_adapters/simpledb_adapter_spec.rb +0 -28
- data/spec/active_record/core_actions_spec.rb +0 -47
- data/spec/active_record/defaults_spec.rb +0 -35
- data/spec/active_record/locking_spec.rb +0 -50
- data/spec/active_record/offset_spec.rb +0 -24
- data/spec/active_record/record_attributes_spec.rb +0 -111
- data/spec/active_record/validates_spec.rb +0 -36
- data/spec/active_record/where_spec.rb +0 -27
- data/spec/assets/db/seeds.rb +0 -1
- data/spec/generators/model_spec.rb +0 -17
- data/spec/spec_helper.rb +0 -66
- data/spec/tasks/rake_spec.rb +0 -79
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -28,10 +28,9 @@ GEM
|
|
|
28
28
|
activemodel (= 3.0.7)
|
|
29
29
|
activesupport (= 3.0.7)
|
|
30
30
|
activesupport (3.0.7)
|
|
31
|
-
arel (2.0.
|
|
32
|
-
awesome_print (0.
|
|
33
|
-
aws (2.
|
|
34
|
-
activesupport
|
|
31
|
+
arel (2.0.10)
|
|
32
|
+
awesome_print (0.4.0)
|
|
33
|
+
aws (2.5.3)
|
|
35
34
|
http_connection
|
|
36
35
|
uuidtools
|
|
37
36
|
xml-simple
|
|
@@ -45,18 +44,18 @@ GEM
|
|
|
45
44
|
git (1.2.5)
|
|
46
45
|
http_connection (1.4.1)
|
|
47
46
|
i18n (0.5.0)
|
|
48
|
-
jeweler (1.
|
|
47
|
+
jeweler (1.6.0)
|
|
49
48
|
bundler (~> 1.0.0)
|
|
50
49
|
git (>= 1.2.5)
|
|
51
50
|
rake
|
|
52
|
-
mail (2.2.
|
|
51
|
+
mail (2.2.19)
|
|
53
52
|
activesupport (>= 2.3.6)
|
|
54
53
|
i18n (>= 0.4.0)
|
|
55
54
|
mime-types (~> 1.16)
|
|
56
55
|
treetop (~> 1.4.8)
|
|
57
56
|
mime-types (1.16)
|
|
58
57
|
polyglot (0.3.1)
|
|
59
|
-
rack (1.2.
|
|
58
|
+
rack (1.2.3)
|
|
60
59
|
rack-mount (0.6.14)
|
|
61
60
|
rack (>= 1.0.0)
|
|
62
61
|
rack-test (0.5.7)
|
|
@@ -74,7 +73,7 @@ GEM
|
|
|
74
73
|
activesupport (= 3.0.7)
|
|
75
74
|
rake (>= 0.8.7)
|
|
76
75
|
thor (~> 0.14.4)
|
|
77
|
-
rake (0.
|
|
76
|
+
rake (0.9.0)
|
|
78
77
|
rcov (0.9.9)
|
|
79
78
|
rspec (2.3.0)
|
|
80
79
|
rspec-core (~> 2.3.0)
|
|
@@ -89,7 +88,7 @@ GEM
|
|
|
89
88
|
thor (0.14.6)
|
|
90
89
|
treetop (1.4.9)
|
|
91
90
|
polyglot (>= 0.3.1)
|
|
92
|
-
tzinfo (0.3.
|
|
91
|
+
tzinfo (0.3.27)
|
|
93
92
|
uuidtools (2.1.2)
|
|
94
93
|
xml-simple (1.0.15)
|
|
95
94
|
|
|
@@ -103,7 +102,7 @@ DEPENDENCIES
|
|
|
103
102
|
aws
|
|
104
103
|
bundler (~> 1.0.0)
|
|
105
104
|
genspec (= 0.2.0.prerails3.2)
|
|
106
|
-
jeweler
|
|
105
|
+
jeweler
|
|
107
106
|
rails
|
|
108
107
|
rcov
|
|
109
108
|
rspec (~> 2.3.0)
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{activerecord-simpledb-adapter}
|
|
8
|
-
s.version = "0.4.
|
|
8
|
+
s.version = "0.4.6"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Ilia Ablamonov", "Alex Gorkunov", "Cloud Castle Inc."]
|
|
12
|
-
s.date = %q{2011-
|
|
12
|
+
s.date = %q{2011-05-24}
|
|
13
13
|
s.email = %q{ilia@flamefork.ru}
|
|
14
14
|
s.extra_rdoc_files = [
|
|
15
15
|
"LICENSE.txt",
|
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
"lib/active_record/connection_adapters/simpledb_adapter/adapter.rb",
|
|
26
26
|
"lib/active_record/connection_adapters/simpledb_adapter/base.rb",
|
|
27
27
|
"lib/active_record/connection_adapters/simpledb_adapter/column.rb",
|
|
28
|
+
"lib/active_record/connection_adapters/simpledb_adapter/defaults.rb",
|
|
28
29
|
"lib/active_record/connection_adapters/simpledb_adapter/finder_methods.rb",
|
|
29
30
|
"lib/active_record/connection_adapters/simpledb_adapter/misc/aws_overrides.rb",
|
|
30
31
|
"lib/active_record/connection_adapters/simpledb_adapter/misc/simpledb_logger.rb",
|
|
@@ -41,21 +42,6 @@ Gem::Specification.new do |s|
|
|
|
41
42
|
s.require_paths = ["lib"]
|
|
42
43
|
s.rubygems_version = %q{1.3.7}
|
|
43
44
|
s.summary = %q{ActiveRecord SimpleDB adapter}
|
|
44
|
-
s.test_files = [
|
|
45
|
-
"spec/active_record/batch_spec.rb",
|
|
46
|
-
"spec/active_record/connection_adapters/simpledb_adapter_spec.rb",
|
|
47
|
-
"spec/active_record/core_actions_spec.rb",
|
|
48
|
-
"spec/active_record/defaults_spec.rb",
|
|
49
|
-
"spec/active_record/locking_spec.rb",
|
|
50
|
-
"spec/active_record/offset_spec.rb",
|
|
51
|
-
"spec/active_record/record_attributes_spec.rb",
|
|
52
|
-
"spec/active_record/validates_spec.rb",
|
|
53
|
-
"spec/active_record/where_spec.rb",
|
|
54
|
-
"spec/assets/db/seeds.rb",
|
|
55
|
-
"spec/generators/model_spec.rb",
|
|
56
|
-
"spec/spec_helper.rb",
|
|
57
|
-
"spec/tasks/rake_spec.rb"
|
|
58
|
-
]
|
|
59
45
|
|
|
60
46
|
if s.respond_to? :specification_version then
|
|
61
47
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
@@ -65,7 +51,7 @@ Gem::Specification.new do |s|
|
|
|
65
51
|
s.add_development_dependency(%q<awesome_print>, [">= 0"])
|
|
66
52
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
67
53
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
68
|
-
s.add_development_dependency(%q<jeweler>, ["
|
|
54
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
|
69
55
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
70
56
|
s.add_development_dependency(%q<aws>, [">= 0"])
|
|
71
57
|
s.add_development_dependency(%q<activerecord>, [">= 0"])
|
|
@@ -82,7 +68,7 @@ Gem::Specification.new do |s|
|
|
|
82
68
|
s.add_dependency(%q<awesome_print>, [">= 0"])
|
|
83
69
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
84
70
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
85
|
-
s.add_dependency(%q<jeweler>, ["
|
|
71
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
86
72
|
s.add_dependency(%q<rcov>, [">= 0"])
|
|
87
73
|
s.add_dependency(%q<aws>, [">= 0"])
|
|
88
74
|
s.add_dependency(%q<activerecord>, [">= 0"])
|
|
@@ -100,7 +86,7 @@ Gem::Specification.new do |s|
|
|
|
100
86
|
s.add_dependency(%q<awesome_print>, [">= 0"])
|
|
101
87
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
|
102
88
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
103
|
-
s.add_dependency(%q<jeweler>, ["
|
|
89
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
104
90
|
s.add_dependency(%q<rcov>, [">= 0"])
|
|
105
91
|
s.add_dependency(%q<aws>, [">= 0"])
|
|
106
92
|
s.add_dependency(%q<activerecord>, [">= 0"])
|
|
@@ -11,3 +11,6 @@ require 'active_record/connection_adapters/simpledb_adapter/validations'
|
|
|
11
11
|
require 'active_record/connection_adapters/simpledb_adapter/table_definition'
|
|
12
12
|
require 'active_record/connection_adapters/simpledb_adapter/column'
|
|
13
13
|
require 'active_record/connection_adapters/simpledb_adapter/adapter'
|
|
14
|
+
require 'active_record/connection_adapters/simpledb_adapter/defaults'
|
|
15
|
+
|
|
16
|
+
ActiveRecord::Base.send :include, ActiveRecordSimpledbAdapter::Defaults
|
|
@@ -25,37 +25,11 @@ module ActiveRecord
|
|
|
25
25
|
table_definition = ConnectionAdapters::SimpleDbTableDifinition.new(options[:collection_column_name] || DEFAULT_COLLECTION_COLUMN_NAME)
|
|
26
26
|
table_definition.primary_key(Base.get_primary_key(table_name.to_s.singularize))
|
|
27
27
|
|
|
28
|
-
alias_method_chain :initialize, :defaults
|
|
29
|
-
|
|
30
28
|
yield table_definition if block_given?
|
|
31
29
|
|
|
32
30
|
ConnectionAdapters::SimpleDBAdapter.set_collection_columns table_name, table_definition
|
|
33
31
|
end
|
|
34
32
|
|
|
35
|
-
def initialize_with_defaults(attrs = nil)
|
|
36
|
-
initialize_without_defaults(attrs) do
|
|
37
|
-
safe_attribute_names = []
|
|
38
|
-
if attrs
|
|
39
|
-
stringified_attrs = attrs.stringify_keys
|
|
40
|
-
safe_attrs = sanitize_for_mass_assignment(stringified_attrs)
|
|
41
|
-
safe_attribute_names = safe_attrs.keys.map { |x| x.to_s }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
ActiveRecord::Base.connection.columns_definition(self.class.table_name).columns_with_defaults.each do |column|
|
|
45
|
-
if !safe_attribute_names.any? { |attr_name| attr_name =~ /^#{column.name}($|\()/ }
|
|
46
|
-
value = if column.default.is_a? Proc
|
|
47
|
-
column.default.call(self)
|
|
48
|
-
else
|
|
49
|
-
column.default
|
|
50
|
-
end
|
|
51
|
-
__send__("#{column.name}=", value)
|
|
52
|
-
changed_attributes.delete(column.name)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
yield(self) if block_given?
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
33
|
def self.batch &block
|
|
60
34
|
connection.begin_batch
|
|
61
35
|
block.call
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module ActiveRecordSimpledbAdapter
|
|
2
|
+
module Defaults
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.send :alias_method_chain, :initialize, :defaults
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def initialize_with_defaults(attrs = nil)
|
|
8
|
+
initialize_without_defaults(attrs) do
|
|
9
|
+
safe_attribute_names = []
|
|
10
|
+
if attrs
|
|
11
|
+
stringified_attrs = attrs.stringify_keys
|
|
12
|
+
safe_attrs = sanitize_for_mass_assignment(stringified_attrs)
|
|
13
|
+
safe_attribute_names = safe_attrs.keys.map { |x| x.to_s }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
ActiveRecord::Base.connection.columns_definition(self.class.table_name).columns_with_defaults.each do |column|
|
|
17
|
+
has_default = !safe_attribute_names.any? { |attr_name|
|
|
18
|
+
attr_name =~ /^#{column.name}($|\()/
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if has_default
|
|
22
|
+
value = if column.default.is_a? Proc
|
|
23
|
+
column.default.call(self)
|
|
24
|
+
else
|
|
25
|
+
column.default
|
|
26
|
+
end
|
|
27
|
+
__send__("#{column.name}=", value)
|
|
28
|
+
changed_attributes.delete(column.name)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
yield(self) if block_given?
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-simpledb-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 3
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 4
|
|
9
|
-
-
|
|
10
|
-
version: 0.4.
|
|
9
|
+
- 6
|
|
10
|
+
version: 0.4.6
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Ilia Ablamonov
|
|
@@ -17,7 +17,7 @@ autorequire:
|
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
19
|
|
|
20
|
-
date: 2011-
|
|
20
|
+
date: 2011-05-24 00:00:00 +04:00
|
|
21
21
|
default_executable:
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|
|
@@ -70,14 +70,12 @@ dependencies:
|
|
|
70
70
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
|
71
71
|
none: false
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
hash:
|
|
75
|
+
hash: 3
|
|
76
76
|
segments:
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
- 2
|
|
80
|
-
version: 1.5.2
|
|
77
|
+
- 0
|
|
78
|
+
version: "0"
|
|
81
79
|
requirement: *id004
|
|
82
80
|
prerelease: false
|
|
83
81
|
type: :development
|
|
@@ -283,6 +281,7 @@ files:
|
|
|
283
281
|
- lib/active_record/connection_adapters/simpledb_adapter/adapter.rb
|
|
284
282
|
- lib/active_record/connection_adapters/simpledb_adapter/base.rb
|
|
285
283
|
- lib/active_record/connection_adapters/simpledb_adapter/column.rb
|
|
284
|
+
- lib/active_record/connection_adapters/simpledb_adapter/defaults.rb
|
|
286
285
|
- lib/active_record/connection_adapters/simpledb_adapter/finder_methods.rb
|
|
287
286
|
- lib/active_record/connection_adapters/simpledb_adapter/misc/aws_overrides.rb
|
|
288
287
|
- lib/active_record/connection_adapters/simpledb_adapter/misc/simpledb_logger.rb
|
|
@@ -293,19 +292,6 @@ files:
|
|
|
293
292
|
- lib/generators/active_record/model/model_generator.rb
|
|
294
293
|
- lib/generators/active_record/model/templates/model.rb
|
|
295
294
|
- lib/tasks/simpledb.rake
|
|
296
|
-
- spec/active_record/batch_spec.rb
|
|
297
|
-
- spec/active_record/connection_adapters/simpledb_adapter_spec.rb
|
|
298
|
-
- spec/active_record/core_actions_spec.rb
|
|
299
|
-
- spec/active_record/defaults_spec.rb
|
|
300
|
-
- spec/active_record/locking_spec.rb
|
|
301
|
-
- spec/active_record/offset_spec.rb
|
|
302
|
-
- spec/active_record/record_attributes_spec.rb
|
|
303
|
-
- spec/active_record/validates_spec.rb
|
|
304
|
-
- spec/active_record/where_spec.rb
|
|
305
|
-
- spec/assets/db/seeds.rb
|
|
306
|
-
- spec/generators/model_spec.rb
|
|
307
|
-
- spec/spec_helper.rb
|
|
308
|
-
- spec/tasks/rake_spec.rb
|
|
309
295
|
has_rdoc: true
|
|
310
296
|
homepage: http://github.com/cloudcastle/activerecord-simpledb-adapter
|
|
311
297
|
licenses:
|
|
@@ -340,17 +326,5 @@ rubygems_version: 1.3.7
|
|
|
340
326
|
signing_key:
|
|
341
327
|
specification_version: 3
|
|
342
328
|
summary: ActiveRecord SimpleDB adapter
|
|
343
|
-
test_files:
|
|
344
|
-
|
|
345
|
-
- spec/active_record/connection_adapters/simpledb_adapter_spec.rb
|
|
346
|
-
- spec/active_record/core_actions_spec.rb
|
|
347
|
-
- spec/active_record/defaults_spec.rb
|
|
348
|
-
- spec/active_record/locking_spec.rb
|
|
349
|
-
- spec/active_record/offset_spec.rb
|
|
350
|
-
- spec/active_record/record_attributes_spec.rb
|
|
351
|
-
- spec/active_record/validates_spec.rb
|
|
352
|
-
- spec/active_record/where_spec.rb
|
|
353
|
-
- spec/assets/db/seeds.rb
|
|
354
|
-
- spec/generators/model_spec.rb
|
|
355
|
-
- spec/spec_helper.rb
|
|
356
|
-
- spec/tasks/rake_spec.rb
|
|
329
|
+
test_files: []
|
|
330
|
+
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
#spec helpers difition
|
|
3
|
-
class F < ActiveRecord::Base
|
|
4
|
-
columns_definition do |t|
|
|
5
|
-
t.string :body
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
has_many :bs
|
|
9
|
-
after_save lambda { self.bs.create!({:body => "test"}) }
|
|
10
|
-
end
|
|
11
|
-
class B < ActiveRecord::Base
|
|
12
|
-
columns_definition do |t|
|
|
13
|
-
t.string :body
|
|
14
|
-
t.string :f_id
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
#testes
|
|
18
|
-
describe "SimpleDBAdapter ActiveRecord batches operation" do
|
|
19
|
-
|
|
20
|
-
before :each do
|
|
21
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
22
|
-
ActiveRecord::Base.establish_connection($config)
|
|
23
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
after :each do
|
|
27
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should work with usual create statments" do
|
|
31
|
-
count = 5
|
|
32
|
-
Person.batch do
|
|
33
|
-
count.times { |i| Person.create_valid }
|
|
34
|
-
Person.count.should == 0
|
|
35
|
-
end
|
|
36
|
-
items = Person.all
|
|
37
|
-
items.count.should == count
|
|
38
|
-
items.each { |item| item.is_valid? }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should work with usual update statments" do
|
|
42
|
-
count = 5
|
|
43
|
-
items = []
|
|
44
|
-
count.times { items << Person.create_valid }
|
|
45
|
-
Person.batch do
|
|
46
|
-
items.each {|item| item.update_attributes({:login => 'test'}); item.save! }
|
|
47
|
-
end
|
|
48
|
-
items = Person.all
|
|
49
|
-
items.count.should == count
|
|
50
|
-
items.each { |item| item.login.should == 'test' }
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "should work with usual destroy statments" do
|
|
54
|
-
count = 5
|
|
55
|
-
items = []
|
|
56
|
-
count.times { items << Person.create_valid }
|
|
57
|
-
Person.batch do
|
|
58
|
-
items.each {|item| item.destroy }
|
|
59
|
-
end
|
|
60
|
-
Person.count.should == 0
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "should work with diferrent statments in one batch session" do
|
|
64
|
-
count = 5
|
|
65
|
-
items = []
|
|
66
|
-
count.times { items << Person.create_valid }
|
|
67
|
-
Person.batch do
|
|
68
|
-
items.each do |item|
|
|
69
|
-
item.destroy
|
|
70
|
-
Person.create_valid
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
Person.count.should == count
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "should auto split to several batches when count of items more than BATCH_MAX_ITEM_COUNT" do
|
|
77
|
-
count = 50
|
|
78
|
-
Person.batch do
|
|
79
|
-
count.times { |i| Person.create_valid }
|
|
80
|
-
end
|
|
81
|
-
Person.count.should == count
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "should batch internal operations too (sub-updates)" do
|
|
85
|
-
count = 5
|
|
86
|
-
F.batch do
|
|
87
|
-
count.times { F.create!({:body => "body"}) }
|
|
88
|
-
end
|
|
89
|
-
[F, B].each {|r| r.count.should == count }
|
|
90
|
-
end
|
|
91
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "SimpleDBAdapter establish connection" do
|
|
4
|
-
|
|
5
|
-
it "should connect to database" do
|
|
6
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
7
|
-
ActiveRecord::Base.connection.should_not be_nil
|
|
8
|
-
ActiveRecord::Base.connection.class.should == ActiveRecord::ConnectionAdapters::SimpleDBAdapter
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should be active after connection to database" do
|
|
12
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
13
|
-
ActiveRecord::Base.connection.should be_active
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should not be active after disconnection to database" do
|
|
17
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
18
|
-
ActiveRecord::Base.connection.disconnect!
|
|
19
|
-
ActiveRecord::Base.connection.should_not be_active
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should be active after reconnection to database" do
|
|
23
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
24
|
-
ActiveRecord::Base.connection.reconnect!
|
|
25
|
-
ActiveRecord::Base.connection.should be_active
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "SimpleDBAdapter ActiveRecord core actions" do
|
|
4
|
-
|
|
5
|
-
before :each do
|
|
6
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
7
|
-
ActiveRecord::Base.establish_connection($config)
|
|
8
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
9
|
-
Person.create!(Person.valid_params)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
after :each do
|
|
13
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should be correct work with .all statement" do
|
|
17
|
-
Person.all.should_not be_empty
|
|
18
|
-
Person.all.first.is_a?(Person).should be_true
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should be correct work with .first statement" do
|
|
22
|
-
Person.first.is_a?(Person).should be_true
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "should be correct work with .last statement" do
|
|
26
|
-
Person.last.is_a?(Person).should be_true
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should be correct work with .count statement" do
|
|
30
|
-
Person.count.should > 0
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should be correct work with .find statement" do
|
|
34
|
-
p1 = Person.create!
|
|
35
|
-
p2 = Person.find p1.id
|
|
36
|
-
p1.should == p2
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should be correct work with .destroy statement" do
|
|
40
|
-
p1 = Person.new
|
|
41
|
-
p1.save
|
|
42
|
-
id = p1.id
|
|
43
|
-
p1.destroy
|
|
44
|
-
p2 = Person.find_by_id id
|
|
45
|
-
p2.should be_nil
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "SimpleDBAdapter ActiveRecord default values for attributes" do
|
|
4
|
-
|
|
5
|
-
before :each do
|
|
6
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
7
|
-
ActiveRecord::Base.establish_connection($config)
|
|
8
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after :each do
|
|
12
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class ModelWithDefaults < ActiveRecord::Base
|
|
16
|
-
columns_definition do |c|
|
|
17
|
-
c.string :p1, :default => 'payload_string1'
|
|
18
|
-
c.string :p2, :default => lambda { "payload_string2" }
|
|
19
|
-
c.integer :p3, :default => 10
|
|
20
|
-
c.float :p4, :default => 10.05
|
|
21
|
-
c.boolean :p5, :default => true
|
|
22
|
-
c.string :p6
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should correct sets after create new instance of model" do
|
|
27
|
-
m = ModelWithDefaults.new
|
|
28
|
-
m.p1.should == "payload_string1"
|
|
29
|
-
m.p2.should == "payload_string2"
|
|
30
|
-
m.p3.should == 10
|
|
31
|
-
m.p4.should == 10.05
|
|
32
|
-
m.p5.should be_true
|
|
33
|
-
m.p6.should be_nil
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "SimpleDBAdapter ActiveRecord with optimistic locking" do
|
|
4
|
-
|
|
5
|
-
before :each do
|
|
6
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
7
|
-
ActiveRecord::Base.establish_connection($config)
|
|
8
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after :each do
|
|
12
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should be have not nil lock version value after save" do
|
|
16
|
-
p = Person.new
|
|
17
|
-
p.save
|
|
18
|
-
p.reload
|
|
19
|
-
p.lock_version.should_not be_nil
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should change lock version value after sevarals saves" do
|
|
23
|
-
p = Person.new
|
|
24
|
-
p.save
|
|
25
|
-
old_lock_version = p.lock_version
|
|
26
|
-
p.login = "blabla"
|
|
27
|
-
p.save
|
|
28
|
-
p.reload
|
|
29
|
-
p.lock_version.should_not == old_lock_version
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "should raise error when tried save model with non-actual values (changed another place and time)" do
|
|
33
|
-
p = Person.new
|
|
34
|
-
p.save
|
|
35
|
-
p1 = Person.find p.id
|
|
36
|
-
p1.login = "blabla"
|
|
37
|
-
p.login = "bla"
|
|
38
|
-
p1.save
|
|
39
|
-
lambda {p.save!}.should raise_error(ActiveRecord::StaleObjectError)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "should raise error when tried destroy item with changed state" do
|
|
43
|
-
p = Person.new
|
|
44
|
-
p.save
|
|
45
|
-
p1 = Person.find p.id
|
|
46
|
-
p1.login = "blabla"
|
|
47
|
-
p1.save
|
|
48
|
-
lambda {p.destroy}.should raise_error(ActiveRecord::StaleObjectError)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
#testes
|
|
3
|
-
describe "SimpleDBAdapter ActiveRecord offset operation" do
|
|
4
|
-
|
|
5
|
-
before :each do
|
|
6
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
7
|
-
ActiveRecord::Base.establish_connection($config)
|
|
8
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
9
|
-
50.times { |i| Person.create!({:login => "login#{i}"}) }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
after :each do
|
|
13
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should work" do
|
|
17
|
-
count, offset = 10, 20
|
|
18
|
-
persons = Person.limit(count).offset(offset).all
|
|
19
|
-
persons.count.should == count
|
|
20
|
-
persons.each_with_index do |person, i|
|
|
21
|
-
person.login.should == "login#{i + offset}"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "SimpleDBAdapter ActiveRecord attributes" do
|
|
4
|
-
|
|
5
|
-
before :each do
|
|
6
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
7
|
-
ActiveRecord::Base.establish_connection($config)
|
|
8
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after :each do
|
|
12
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should correct auto-generated properites (id, created_at, updated_at)" do
|
|
16
|
-
p = Person.new
|
|
17
|
-
p.id.should be_nil
|
|
18
|
-
p.created_at.should be_nil
|
|
19
|
-
p.updated_at.should be_nil
|
|
20
|
-
p.save!
|
|
21
|
-
p.id.should_not be_nil
|
|
22
|
-
p.created_at.should_not be_nil
|
|
23
|
-
p.updated_at.should_not be_nil
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should be different ids for different model instances after create" do
|
|
27
|
-
p1 = Person.create!
|
|
28
|
-
p2 = Person.create!
|
|
29
|
-
p1.id.should_not == p2.id
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "should correct saved and loaded" do
|
|
33
|
-
p = Person.create!(Person.valid_params)
|
|
34
|
-
|
|
35
|
-
r = Person.find p.id
|
|
36
|
-
Person.valid_params.each do |key, value|
|
|
37
|
-
r.try(key).should == value
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should correct save and load integer values" do
|
|
42
|
-
p = Person.new
|
|
43
|
-
p.year = 2010
|
|
44
|
-
p.save
|
|
45
|
-
p.year = p.year + 1
|
|
46
|
-
p.save
|
|
47
|
-
p.reload
|
|
48
|
-
p.year.is_a?(Fixnum).should be_true
|
|
49
|
-
p.year.should == 2011
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "should correct save and load float values" do
|
|
53
|
-
p = Person.new
|
|
54
|
-
p.price = 10.04
|
|
55
|
-
p.save
|
|
56
|
-
p.price = p.price + 1.2
|
|
57
|
-
p.save
|
|
58
|
-
p.reload
|
|
59
|
-
p.price.is_a?(Float).should be_true
|
|
60
|
-
p.price.should == 11.24
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "should corrert save and load negative values" do
|
|
64
|
-
p = Person.new
|
|
65
|
-
p.price = -10.04
|
|
66
|
-
p.year = -200
|
|
67
|
-
p.save
|
|
68
|
-
p.price = p.price - 1.02
|
|
69
|
-
p.year = p.year - 2
|
|
70
|
-
p.save
|
|
71
|
-
p.reload
|
|
72
|
-
p.price.should == -11.06
|
|
73
|
-
p.year.should == -202
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "should correct save and load boolean values" do
|
|
77
|
-
p = Person.new
|
|
78
|
-
p.active = true
|
|
79
|
-
p.save
|
|
80
|
-
p.reload
|
|
81
|
-
p.active.should be_true
|
|
82
|
-
p.active = false
|
|
83
|
-
p.save
|
|
84
|
-
p.reload
|
|
85
|
-
p.active.should be_false
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
it "should correct save and load string values" do
|
|
89
|
-
p = Person.new
|
|
90
|
-
p.login = "superman"
|
|
91
|
-
p.save
|
|
92
|
-
p.login = p.login + "123"
|
|
93
|
-
p.save
|
|
94
|
-
p.reload
|
|
95
|
-
p.login.should == "superman123"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "should update updated_at property when invoke .touch" do
|
|
99
|
-
p1 = Person.new
|
|
100
|
-
p1.save
|
|
101
|
-
p2 = Person.find p1.id
|
|
102
|
-
p1.touch
|
|
103
|
-
p1.updated_at.class.should == Time
|
|
104
|
-
p1.updated_at.should > p2.updated_at
|
|
105
|
-
end
|
|
106
|
-
it "should update attributes with update_attributes" do
|
|
107
|
-
p1 = Person.create_valid
|
|
108
|
-
p1.update_attributes!({:login =>"123"})
|
|
109
|
-
p1.login.should == "123"
|
|
110
|
-
end
|
|
111
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "SimpleDBAdapter ActiveRecord validates" do
|
|
4
|
-
|
|
5
|
-
before :each do
|
|
6
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
7
|
-
ActiveRecord::Base.establish_connection($config)
|
|
8
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
after :each do
|
|
12
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it "should be correct work with validates presense of" do
|
|
16
|
-
class PersonWithValidates < Person
|
|
17
|
-
validates_presence_of :login
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
lambda {
|
|
21
|
-
PersonWithValidates.create!
|
|
22
|
-
}.should raise_error(ActiveRecord::RecordInvalid, "Validation failed: Login can't be blank")
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "should be correct work with validates uniqueness of" do
|
|
26
|
-
class PersonWithValidates < Person
|
|
27
|
-
validates_uniqueness_of :login
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
PersonWithValidates.create!(Person.valid_params)
|
|
31
|
-
|
|
32
|
-
lambda {
|
|
33
|
-
PersonWithValidates.create!(Person.valid_params)
|
|
34
|
-
}.should raise_error(ActiveRecord::RecordInvalid, "Validation failed: Login has already been taken")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "SimpleDBAdapter ActiveRecord where statement" do
|
|
4
|
-
|
|
5
|
-
before :each do
|
|
6
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
7
|
-
ActiveRecord::Base.establish_connection($config)
|
|
8
|
-
ActiveRecord::Base.connection.create_domain($config[:domain_name])
|
|
9
|
-
Person.create!(Person.valid_params)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
after :each do
|
|
13
|
-
ActiveRecord::Base.connection.delete_domain($config[:domain_name])
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should be return items by conditions with different type values" do
|
|
17
|
-
Person.valid_params.each do |name, value|
|
|
18
|
-
result = Person.where(name => value).first
|
|
19
|
-
result.try(name).should == value
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "should be return items by condition with table name prefix" do
|
|
24
|
-
result = Person.where("people.state" => 'paid').first
|
|
25
|
-
result.state.should == 'paid'
|
|
26
|
-
end
|
|
27
|
-
end
|
data/spec/assets/db/seeds.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Person.create!(:login => "admin")
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'rails'
|
|
3
|
-
require 'rails/generators'
|
|
4
|
-
require 'generators/active_record/model/model_generator'
|
|
5
|
-
require 'genspec'
|
|
6
|
-
describe :model do
|
|
7
|
-
context "with a name argument" do
|
|
8
|
-
with_args "foo", "name:string", "year:integer", "--orm=active_record"
|
|
9
|
-
|
|
10
|
-
it "should generate a model called 'foo' with two columns" do
|
|
11
|
-
subject.should generate("app/models/foo.rb") { |content|
|
|
12
|
-
content.should =~ /class Foo < ActiveRecord\:\:Base/
|
|
13
|
-
content.should =~ /columns_definition do \|c\|\n c.string :name\n c.integer :year\n end/
|
|
14
|
-
}
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
# Set up gems listed in the Gemfile.
|
|
3
|
-
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
|
4
|
-
begin
|
|
5
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
|
6
|
-
require 'bundler'
|
|
7
|
-
Bundler.setup
|
|
8
|
-
rescue Bundler::GemNotFound => e
|
|
9
|
-
STDERR.puts e.message
|
|
10
|
-
STDERR.puts "Try running `bundle install`."
|
|
11
|
-
exit!
|
|
12
|
-
end if File.exist?(gemfile)
|
|
13
|
-
|
|
14
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
15
|
-
require 'ap'
|
|
16
|
-
require 'rspec'
|
|
17
|
-
require 'aws'
|
|
18
|
-
require 'active_record'
|
|
19
|
-
require 'active_record/connection_adapters/simpledb_adapter'
|
|
20
|
-
require 'arel/visitors/simpledb'
|
|
21
|
-
|
|
22
|
-
CONNECTION_PARAMS = {
|
|
23
|
-
:adapter => 'simpledb',
|
|
24
|
-
:access_key_id => "some_key",
|
|
25
|
-
:secret_access_key => "some_secret",
|
|
26
|
-
:domain_name => "test_domain",
|
|
27
|
-
:host => 'localhost',
|
|
28
|
-
:port => '8080',
|
|
29
|
-
:protocol => 'http'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
$config = CONNECTION_PARAMS
|
|
33
|
-
|
|
34
|
-
#define stub model
|
|
35
|
-
class Person < ActiveRecord::Base
|
|
36
|
-
establish_connection $config
|
|
37
|
-
|
|
38
|
-
columns_definition do |t|
|
|
39
|
-
t.string :login
|
|
40
|
-
t.integer :year, :limit => 4
|
|
41
|
-
t.boolean :active
|
|
42
|
-
t.string :state
|
|
43
|
-
t.float :price
|
|
44
|
-
t.integer :lock_version
|
|
45
|
-
|
|
46
|
-
t.timestamps
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def self.valid_params
|
|
50
|
-
{
|
|
51
|
-
:login => "john",
|
|
52
|
-
:year => 2010,
|
|
53
|
-
:active => true,
|
|
54
|
-
:price => 10.04,
|
|
55
|
-
:state => 'paid'
|
|
56
|
-
}
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def self.create_valid
|
|
60
|
-
create! valid_params
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def is_valid?
|
|
64
|
-
Person.valid_params.all? {|key, value| self.try(key) == value}
|
|
65
|
-
end
|
|
66
|
-
end
|
data/spec/tasks/rake_spec.rb
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'rake'
|
|
3
|
-
require 'rails'
|
|
4
|
-
|
|
5
|
-
DOMAIN = CONNECTION_PARAMS[:domain_name]
|
|
6
|
-
|
|
7
|
-
def delete_domain_if_exist
|
|
8
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
9
|
-
con = ActiveRecord::Base.connection
|
|
10
|
-
con.delete_domain(DOMAIN) if con.list_domains.include? DOMAIN
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def recreate_domain
|
|
14
|
-
delete_domain_if_exist
|
|
15
|
-
ActiveRecord::Base.connection.create_domain DOMAIN
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe "gem rake tasks" do
|
|
19
|
-
before do
|
|
20
|
-
@rake = Rake::Application.new
|
|
21
|
-
Rake.application = @rake
|
|
22
|
-
Rake.application.rake_require "tasks/simpledb"
|
|
23
|
-
Rake::Task.define_task(:environment)
|
|
24
|
-
ActiveRecord::Base.stub!(:configurations).and_return({"development" => CONNECTION_PARAMS})
|
|
25
|
-
Rails.stub!(:env).and_return("development")
|
|
26
|
-
Rails.stub!(:logger).and_return(Logger.new(STDOUT))
|
|
27
|
-
Rails.stub!(:root).and_return(File.dirname(__FILE__) + "/../assets")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe "db:create" do
|
|
31
|
-
before do
|
|
32
|
-
@task_name = "db:create"
|
|
33
|
-
delete_domain_if_exist
|
|
34
|
-
end
|
|
35
|
-
it "should create sdb domain" do
|
|
36
|
-
@rake[@task_name].invoke
|
|
37
|
-
ActiveRecord::Base.connection.list_domains.should include(DOMAIN)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe "db:drop" do
|
|
42
|
-
before do
|
|
43
|
-
@task_name = "db:drop"
|
|
44
|
-
recreate_domain
|
|
45
|
-
end
|
|
46
|
-
it "should drop sdb domain" do
|
|
47
|
-
@rake[@task_name].invoke
|
|
48
|
-
ActiveRecord::Base.connection.list_domains.should_not include(DOMAIN)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
describe "db:seed" do
|
|
53
|
-
before do
|
|
54
|
-
@task_name = "db:seed"
|
|
55
|
-
recreate_domain
|
|
56
|
-
end
|
|
57
|
-
it "should pushing data to sdb domain" do
|
|
58
|
-
@rake[@task_name].invoke
|
|
59
|
-
Person.count.should == 1
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe "db:collection:clear" do
|
|
64
|
-
before do
|
|
65
|
-
@task_name = "db:collection:clear"
|
|
66
|
-
recreate_domain
|
|
67
|
-
Person.create!(Person.valid_params)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "should receive param with name \"name\"" do
|
|
71
|
-
@rake[@task_name].arg_names.should include(:name)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "should clear collection by name" do
|
|
75
|
-
@rake[@task_name].invoke("person")
|
|
76
|
-
Person.count.should == 0
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|