Skip to content

Commit

Permalink
test running now
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro Oniszczuk committed Aug 15, 2011
1 parent fd00b69 commit 67feb89
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/indextank/document.rb
Expand Up @@ -26,7 +26,7 @@ def add(fields, options = {})
req.body = options.to_json
end

resp.status
resp.status
end

def delete(options = {})
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/indextank/document_spec.rb
Expand Up @@ -3,7 +3,7 @@
describe IndexTank::Document do
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
let(:document) { IndexTank::Client.new("http://:xxxx@dstqe.api.indextank.com").indexes('new-index').document('document1') }
let(:path_prefix) { '/v1/indexes/new-index/docs/' }
let(:path_prefix) { '/v1/indexes/new-index/docs' }

before { stub_setup_connection do |builder| builder.use IndexTank::DocumentResponseMiddleware; end }

Expand Down Expand Up @@ -106,15 +106,15 @@

context "variables indexed" do
before do
stubs.put("#{path_prefix}variables") { [200, {}, ''] }
stubs.put("#{path_prefix}/variables") { [200, {}, ''] }
end

it { should be_true }
end

context "index is initializing" do
before do
stubs.put("#{path_prefix}variables") { [409, {}, ''] }
stubs.put("#{path_prefix}/variables") { [409, {}, ''] }
end

it "should raise an exception" do
Expand All @@ -124,7 +124,7 @@

context "invalid or missing argument" do
before do
stubs.put("#{path_prefix}variables") { [400, {}, ''] }
stubs.put("#{path_prefix}/variables") { [400, {}, ''] }
end

it "should raise an exception" do
Expand All @@ -134,7 +134,7 @@

context "no index existed for the given name" do
before do
stubs.put("#{path_prefix}variables") { [404, {}, ''] }
stubs.put("#{path_prefix}/variables") { [404, {}, ''] }
end

it "should raise an exception" do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/indextank/function_spec.rb
Expand Up @@ -3,7 +3,7 @@
describe IndexTank::Function do
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
let(:function) { IndexTank::Client.new("http://:xxxx@dstqe.api.indextank.com").indexes('new-index').functions(0, '-age') }
let(:path_prefix) { '/v1/indexes/new-index/functions/0/' }
let(:path_prefix) { '/v1/indexes/new-index/functions/0' }

before { stub_setup_connection do |builder| builder.use IndexTank::DocumentResponseMiddleware; end}

Expand Down
24 changes: 13 additions & 11 deletions spec/lib/indextank/index_spec.rb
Expand Up @@ -4,7 +4,7 @@
describe IndexTank::Index do
let(:stubs) { Faraday::Adapter::Test::Stubs.new }
let(:index) { IndexTank::Client.new("http://:xxxx@dstqe.api.indextank.com").indexes('new-index') }
let(:path_prefix) { '/v1/indexes/new-index/' }
let(:path_prefix) { '/v1/indexes/new-index' }

before { stub_setup_connection }

Expand All @@ -17,6 +17,7 @@

context "the index does not exist" do
before do
stubs.get(path_prefix) { [404, {}, ''] }
stubs.put(path_prefix) { [201, {}, '{"started": false, "code": "dsyaj", "creation_time": "2010-08-14T13:01:48.454624", "size": 0}'] }
end

Expand All @@ -26,7 +27,7 @@
context "when an index already exists" do
before do
# @index.add
stubs.put(path_prefix) { [204, {}, ''] }
stubs.get(path_prefix) { [200, {}, '{"started": true, "code": "dsyaj", "creation_time": "2010-08-14T13:01:48.454624", "size": 0}'] }
end

it "should raise an exception" do
Expand All @@ -36,6 +37,7 @@

context "when the user has too many indexes" do
before do
stubs.get(path_prefix) { [404, {}, ''] }
stubs.put(path_prefix) { [409, {}, ''] }
end

Expand Down Expand Up @@ -144,7 +146,7 @@

context "search is successful" do
before do
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [200, {}, '{"matches": 4, "search_time": "0.022", "results": [{"docid": "http://cnn.com/HEALTH"}, {"docid": "http://www.cnn.com/HEALTH/"}, {"docid": "http://cnn.com/HEALTH/?hpt=Sbin"}, {"docid": "http://cnn.com/HEALTH/"}]}'] }
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [200, {}, '{"matches": 4, "search_time": "0.022", "results": [{"docid": "http://cnn.com/HEALTH"}, {"docid": "http://www.cnn.com/HEALTH/"}, {"docid": "http://cnn.com/HEALTH/?hpt=Sbin"}, {"docid": "http://cnn.com/HEALTH/"}]}'] }
end

it "should have the number of matches" do
Expand All @@ -165,7 +167,7 @@

context "index is initializing" do
before do
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [409, {}, ''] }
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [409, {}, ''] }
end

it "should return raise an exception" do
Expand All @@ -175,7 +177,7 @@

context "index is invalid/missing argument" do
before do
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [400, {}, ''] }
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [400, {}, ''] }
end

it "should return raise an exception" do
Expand All @@ -185,7 +187,7 @@

context "no index existed for the given name" do
before do
stubs.get("#{path_prefix}search?len=10&q=foo&start=0") { [404, {}, ''] }
stubs.get("#{path_prefix}/search?len=10&q=foo&start=0") { [404, {}, ''] }
end

it "should return raise an exception" do
Expand All @@ -199,15 +201,15 @@

context "when the document is promoted" do
before do
stubs.put("#{path_prefix}promote", Yajl::dump({"docid" => "4", "query" =>"foo"})) { [200, {}, ''] }
stubs.put("#{path_prefix}/promote", Yajl::dump({"docid" => "4", "query" =>"foo"})) { [200, {}, ''] }
end

it { should be_nil }
end

context "when the index is initializing" do
before do
stubs.put("#{path_prefix}promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [409, {}, ''] }
stubs.put("#{path_prefix}/promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [409, {}, ''] }
end

it "should raise an exception" do
Expand All @@ -217,7 +219,7 @@

context "when invalid or missing argument" do
before do
stubs.put("#{path_prefix}promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [400, {}, ''] }
stubs.put("#{path_prefix}/promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [400, {}, ''] }
end

it "should raise an exception" do
Expand All @@ -227,7 +229,7 @@

context "when no index exists for the given name" do
before do
stubs.put("#{path_prefix}promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [404, {}, ''] }
stubs.put("#{path_prefix}/promote", body=Yajl::dump({"docid" => "4", "query" =>"foo"})) { [404, {}, ''] }
end

it "should raise an exception" do
Expand All @@ -250,7 +252,7 @@
subject { index.functions }

before do
stubs.get("#{path_prefix}functions") { [200, {}, '{"0": "0-A", "1": "-age", "2": "relevance"}'] }
stubs.get("#{path_prefix}/functions") { [200, {}, '{"0": "0-A", "1": "-age", "2": "relevance"}'] }
end

it "should return an array of functions" do
Expand Down

0 comments on commit 67feb89

Please sign in to comment.