spec/zunnit_spec.rb in zunnit-0.2.0 vs spec/zunnit_spec.rb in zunnit-0.3.1
- old
+ new
@@ -1,93 +1,95 @@
# encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Zunnit do
# let(zunnit) { Zunnit::Api.new }
-
- describe "get" do
+
+ describe "get" do
it "should instanciate a Zunnit::Api object" do
default_key = Zunnit.key
default_client = Zunnit.client
default_version = Zunnit.version
-
+
zunnit = Zunnit::Api.new do |z|
z.key = "new-key"
z.version = "1.1"
end
-
+
zunnit.class.should == Zunnit::Api
zunnit.client.should == default_client
zunnit.key.should == "new-key"
zunnit.version.should == "1.1"
-
+
Zunnit.client.should == default_client
Zunnit.key.should == default_key
Zunnit.version.should == default_version
end
-
- it "should return related items" do
- response = Zunnit.api.get(:related_items,
- :item_id => "20275919", :user_id => "255")
- validate_response(response, :items)
- end
-
- it "should get 400 error if :item_id is not given to related items" do
- response = Zunnit.api.get(:related_items)
- response[:status].should == 400
- end
-
- it "should return recommendation items for user" do
- response = Zunnit.api.get(:recommendation_items_for_user,
- :user_id => "255")
- validate_response(response, :items)
- end
-
- it "should return recommendation groups for user" do
- pending "404"
- response = Zunnit.api.get(:recommendation_groups_for_user,
- :user_id => "255")
- validate_response(response, :groups)
- end
-
- it "should return recommendation users for user" do
- pending "404"
- response = Zunnit.api.get(:recommendation_groups_for_user,
- :user_id => "2155")
- validate_response(response, :users)
- end
-
- it "should return recommendation users for item" do
- pending "It should return a collection of users but is returning items"
- response = Zunnit.api.get(:recommendation_items_for_user,
- :item_id => "20275919", :user_id => "255")
- validate_response(response, :users)
- end
-
- it "should return recommendation tags for item" do
- pending "404"
- response = Zunnit.api.get(:recommendation_tags_for_item,
- :item_id => "20275919")
- validate_response(response, :tags)
- end
-
- it "should return recommendation cluster for item" do
- pending "404"
- response = Zunnit.api.get(:recommendation_cluster_for_item,
- :item_id => "20275919")
- validate_response(response, :clusters)
- end
- end
-
- describe "post" do
-
- end
-
- private
- def validate_response(response, results_key)
- response[:status].should == 200
- response[:msg].should == "Ok"
- response[results_key].size.should >= 1
- end
+ it "should return related items" do
+ response = Zunnit.api.get :related_items,
+ :item_id => "20275919",
+ :user_id => "255"
+ validate_response(response, :items)
+ end
+
+ it "should get 400 error if :item_id is not given to related items" do
+ response = Zunnit.api.get(:related_items)
+ response[:status].should == 400
+ end
+
+ it "should return recommendation items for user" do
+ response = Zunnit.api.get :recommendation_items_for_user,
+ :user_id => "255"
+ validate_response(response, :items)
+ end
+
+
+ it "should return recommendation groups for user" do
+ pending "404"
+ response = Zunnit.api.get :recommendation_groups_for_user,
+ :user_id => "255"
+ validate_response(response, :groups)
+ end
+
+ it "should return recommendation users for user" do
+ pending "404"
+ response = Zunnit.api.get :recommendation_groups_for_user,
+ :user_id => "2155"
+ validate_response(response, :users)
+ end
+
+ it "should return recommendation users for item" do
+ pending "It should return a collection of users but is returning items"
+ response = Zunnit.api.get :recommendation_items_for_user,
+ :item_id => "20275919",
+ :user_id => "255"
+ validate_response(response, :users)
+ end
+
+ it "should return recommendation tags for item" do
+ pending "404"
+ response = Zunnit.api.get :recommendation_tags_for_item,
+ :item_id => "20275919"
+ validate_response(response, :tags)
+ end
+
+ it "should return recommendation cluster for item" do
+ pending "404"
+ response = Zunnit.api.get :recommendation_cluster_for_item,
+ :item_id => "20275919"
+ validate_response(response, :clusters)
+ end
+ end
+
+describe "post" do
+
+end
+
+private
+def validate_response(response, results_key)
+response[:status].should == 200
+response[:msg].should == "Ok"
+response[results_key].size.should >= 1
+end
end