couchrest_model 1.1.0.rc1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/VERSION +1 -1
- data/couchrest_model.gemspec +1 -1
- data/history.md +13 -1
- data/lib/couchrest/model/associations.rb +4 -4
- data/lib/couchrest/model/base.rb +25 -7
- data/lib/couchrest/model/callbacks.rb +13 -11
- data/lib/couchrest/model/{casted_model.rb → embeddable.rb} +22 -17
- data/lib/couchrest/model/persistence.rb +6 -1
- data/lib/couchrest/model/properties.rb +22 -34
- data/lib/couchrest/model/property.rb +1 -1
- data/lib/couchrest/model/validations.rb +19 -8
- data/lib/couchrest/railtie.rb +6 -3
- data/lib/couchrest_model.rb +2 -3
- data/lib/rails/generators/couchrest_model/config/config_generator.rb +18 -0
- data/lib/rails/generators/couchrest_model/config/templates/couchdb.yml +21 -0
- data/spec/fixtures/{more → models}/article.rb +0 -0
- data/spec/fixtures/{base.rb → models/base.rb} +11 -0
- data/spec/fixtures/{more → models}/card.rb +2 -0
- data/spec/fixtures/{more → models}/cat.rb +2 -2
- data/spec/fixtures/{more → models}/client.rb +0 -0
- data/spec/fixtures/{more → models}/course.rb +2 -2
- data/spec/fixtures/{more → models}/event.rb +0 -0
- data/spec/fixtures/{more → models}/invoice.rb +2 -2
- data/spec/fixtures/{more → models}/key_chain.rb +0 -0
- data/spec/fixtures/models/membership.rb +4 -0
- data/spec/fixtures/{more → models}/person.rb +4 -2
- data/spec/fixtures/models/project.rb +6 -0
- data/spec/fixtures/models/question.rb +7 -0
- data/spec/fixtures/{more → models}/sale_entry.rb +0 -0
- data/spec/fixtures/{more → models}/sale_invoice.rb +5 -4
- data/spec/fixtures/{more → models}/service.rb +0 -0
- data/spec/fixtures/{more → models}/user.rb +0 -0
- data/spec/functional/validations_spec.rb +8 -0
- data/spec/spec_helper.rb +23 -14
- data/spec/unit/active_model_lint_spec.rb +30 -0
- data/spec/{couchrest → unit}/assocations_spec.rb +1 -3
- data/spec/{couchrest → unit}/attachment_spec.rb +1 -1
- data/spec/{couchrest → unit}/base_spec.rb +59 -10
- data/spec/{couchrest → unit}/casted_spec.rb +1 -4
- data/spec/{couchrest → unit}/class_proxy_spec.rb +1 -1
- data/spec/{couchrest → unit}/collection_spec.rb +1 -2
- data/spec/{couchrest → unit}/configuration_spec.rb +2 -3
- data/spec/{couchrest → unit}/connection_spec.rb +2 -2
- data/spec/{couchrest → unit}/core_extensions/time_parsing.rb +0 -0
- data/spec/{couchrest → unit}/design_doc_spec.rb +2 -5
- data/spec/{couchrest → unit}/designs/view_spec.rb +0 -0
- data/spec/{couchrest → unit}/designs_spec.rb +2 -3
- data/spec/{couchrest → unit}/dirty_spec.rb +2 -8
- data/spec/{couchrest/casted_model_spec.rb → unit/embeddable_spec.rb} +49 -26
- data/spec/{couchrest → unit}/inherited_spec.rb +1 -1
- data/spec/{couchrest → unit}/persistence_spec.rb +23 -8
- data/spec/{couchrest → unit}/property_protection_spec.rb +1 -1
- data/spec/{couchrest → unit}/property_spec.rb +3 -14
- data/spec/{couchrest → unit}/proxyable_spec.rb +2 -4
- data/spec/{couchrest → unit}/subclass_spec.rb +1 -5
- data/spec/{couchrest → unit}/typecast_spec.rb +1 -4
- data/spec/{couchrest → unit}/validations_spec.rb +2 -10
- data/spec/{couchrest → unit}/view_spec.rb +2 -7
- metadata +49 -91
- data/spec/fixtures/more/question.rb +0 -7
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
+
|
1
4
|
require "bundler/setup"
|
2
5
|
require "rubygems"
|
3
|
-
require "rspec"
|
6
|
+
require "rspec"
|
4
7
|
|
5
|
-
require
|
6
|
-
# check the following file to see how to use the spec'd features.
|
8
|
+
require 'couchrest_model'
|
7
9
|
|
8
10
|
unless defined?(FIXTURE_PATH)
|
11
|
+
MODEL_PATH = File.join(File.dirname(__FILE__), "fixtures", "models")
|
12
|
+
$LOAD_PATH.unshift(MODEL_PATH)
|
13
|
+
|
9
14
|
FIXTURE_PATH = File.join(File.dirname(__FILE__), '/fixtures')
|
10
15
|
SCRATCH_PATH = File.join(File.dirname(__FILE__), '/tmp')
|
11
16
|
|
@@ -16,6 +21,21 @@ unless defined?(FIXTURE_PATH)
|
|
16
21
|
DB = TEST_SERVER.database(TESTDB)
|
17
22
|
end
|
18
23
|
|
24
|
+
RSpec.configure do |config|
|
25
|
+
config.before(:all) { reset_test_db! }
|
26
|
+
|
27
|
+
config.after(:all) do
|
28
|
+
cr = TEST_SERVER
|
29
|
+
test_dbs = cr.databases.select { |db| db =~ /^#{TESTDB}/ }
|
30
|
+
test_dbs.each do |db|
|
31
|
+
cr.database(db).delete! rescue nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Require each of the fixture models
|
37
|
+
Dir[ File.join(MODEL_PATH, "*.rb") ].sort.each { |file| require File.basename(file) }
|
38
|
+
|
19
39
|
class Basic < CouchRest::Model::Base
|
20
40
|
use_database TEST_SERVER.default_database
|
21
41
|
end
|
@@ -27,17 +47,6 @@ def reset_test_db!
|
|
27
47
|
DB
|
28
48
|
end
|
29
49
|
|
30
|
-
RSpec.configure do |config|
|
31
|
-
config.before(:all) { reset_test_db! }
|
32
|
-
|
33
|
-
config.after(:all) do
|
34
|
-
cr = TEST_SERVER
|
35
|
-
test_dbs = cr.databases.select { |db| db =~ /^#{TESTDB}/ }
|
36
|
-
test_dbs.each do |db|
|
37
|
-
cr.database(db).delete! rescue nil
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
50
|
|
42
51
|
def couchdb_lucene_available?
|
43
52
|
lucene_path = "http://localhost:5985/"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'test/unit/assertions'
|
4
|
+
require 'active_model/lint'
|
5
|
+
|
6
|
+
class CompliantModel < CouchRest::Model::Base
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
describe CouchRest::Model::Base do
|
11
|
+
include Test::Unit::Assertions
|
12
|
+
include ActiveModel::Lint::Tests
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
@model = CompliantModel.new
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "active model lint tests" do
|
19
|
+
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
|
20
|
+
example m.gsub('_',' ') do
|
21
|
+
send m
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def model
|
27
|
+
@model
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -1,11 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path("../../spec_helper", __FILE__)
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'article')
|
6
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
7
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
8
|
-
require File.join(FIXTURE_PATH, 'base')
|
2
|
+
require "spec_helper"
|
9
3
|
|
10
4
|
describe "Model Base" do
|
11
5
|
|
@@ -75,6 +69,17 @@ describe "Model Base" do
|
|
75
69
|
@doc = WithAfterInitializeMethod.new {|d| d.some_value = "foo"}
|
76
70
|
@doc['some_value'].should eql('foo')
|
77
71
|
end
|
72
|
+
|
73
|
+
it "should call after_initialize callback if available" do
|
74
|
+
klass = Class.new(CouchRest::Model::Base)
|
75
|
+
klass.class_eval do # for ruby 1.8.7
|
76
|
+
property :name
|
77
|
+
after_initialize :set_name
|
78
|
+
def set_name; self.name = "foobar"; end
|
79
|
+
end
|
80
|
+
@doc = klass.new
|
81
|
+
@doc.name.should eql("foobar")
|
82
|
+
end
|
78
83
|
end
|
79
84
|
|
80
85
|
describe "ActiveModel compatability Basic" do
|
@@ -116,14 +121,22 @@ describe "Model Base" do
|
|
116
121
|
describe "#persisted?" do
|
117
122
|
context "when the document is new" do
|
118
123
|
it "returns false" do
|
119
|
-
@obj.persisted?.should
|
124
|
+
@obj.persisted?.should be_false
|
120
125
|
end
|
121
126
|
end
|
122
127
|
|
123
128
|
context "when the document is not new" do
|
124
129
|
it "returns id" do
|
125
130
|
@obj.save
|
126
|
-
@obj.persisted?.should
|
131
|
+
@obj.persisted?.should be_true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context "when the document is destroyed" do
|
136
|
+
it "returns false" do
|
137
|
+
@obj.save
|
138
|
+
@obj.destroy
|
139
|
+
@obj.persisted?.should be_false
|
127
140
|
end
|
128
141
|
end
|
129
142
|
end
|
@@ -148,8 +161,44 @@ describe "Model Base" do
|
|
148
161
|
@obj.destroyed?.should be_true
|
149
162
|
end
|
150
163
|
end
|
164
|
+
end
|
151
165
|
|
152
|
-
|
166
|
+
describe "comparisons" do
|
167
|
+
describe "#==" do
|
168
|
+
context "on saved document" do
|
169
|
+
it "should be true on same document" do
|
170
|
+
p = Project.create
|
171
|
+
p.should eql(p)
|
172
|
+
end
|
173
|
+
it "should be true after loading" do
|
174
|
+
p = Project.create
|
175
|
+
p.should eql(Project.get(p.id))
|
176
|
+
end
|
177
|
+
it "should not be true if databases do not match" do
|
178
|
+
p = Project.create
|
179
|
+
p2 = p.dup
|
180
|
+
p2.stub!(:database).and_return('other')
|
181
|
+
p.should_not eql(p2)
|
182
|
+
end
|
183
|
+
it "should always be false if one document not saved" do
|
184
|
+
p = Project.create(:name => 'test')
|
185
|
+
o = Project.new(:name => 'test')
|
186
|
+
p.should_not eql(o)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
context "with new documents" do
|
190
|
+
it "should be true when attributes match" do
|
191
|
+
p = Project.new(:name => 'test')
|
192
|
+
o = Project.new(:name => 'test')
|
193
|
+
p.should eql(o)
|
194
|
+
end
|
195
|
+
it "should not be true when attributes don't match" do
|
196
|
+
p = Project.new(:name => 'test')
|
197
|
+
o = Project.new(:name => 'testing')
|
198
|
+
p.should_not eql(o)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
153
202
|
end
|
154
203
|
|
155
204
|
describe "update attributes without saving" do
|
@@ -1,7 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
3
|
-
require File.join(FIXTURE_PATH, 'more', 'person')
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
1
|
+
require "spec_helper"
|
5
2
|
|
6
3
|
class Driver < CouchRest::Model::Base
|
7
4
|
use_database TEST_SERVER.default_database
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
2
|
+
require "spec_helper"
|
4
3
|
|
5
|
-
describe CouchRest::Model::
|
4
|
+
describe CouchRest::Model::Configuration do
|
6
5
|
|
7
6
|
before do
|
8
7
|
@class = Class.new(CouchRest::Model::Base)
|
File without changes
|
@@ -1,10 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
2
3
|
|
3
|
-
|
4
|
-
require File.join(FIXTURE_PATH, 'base')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'article')
|
6
|
-
|
7
|
-
describe "Design Documents" do
|
4
|
+
describe CouchRest::Model::DesignDoc do
|
8
5
|
|
9
6
|
before :all do
|
10
7
|
reset_test_db!
|
File without changes
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
class DesignModel < CouchRest::Model::Base
|
4
|
-
|
5
4
|
end
|
6
5
|
|
7
|
-
describe
|
6
|
+
describe CouchRest::Model::Designs do
|
8
7
|
|
9
8
|
it "should accessable from model" do
|
10
9
|
DesignModel.respond_to?(:design).should be_true
|
@@ -1,12 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'article')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
6
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
7
|
-
require File.join(FIXTURE_PATH, 'base')
|
8
|
-
|
9
|
-
class WithCastedModelMixin < Hash
|
3
|
+
class WithCastedModelMixin
|
10
4
|
include CouchRest::Model::CastedModel
|
11
5
|
property :name
|
12
6
|
property :details, Object, :default => {}
|
@@ -1,26 +1,25 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'person')
|
6
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
7
|
-
require File.join(FIXTURE_PATH, 'more', 'question')
|
8
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
9
|
-
|
10
|
-
|
11
|
-
class WithCastedModelMixin < Hash
|
12
|
-
include CouchRest::Model::CastedModel
|
4
|
+
class WithCastedModelMixin
|
5
|
+
include CouchRest::Model::Embeddable
|
13
6
|
property :name
|
14
7
|
property :no_value
|
15
8
|
property :details, Object, :default => {}
|
16
9
|
property :casted_attribute, WithCastedModelMixin
|
17
10
|
end
|
18
11
|
|
12
|
+
class OldFashionedMixin < Hash
|
13
|
+
include CouchRest::Model::CastedModel
|
14
|
+
property :name
|
15
|
+
end
|
16
|
+
|
19
17
|
class DummyModel < CouchRest::Model::Base
|
20
18
|
use_database TEST_SERVER.default_database
|
21
19
|
raise "Default DB not set" if TEST_SERVER.default_database.nil?
|
22
20
|
property :casted_attribute, WithCastedModelMixin
|
23
21
|
property :keywords, [String]
|
22
|
+
property :old_casted_attribute, OldFashionedMixin
|
24
23
|
property :sub_models do |child|
|
25
24
|
child.property :title
|
26
25
|
end
|
@@ -29,8 +28,8 @@ class DummyModel < CouchRest::Model::Base
|
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
32
|
-
class WithCastedCallBackModel
|
33
|
-
include CouchRest::Model::
|
31
|
+
class WithCastedCallBackModel
|
32
|
+
include CouchRest::Model::Embeddable
|
34
33
|
property :name
|
35
34
|
property :run_before_validation
|
36
35
|
property :run_after_validation
|
@@ -51,19 +50,7 @@ class CastedCallbackDoc < CouchRest::Model::Base
|
|
51
50
|
property :callback_model, WithCastedCallBackModel
|
52
51
|
end
|
53
52
|
|
54
|
-
describe CouchRest::Model::
|
55
|
-
|
56
|
-
describe "A non hash class including CastedModel" do
|
57
|
-
it "should fail raising and include error" do
|
58
|
-
lambda do
|
59
|
-
class NotAHashButWithCastedModelMixin
|
60
|
-
include CouchRest::CastedModel
|
61
|
-
property :name
|
62
|
-
end
|
63
|
-
|
64
|
-
end.should raise_error
|
65
|
-
end
|
66
|
-
end
|
53
|
+
describe CouchRest::Model::Embeddable do
|
67
54
|
|
68
55
|
describe "isolated" do
|
69
56
|
before(:each) do
|
@@ -82,7 +69,16 @@ describe CouchRest::Model::CastedModel do
|
|
82
69
|
it "should always return base_doc? as false" do
|
83
70
|
@obj.base_doc?.should be_false
|
84
71
|
end
|
85
|
-
|
72
|
+
it "should call after_initialize callback if available" do
|
73
|
+
klass = Class.new do
|
74
|
+
include CouchRest::Model::CastedModel
|
75
|
+
after_initialize :set_name
|
76
|
+
property :name
|
77
|
+
def set_name; self.name = "foobar"; end
|
78
|
+
end
|
79
|
+
@obj = klass.new
|
80
|
+
@obj.name.should eql("foobar")
|
81
|
+
end
|
86
82
|
end
|
87
83
|
|
88
84
|
describe "casted as an attribute, but without a value" do
|
@@ -162,6 +158,33 @@ describe CouchRest::Model::CastedModel do
|
|
162
158
|
end
|
163
159
|
end
|
164
160
|
|
161
|
+
# Basic testing for an old fashioned casted hash
|
162
|
+
describe "old hash casted as attribute" do
|
163
|
+
before :each do
|
164
|
+
@obj = DummyModel.new(:old_casted_attribute => {:name => 'Testing'})
|
165
|
+
@casted_obj = @obj.old_casted_attribute
|
166
|
+
end
|
167
|
+
it "should be available from its parent" do
|
168
|
+
@casted_obj.should be_an_instance_of(OldFashionedMixin)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should have the getters defined" do
|
172
|
+
@casted_obj.name.should == 'Testing'
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should know who casted it" do
|
176
|
+
@casted_obj.casted_by.should == @obj
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should know which property casted it" do
|
180
|
+
@casted_obj.casted_by_property.should == @obj.properties.detect{|p| p.to_s == 'old_casted_attribute'}
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should return nil for the unknown attribute" do
|
184
|
+
@casted_obj["unknown"].should be_nil
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
165
188
|
describe "casted as an array of a different type" do
|
166
189
|
before(:each) do
|
167
190
|
@obj = DummyModel.new(:keywords => ['couch', 'sofa', 'relax', 'canapé'])
|
@@ -1,13 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require File.join(FIXTURE_PATH, 'base')
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'article')
|
6
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
7
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
8
|
-
require File.join(FIXTURE_PATH, 'more', 'event')
|
2
|
+
require 'spec_helper'
|
9
3
|
|
10
|
-
describe
|
4
|
+
describe CouchRest::Model::Persistence do
|
11
5
|
|
12
6
|
before(:each) do
|
13
7
|
@obj = WithDefaultValues.new
|
@@ -362,6 +356,27 @@ describe "Model Persistence" do
|
|
362
356
|
end
|
363
357
|
end
|
364
358
|
|
359
|
+
describe "with contextual validation on ”create”" do
|
360
|
+
it "should validate only within ”create” context" do
|
361
|
+
doc = WithContextualValidationOnCreate.new
|
362
|
+
doc.save.should be_false
|
363
|
+
doc.name = "Alice"
|
364
|
+
doc.save.should be_true
|
365
|
+
|
366
|
+
doc.update_attributes(:name => nil).should be_true
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
describe "with contextual validation on ”update”" do
|
371
|
+
it "should validate only within ”update” context" do
|
372
|
+
doc = WithContextualValidationOnUpdate.new
|
373
|
+
doc.save.should be_true
|
374
|
+
|
375
|
+
doc.update_attributes(:name => nil).should be_false
|
376
|
+
doc.update_attributes(:name => "Bob").should be_true
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
365
380
|
describe "save" do
|
366
381
|
it "should run the after filter after saving" do
|
367
382
|
@doc.run_after_save.should be_nil
|
@@ -1,18 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'person')
|
6
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
7
|
-
require File.join(FIXTURE_PATH, 'more', 'invoice')
|
8
|
-
require File.join(FIXTURE_PATH, 'more', 'service')
|
9
|
-
require File.join(FIXTURE_PATH, 'more', 'event')
|
10
|
-
require File.join(FIXTURE_PATH, 'more', 'user')
|
11
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
12
|
-
require File.join(FIXTURE_PATH, "more", "key_chain")
|
13
|
-
|
14
|
-
|
15
|
-
describe "Model properties" do
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe CouchRest::Model::Property do
|
16
5
|
|
17
6
|
before(:each) do
|
18
7
|
reset_test_db!
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
1
|
+
require "spec_helper"
|
4
2
|
|
5
3
|
class DummyProxyable < CouchRest::Model::Base
|
6
4
|
proxy_database_method :db
|
@@ -12,7 +10,7 @@ end
|
|
12
10
|
class ProxyKitten < CouchRest::Model::Base
|
13
11
|
end
|
14
12
|
|
15
|
-
describe
|
13
|
+
describe CouchRest::Model::Proxyable do
|
16
14
|
|
17
15
|
describe "#proxy_database" do
|
18
16
|
|
@@ -1,8 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
3
|
-
require File.join(FIXTURE_PATH, 'more', 'person')
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
1
|
+
require "spec_helper"
|
6
2
|
|
7
3
|
# add a default value
|
8
4
|
Card.property :bg_color, :default => '#ccc'
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'person')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
2
|
+
require 'spec_helper'
|
6
3
|
|
7
4
|
describe "Type Casting" do
|
8
5
|
|
@@ -1,14 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'article')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
6
|
-
require File.join(FIXTURE_PATH, 'more', 'card')
|
7
|
-
require File.join(FIXTURE_PATH, 'base')
|
8
|
-
|
9
|
-
# TODO Move validations from other specs to here
|
10
|
-
|
11
|
-
describe "Validations" do
|
3
|
+
describe CouchRest::Model::Validations do
|
12
4
|
|
13
5
|
describe "Uniqueness" do
|
14
6
|
|
@@ -1,10 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require File.join(FIXTURE_PATH, 'more', 'cat')
|
3
|
-
require File.join(FIXTURE_PATH, 'more', 'person')
|
4
|
-
require File.join(FIXTURE_PATH, 'more', 'article')
|
5
|
-
require File.join(FIXTURE_PATH, 'more', 'course')
|
1
|
+
require "spec_helper"
|
6
2
|
|
7
|
-
describe
|
3
|
+
describe CouchRest::Model::Views do
|
8
4
|
|
9
5
|
class Unattached < CouchRest::Model::Base
|
10
6
|
property :title
|
@@ -17,7 +13,6 @@ describe "Model views" do
|
|
17
13
|
nil
|
18
14
|
end
|
19
15
|
end
|
20
|
-
|
21
16
|
|
22
17
|
describe "ClassMethods" do
|
23
18
|
# NOTE! Add more unit tests!
|