-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
694 additions
and
658 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour --format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,5 @@ | |
|
||
[ ] netp : close() impl | ||
|
||
[ ] views : couch#query(view, opts) ? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
|
||
# | ||
# specifying rufus-jig | ||
# | ||
# Tue Nov 30 09:12:59 JST 2010 | ||
# | ||
|
||
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') | ||
|
||
|
||
describe Rufus::Jig::Couch do | ||
|
||
context 'with attachments' do | ||
|
||
before(:each) do | ||
|
||
h = Rufus::Jig::Http.new(couch_url) | ||
begin | ||
h.delete('/rufus_jig_test') | ||
rescue Exception => e | ||
#p e | ||
end | ||
|
||
h.put('/rufus_jig_test', '') | ||
h.close | ||
|
||
@c = Rufus::Jig::Couch.new(couch_url, 'rufus_jig_test') | ||
|
||
@c.put('_id' => 'thedoc', 'function' => 'recipient for attachements') | ||
@d = @c.get('thedoc') | ||
end | ||
|
||
after(:each) do | ||
|
||
@c.close | ||
end | ||
|
||
describe '#attach' do | ||
|
||
it 'attaches' do | ||
|
||
@c.attach( | ||
'thedoc', @d['_rev'], 'message', 'this is a message', | ||
:content_type => 'text/plain') | ||
|
||
@c.get('thedoc/message').should == 'this is a message' | ||
end | ||
|
||
it 'attaches with the right content-type' do | ||
|
||
@c.attach( | ||
'thedoc', @d['_rev'], 'message', 'this is a message', | ||
:content_type => 'text/plain') | ||
|
||
r = @c.get('thedoc/message', :raw => true) | ||
r.status.should == 200 | ||
r.headers['Content-Type'].should == 'text/plain' | ||
end | ||
|
||
it 'returns the couch response' do | ||
|
||
r = @c.attach( | ||
'thedoc', @d['_rev'], 'message', 'this is a message', | ||
:content_type => 'text/plain') | ||
|
||
r.keys.sort.should == %w[ id ok rev ] | ||
end | ||
|
||
it 'raises if it failed' do | ||
|
||
lambda { | ||
@c.attach( | ||
'thedoc', '999-123e', 'message', 'this is a message', | ||
:content_type => 'text/plain') | ||
}.should raise_error | ||
end | ||
end | ||
|
||
describe '#detach' do | ||
|
||
before (:each) do | ||
|
||
r = @c.attach( | ||
'thedoc', @d['_rev'], | ||
'image', File.read(File.join(File.dirname(__FILE__), 'tweet.png')), | ||
:content_type => 'image/png') | ||
@d['_rev'] = r['rev'] | ||
end | ||
|
||
it 'detaches' do | ||
|
||
@c.detach('thedoc', @d['_rev'], 'image') | ||
|
||
@c.get('thedoc/image').should == nil | ||
end | ||
|
||
it 'returns the couch response' do | ||
|
||
r = @c.detach('thedoc', @d['_rev'], 'image') | ||
|
||
r.keys.sort.should == %w[ id ok rev ] | ||
end | ||
|
||
it 'raises if it failed' do | ||
|
||
lambda { | ||
@c.detach('thedoc', '999-12340e', 'image') | ||
}.should raise_error | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# encoding: UTF-8 | ||
|
||
# | ||
# specifying rufus-jig | ||
# | ||
# Tue Nov 30 10:16:03 JST 2010 | ||
# | ||
|
||
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') | ||
|
||
|
||
describe Rufus::Jig::Couch do | ||
|
||
context 'and feed=continuous' do | ||
|
||
before(:each) do | ||
|
||
h = Rufus::Jig::Http.new(couch_url) | ||
|
||
begin | ||
h.delete('/rufus_jig_test') | ||
rescue Exception => e | ||
#p e | ||
end | ||
h.put('/rufus_jig_test', '') | ||
h.close | ||
|
||
@c = Rufus::Jig::Couch.new(couch_url, 'rufus_jig_test') | ||
end | ||
|
||
after(:each) do | ||
|
||
@c.close | ||
end | ||
|
||
describe '#on_change' do | ||
|
||
it 'intercepts changes' do | ||
|
||
stack = [] | ||
|
||
t = Thread.new do | ||
@c.on_change { |doc_id, deleted| stack << doc_id } | ||
end | ||
|
||
@c.put('_id' => 'angel0', 'name' => 'samael') | ||
@c.put('_id' => 'angel1', 'name' => 'raphael') | ||
|
||
sleep 0.500 | ||
t.kill | ||
|
||
stack.size.should == 2 | ||
end | ||
|
||
it 'intercepts changes and docs' do | ||
|
||
stack = [] | ||
|
||
Thread.abort_on_exception = true | ||
|
||
t = Thread.new do | ||
@c.on_change { |doc_id, deleted, doc| stack << doc } | ||
end | ||
|
||
@c.put('_id' => 'angel2', 'name' => 'samael') | ||
@c.put('_id' => 'angel3', 'name' => 'ゆきひろ') | ||
|
||
sleep 0.500 | ||
t.kill | ||
|
||
stack[1]['name'].should == 'ゆきひろ' | ||
end | ||
|
||
it 'intercepts changes and among them, doc deletions' do | ||
|
||
stack = [] | ||
|
||
Thread.abort_on_exception = true | ||
|
||
t = Thread.new do | ||
@c.on_change { |doc_id, deleted, doc| stack << [ doc_id, deleted ] } | ||
end | ||
|
||
@c.put('_id' => 'angel4', 'name' => 'samael') | ||
sleep 0.077 | ||
@c.delete(@c.get('angel4')) | ||
|
||
sleep 0.500 | ||
t.kill | ||
|
||
([["angel4", false], ["angel4", true]] == stack || | ||
[["angel4", true]] == stack).should == true | ||
end | ||
end | ||
end | ||
end | ||
|
Oops, something went wrong.