slipcover 0.2.1 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/slipcover/document.rb +0 -1
- data/lib/slipcover/version.rb +1 -1
- data/lib/slipcover/wrapper.rb +2 -5
- data/spec/query_spec.rb +3 -3
- data/spec/wrapper_spec.rb +56 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b62699c6646708ec6b08a6350cf49393c20c70e8
|
4
|
+
data.tar.gz: 0569fa1c37986f8db74ceb8f142f520c24c9c49e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aa0fec9eb262d71c41e174929e67a76a0fccad539be45ead17afa6e24c5bf67099bb8899001068f7113577717995371cad54250db96dede5b376caa21a38400
|
7
|
+
data.tar.gz: 5a40e987c471f97a972e7936670315814c78cf4f1f12a4968e993dbe612968509d6c64349068b10c433e78f32e7a6eb89ab5e1062ee53dcd0fa924ee468ef414
|
data/lib/slipcover/document.rb
CHANGED
data/lib/slipcover/version.rb
CHANGED
data/lib/slipcover/wrapper.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Slipcover
|
2
2
|
class Wrapper
|
3
|
-
attr_reader :database_name, :view_name
|
3
|
+
attr_reader :database_name, :view_name, :view_dir
|
4
4
|
|
5
5
|
def initialize(opts)
|
6
6
|
@database_name = opts[:database_name]
|
7
7
|
@view_name = opts[:view_name]
|
8
|
+
@view_dir = opts[:view_dir] || Slipcover::Config.view_dir
|
8
9
|
end
|
9
10
|
|
10
11
|
def lookup(opts={})
|
@@ -28,9 +29,5 @@ module Slipcover
|
|
28
29
|
def database
|
29
30
|
@database ||= Slipcover::Database.new("#{database_name}")
|
30
31
|
end
|
31
|
-
|
32
|
-
def view_dir
|
33
|
-
# Defaults to app/slipcover_views, override to change.
|
34
|
-
end
|
35
32
|
end
|
36
33
|
end
|
data/spec/query_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe Slipcover::Query do
|
|
29
29
|
|
30
30
|
describe '#all' do
|
31
31
|
it 'returns all the documents that match the index/view' do
|
32
|
-
results = query.all
|
32
|
+
results = query.all(include_docs: true)
|
33
33
|
results.size.should == 3
|
34
34
|
results.map {|doc| doc[:name] }.should =~ ['Deepti', 'Fito', 'Kane']
|
35
35
|
end
|
@@ -37,7 +37,7 @@ describe Slipcover::Query do
|
|
37
37
|
context 'with options' do
|
38
38
|
context 'with key' do
|
39
39
|
it "returns only the related records" do
|
40
|
-
results = query.all(key: 'Deepti')
|
40
|
+
results = query.all(key: 'Deepti', include_docs: true)
|
41
41
|
results.size.should == 1
|
42
42
|
results.first[:name].should == 'Deepti'
|
43
43
|
end
|
@@ -45,7 +45,7 @@ describe Slipcover::Query do
|
|
45
45
|
|
46
46
|
context 'with a startkey and endkey' do
|
47
47
|
it "return the range of docs" do
|
48
|
-
results = query.all(startkey: 'Da', endkey: 'Fz')
|
48
|
+
results = query.all(startkey: 'Da', endkey: 'Fz', include_docs: true)
|
49
49
|
results.size.should == 2
|
50
50
|
results.map { |doc| doc[:name] }.should =~ ['Deepti', 'Fito']
|
51
51
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Slipcover::Wrapper do
|
4
|
+
let(:wrapper){ Slipcover::Wrapper.new({database_name: "test_database", view_name: "view"}) }
|
5
|
+
|
6
|
+
describe "#lookup" do
|
7
|
+
let(:query){ double(:query) }
|
8
|
+
let(:design_document){ double(:doc, save:true) }
|
9
|
+
before do
|
10
|
+
Slipcover::DesignDocument.stub(:new).and_return(design_document)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "makes a slipcover query" do
|
14
|
+
Slipcover::Query.should_receive(:new).and_return(query)
|
15
|
+
query.should_receive(:all).and_return([double(:thingy, attributes: true)])
|
16
|
+
wrapper.lookup
|
17
|
+
end
|
18
|
+
|
19
|
+
context "database does not exist" do
|
20
|
+
let(:database) { double('database', name: "thingy") }
|
21
|
+
|
22
|
+
it "creates a database" do
|
23
|
+
Slipcover::Query.should_receive(:new).and_return(query)
|
24
|
+
query.should_receive(:all).ordered.and_raise(Slipcover::HttpAdapter::DBNotFound)
|
25
|
+
query.should_receive(:all).ordered.and_return([double(:thingy, attributes: true)])
|
26
|
+
|
27
|
+
Slipcover::Database.should_receive(:new).with(wrapper.database_name).and_return(database)
|
28
|
+
database.should_receive(:create)
|
29
|
+
wrapper.lookup
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "design document does not exist" do
|
34
|
+
it "saves the design document" do
|
35
|
+
Slipcover::Query.should_receive(:new).and_return(query)
|
36
|
+
query.should_receive(:all).ordered.and_raise(Slipcover::HttpAdapter::DocumentNotFound)
|
37
|
+
query.should_receive(:all).ordered.and_return([double(:thingy, attributes: true)])
|
38
|
+
|
39
|
+
Slipcover::DesignDocument.should_receive(:new).with(wrapper.database_name, wrapper.view_name, wrapper.view_dir).and_return(design_document)
|
40
|
+
design_document.should_receive(:save)
|
41
|
+
wrapper.lookup
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#initialize" do
|
47
|
+
before(:each) do
|
48
|
+
Slipcover::Config.stub(:view_dir).and_return("viewdir")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "uses the default view_dir if none is passed in" do
|
52
|
+
wrapper.view_dir.should_not == nil
|
53
|
+
wrapper.view_dir.should == Slipcover::Config.view_dir
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slipcover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kane Baccigalupi
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- spec/spec_helper.rb
|
123
123
|
- spec/support/slipcover.yml
|
124
124
|
- spec/support/slipcover_views/by_name/map.js
|
125
|
+
- spec/wrapper_spec.rb
|
125
126
|
homepage: http://github.com/socialchorus/slipcover
|
126
127
|
licenses:
|
127
128
|
- MIT
|
@@ -156,3 +157,4 @@ test_files:
|
|
156
157
|
- spec/spec_helper.rb
|
157
158
|
- spec/support/slipcover.yml
|
158
159
|
- spec/support/slipcover_views/by_name/map.js
|
160
|
+
- spec/wrapper_spec.rb
|