boombera 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/boombera.gemspec +2 -5
- data/spec/integration/boombera_spec.rb +108 -0
- metadata +6 -7
- data/bin/boombera +0 -26
- data/spec/bin/boombera_spec.rb +0 -121
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/boombera.gemspec
CHANGED
@@ -5,15 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{boombera}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Wilger"]
|
12
12
|
s.date = %q{2011-05-30}
|
13
|
-
s.default_executable = %q{boombera}
|
14
13
|
s.description = %q{CouchDB-backed content repository for multi-tenant, multi-stage applications}
|
15
14
|
s.email = %q{johnwilger@gmail.com}
|
16
|
-
s.executables = ["boombera"]
|
17
15
|
s.extra_rdoc_files = [
|
18
16
|
"LICENSE.txt",
|
19
17
|
"README.rdoc"
|
@@ -29,11 +27,10 @@ Gem::Specification.new do |s|
|
|
29
27
|
"README.rdoc",
|
30
28
|
"Rakefile",
|
31
29
|
"VERSION",
|
32
|
-
"bin/boombera",
|
33
30
|
"boombera.gemspec",
|
34
31
|
"lib/boombera.rb",
|
35
32
|
"lib/boombera/content_item.rb",
|
36
|
-
"spec/
|
33
|
+
"spec/integration/boombera_spec.rb",
|
37
34
|
"spec/lib/boombera/content_item_spec.rb",
|
38
35
|
"spec/lib/boombera_spec.rb",
|
39
36
|
"spec/spec_helper.rb"
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe 'The Boombera library:' do
|
4
|
+
let(:db_name) { 'boombera_test' }
|
5
|
+
let(:db) { CouchRest.database!(db_name) }
|
6
|
+
|
7
|
+
let(:boombera) do
|
8
|
+
Boombera.install_design_doc!(db_name)
|
9
|
+
Boombera.new(db_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
db.delete!
|
14
|
+
db.create!
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'installing and updating the couchdb design document' do
|
18
|
+
context 'on a new boombera database' do
|
19
|
+
it 'publishes Boombera.design_doc to _design/boombera' do
|
20
|
+
Boombera.install_design_doc!(db_name)
|
21
|
+
design = db.get('_design/boombera')
|
22
|
+
%w(_id gem_version views).each do |key|
|
23
|
+
design[key].should == Boombera.design_doc[key]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'on an existing boombera database' do
|
29
|
+
it 'updates Boombera.design_doc to _design/boombera' do
|
30
|
+
db.save_doc({'_id' => '_design/boombera'})
|
31
|
+
Boombera.install_design_doc!(db_name)
|
32
|
+
design = db.get('_design/boombera')
|
33
|
+
%w(_id gem_version views).each do |key|
|
34
|
+
design[key].should == Boombera.design_doc[key]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'connecting to the database' do
|
41
|
+
context 'when the design document does not exist' do
|
42
|
+
it 'raises a VersionMismatch exception' do
|
43
|
+
lambda { Boombera.new(db_name) }.should \
|
44
|
+
raise_error(Boombera::VersionMismatch, "Database does not specify a Boombera version")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when the design document does not have a gem_version specified' do
|
49
|
+
it 'raises a VersionMismatch exception' do
|
50
|
+
db.save_doc({'_id' => '_design/boombera'})
|
51
|
+
lambda { Boombera.new(db_name) }.should \
|
52
|
+
raise_error(Boombera::VersionMismatch, "Database does not specify a Boombera version")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when the design document does not match the version of the library being used' do
|
57
|
+
it 'raises a VersionMismatch exception' do
|
58
|
+
db.save_doc({'_id' => '_design/boombera', 'gem_version' => '0.0.0'})
|
59
|
+
lambda { Boombera.new(db_name) }.should \
|
60
|
+
raise_error(Boombera::VersionMismatch, "Database expects Boombera 0.0.0")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'putting content in the database' do
|
66
|
+
it 'saves content to a new path' do
|
67
|
+
boombera.put('/foo', 'foo bar baz')
|
68
|
+
results = db.view('boombera/content_map', :key => '/foo')['rows']
|
69
|
+
results.length.should == 1
|
70
|
+
document = db.get(results.first['id'])
|
71
|
+
document['path'].should == '/foo'
|
72
|
+
document['body'].should == 'foo bar baz'
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'saves content to an existing path' do
|
76
|
+
boombera.put('/foo', 'foo bar baz')
|
77
|
+
boombera.put('/foo', 'the new content')
|
78
|
+
results = db.view('boombera/content_map', :key => '/foo')['rows']
|
79
|
+
results.length.should == 1
|
80
|
+
document = db.get(results.first['id'])
|
81
|
+
document['path'].should == '/foo'
|
82
|
+
document['body'].should == 'the new content'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'getting content from the database' do
|
87
|
+
it 'gives you nil if the content is not there' do
|
88
|
+
boombera.get('/not_there').should == nil
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'gives you a ContentItem if the content is there' do
|
92
|
+
db.save_doc({'path' => '/index', 'body' => 'Hello, World!'})
|
93
|
+
result = boombera.get('/index')
|
94
|
+
result.path.should == '/index'
|
95
|
+
result.body.should == 'Hello, World!'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'working with ContentItem' do
|
100
|
+
it 'lets you save changes' do
|
101
|
+
boombera.put('/foo', 'some content')
|
102
|
+
content = boombera.get('/foo')
|
103
|
+
content.body = 'new content'
|
104
|
+
content.save
|
105
|
+
boombera.get('/foo').body.should == 'new content'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: boombera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Wilger
|
@@ -11,7 +11,7 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
|
13
13
|
date: 2011-05-30 00:00:00 -07:00
|
14
|
-
default_executable:
|
14
|
+
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: couchrest
|
@@ -125,8 +125,8 @@ dependencies:
|
|
125
125
|
version_requirements: *id010
|
126
126
|
description: CouchDB-backed content repository for multi-tenant, multi-stage applications
|
127
127
|
email: johnwilger@gmail.com
|
128
|
-
executables:
|
129
|
-
|
128
|
+
executables: []
|
129
|
+
|
130
130
|
extensions: []
|
131
131
|
|
132
132
|
extra_rdoc_files:
|
@@ -143,11 +143,10 @@ files:
|
|
143
143
|
- README.rdoc
|
144
144
|
- Rakefile
|
145
145
|
- VERSION
|
146
|
-
- bin/boombera
|
147
146
|
- boombera.gemspec
|
148
147
|
- lib/boombera.rb
|
149
148
|
- lib/boombera/content_item.rb
|
150
|
-
- spec/
|
149
|
+
- spec/integration/boombera_spec.rb
|
151
150
|
- spec/lib/boombera/content_item_spec.rb
|
152
151
|
- spec/lib/boombera_spec.rb
|
153
152
|
- spec/spec_helper.rb
|
@@ -165,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
164
|
requirements:
|
166
165
|
- - ">="
|
167
166
|
- !ruby/object:Gem::Version
|
168
|
-
hash: -
|
167
|
+
hash: -3756736400322567909
|
169
168
|
segments:
|
170
169
|
- 0
|
171
170
|
version: "0"
|
data/bin/boombera
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
3
|
-
require 'boombera'
|
4
|
-
|
5
|
-
command, database, path, body = ARGV[0..3]
|
6
|
-
|
7
|
-
begin
|
8
|
-
case command
|
9
|
-
when 'install'
|
10
|
-
Boombera.install_design_doc!(database)
|
11
|
-
puts "The CouchDB Boombera application has been updated to version #{Boombera.version}"
|
12
|
-
when 'put'
|
13
|
-
db = Boombera.new(database)
|
14
|
-
result = db.put(path, body)
|
15
|
-
puts "Content Saved: #{path}"
|
16
|
-
when 'get'
|
17
|
-
db = Boombera.new(database)
|
18
|
-
result = db.get(path)
|
19
|
-
puts result.body
|
20
|
-
end
|
21
|
-
rescue Boombera::VersionMismatch => e
|
22
|
-
puts e.message
|
23
|
-
puts "You may need to run 'boombera install #{database}' to update the"
|
24
|
-
puts "CouchDB Boombera application."
|
25
|
-
exit(1)
|
26
|
-
end
|
data/spec/bin/boombera_spec.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
-
|
3
|
-
describe "The boombera CLI" do
|
4
|
-
BOOMBERA_CLI = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'boombera')
|
5
|
-
|
6
|
-
let(:db) { CouchRest.database!('boombera_test') }
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
db.delete!
|
10
|
-
Boombera.install_design_doc!('boombera_test')
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "put command" do
|
14
|
-
context "when putting a new content item via argument string" do
|
15
|
-
|
16
|
-
before(:each) do
|
17
|
-
@output = `#{BOOMBERA_CLI} put boombera_test /foo "some content"`
|
18
|
-
@exit_status = $?.exitstatus
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'exits with a status code of 0' do
|
22
|
-
@exit_status.should == 0
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'outputs a message indicating that the content was saved' do
|
26
|
-
@output.should == "Content Saved: /foo\n"
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'creates the content in the couchdb server' do
|
30
|
-
result = db.view('boombera/content_map', :key => '/foo')['rows'].first
|
31
|
-
result.should_not be_nil
|
32
|
-
document = db.get(result['id'])
|
33
|
-
document['path'].should == '/foo'
|
34
|
-
document['body'].should == 'some content'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "when updating an existing content item via argument string" do
|
39
|
-
before(:each) do
|
40
|
-
db.save_doc({:path => '/bar', :body => 'original content'})
|
41
|
-
@output = `#{BOOMBERA_CLI} put boombera_test /bar "new content"`
|
42
|
-
@exit_status = $?.exitstatus
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'exits with a status code of 0' do
|
46
|
-
@exit_status.should == 0
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'outputs a message indicating that the content was saved' do
|
50
|
-
@output.should == "Content Saved: /bar\n"
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'updates the content in the couchdb server' do
|
54
|
-
rows = db.view('boombera/content_map', :key => '/bar')['rows']
|
55
|
-
rows.length.should == 1
|
56
|
-
result = rows.first
|
57
|
-
result.should_not be_nil
|
58
|
-
document = db.get(result['id'])
|
59
|
-
document['path'].should == '/bar'
|
60
|
-
document['body'].should == 'new content'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe 'get command' do
|
66
|
-
context 'the requested content exists' do
|
67
|
-
before(:each) do
|
68
|
-
`#{BOOMBERA_CLI} put boombera_test /foo "some content"`
|
69
|
-
@output = `#{BOOMBERA_CLI} get boombera_test /foo`
|
70
|
-
@exit_status = $?.exitstatus
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'exits with a status code of 0' do
|
74
|
-
@exit_status.should == 0
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'outputs the document body to STDOUT' do
|
78
|
-
@output.should == "some content\n"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "install command" do
|
84
|
-
before(:each) do
|
85
|
-
db.delete!
|
86
|
-
@output = `#{BOOMBERA_CLI} install boombera_test`
|
87
|
-
@exit_status = $?.exitstatus
|
88
|
-
end
|
89
|
-
|
90
|
-
shared_examples_for :a_successful_instalation do
|
91
|
-
it 'exits with a status code of 0' do
|
92
|
-
@exit_status.should == 0
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'outputs a message indicating that the CouchDB portion of the Boombera application was installed' do
|
96
|
-
@output.should == "The CouchDB Boombera application has been updated to " \
|
97
|
-
+ "version #{Boombera.version}\n"
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'installs the boombera design document on the CouchDB instance' do
|
101
|
-
design_doc = db.get('_design/boombera')
|
102
|
-
expected = Boombera.design_doc
|
103
|
-
design_doc['gem_version'].should == expected['gem_version']
|
104
|
-
design_doc['views'].should == expected['views']
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'when run for the first time' do
|
109
|
-
it_should_behave_like :a_successful_instalation
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'when run more than once' do
|
113
|
-
before(:each) do
|
114
|
-
@output = `#{BOOMBERA_CLI} install boombera_test`
|
115
|
-
@exit_status = $?.exitstatus
|
116
|
-
end
|
117
|
-
|
118
|
-
it_should_behave_like :a_successful_instalation
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|