gom-couchdb-adapter 0.4.1 → 0.4.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.
data/README.rdoc CHANGED
@@ -4,6 +4,8 @@
4
4
  The CouchDB adapter for the Generic Object Mapper (http://github.com/phifty/gom) provides an easy way store and fetch
5
5
  object data to/from a CouchDB server. Object properties are mapped as well as object relations.
6
6
 
7
+ http://travis-ci.org/phifty/gom-couchdb-adapter.png
8
+
7
9
  == Configuration
8
10
 
9
11
  If the couchdb adapter is chosen in the storage configuration, the following configuration values should be specified.
@@ -5,9 +5,9 @@ describe GOM::Storage::CouchDB::View::Pusher do
5
5
  before :each do
6
6
  @database = mock CouchDB::Database
7
7
 
8
- @class_view = GOM::Storage::Configuration::View::Class.new "Object"
9
- @map_reduce_view = GOM::Storage::Configuration::View::MapReduce.new "function(document) { }", "function(key, values) { }"
10
- @view_hash = { "test_class_view" => @class_view, "test_map_reduce_view" => @map_reduce_view }
8
+ @class_view_configuration = GOM::Storage::Configuration::View::Class.new "Object"
9
+ @map_reduce_view_configuration = GOM::Storage::Configuration::View::MapReduce.new "function(document) { }", "function(key, values) { }"
10
+ @view_hash = { "test_class_view" => @class_view_configuration, "test_map_reduce_view" => @map_reduce_view_configuration }
11
11
 
12
12
  @pusher = described_class.new @database, @view_hash
13
13
  end
@@ -16,15 +16,18 @@ describe GOM::Storage::CouchDB::View::Pusher do
16
16
 
17
17
  before :each do
18
18
  @design = mock CouchDB::Design, :views => mock(CouchDB::Design::ViewsProxy, :<< => nil), :save => true
19
- CouchDB::Design.stub(:new).and_return(@design)
19
+ CouchDB::Design.stub :new => @design
20
20
 
21
- @view = mock CouchDB::Design::View
22
- CouchDB::Design::View.stub(:new).and_return(@view)
21
+ @class_view = mock CouchDB::Design::View
22
+ @map_reduce_view = mock CouchDB::Design::View
23
+ CouchDB::Design::View.stub :new do |design, name, map_function, reduce_function|
24
+ { "test_class_view" => @class_view, "test_map_reduce_view" => @map_reduce_view }[name]
25
+ end
23
26
 
24
27
  @class_map_reduce_view = mock GOM::Storage::Configuration::View::MapReduce,
25
28
  :map => "function(document) { }", :reduce => nil
26
29
  @builder = mock GOM::Storage::CouchDB::View::Builder, :map_reduce_view => @class_map_reduce_view
27
- GOM::Storage::CouchDB::View::Builder.stub(:new).and_return(@builder)
30
+ GOM::Storage::CouchDB::View::Builder.stub :new => @builder
28
31
  end
29
32
 
30
33
  it "should initialize the design document" do
@@ -33,24 +36,22 @@ describe GOM::Storage::CouchDB::View::Pusher do
33
36
  end
34
37
 
35
38
  it "should initialize the builder with the class view" do
36
- GOM::Storage::CouchDB::View::Builder.should_receive(:new).with(@class_view).and_return(@builder)
39
+ GOM::Storage::CouchDB::View::Builder.should_receive(:new).with(@class_view_configuration).and_return(@builder)
37
40
  @pusher.perform
38
41
  end
39
42
 
40
- it "should use the builder to create a map reduce view out of the class view" do
43
+ it "should use the builder to generate a map reduce view out of the class view" do
41
44
  @builder.should_receive(:map_reduce_view).and_return(@class_map_reduce_view)
42
45
  @pusher.perform
43
46
  end
44
47
 
45
- it "should initialize the created map reduce view" do
46
- CouchDB::Design::View.should_receive(:new).with(@design, "test_class_view", "function(document) { }", nil).once.and_return(@view)
47
- CouchDB::Design::View.should_receive(:new).once.and_return(@view)
48
+ it "should add the generated map reduce view" do
49
+ @design.views.should_receive(:<<).with(@class_view)
48
50
  @pusher.perform
49
51
  end
50
52
 
51
- it "should initialize the map reduce view" do
52
- CouchDB::Design::View.should_receive(:new).once.and_return(@view)
53
- CouchDB::Design::View.should_receive(:new).with(@design, "test_map_reduce_view", "function(document) { }", "function(key, values) { }").and_return(@view)
53
+ it "should add the map reduce view" do
54
+ @design.views.should_receive(:<<).with(@map_reduce_view)
54
55
  @pusher.perform
55
56
  end
56
57
 
data/spec/spec_helper.rb CHANGED
@@ -15,12 +15,12 @@ GOM::Storage.configure {
15
15
  create_database_if_missing true
16
16
  view {
17
17
  name :test_object_class_view
18
- type :class
18
+ kind :class
19
19
  model_class GOM::Spec::Object
20
20
  }
21
21
  view {
22
22
  name :test_map_view
23
- type :map_reduce
23
+ kind :map_reduce
24
24
  map_function """
25
25
  function(document) {
26
26
  if (document['number'] == 11) {
@@ -31,7 +31,7 @@ GOM::Storage.configure {
31
31
  }
32
32
  view {
33
33
  name :test_map_reduce_view
34
- type :map_reduce
34
+ kind :map_reduce
35
35
  map_function """
36
36
  function(document) {
37
37
  if (document['number']) {
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gom-couchdb-adapter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.1
5
+ version: 0.4.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - "Philipp Br\xC3\xBCll"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-22 00:00:00 +02:00
13
+ date: 2011-05-30 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 0.4.0
24
+ version: 0.4.1
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency