spec/zunnit_spec.rb in zunnit-0.1.1 vs spec/zunnit_spec.rb in zunnit-0.2.0

- old
+ new

@@ -2,67 +2,79 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Zunnit do # let(zunnit) { Zunnit::Api.new } - describe "get" do - it "should return related items" do - zunnit = Zunnit::Api.new - response = zunnit.get(:related_items, + 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 - zunnit = Zunnit::Api.new - response = zunnit.get(:related_items) + response = Zunnit.api.get(:related_items) response[:status].should == 400 end it "should return recommendation items for user" do - zunnit = Zunnit::Api.new - response = zunnit.get(:recommendation_items_for_user, + 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" - zunnit = Zunnit::Api.new - response = zunnit.get(:recommendation_groups_for_user, + 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" - zunnit = Zunnit::Api.new - response = zunnit.get(:recommendation_groups_for_user, + 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" - zunnit = Zunnit::Api.new - response = zunnit.get(:recommendation_items_for_user, + 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" - zunnit = Zunnit::Api.new - response = zunnit.get(:recommendation_tags_for_item, + 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" - zunnit = Zunnit::Api.new - response = zunnit.get(:recommendation_cluster_for_item, + response = Zunnit.api.get(:recommendation_cluster_for_item, :item_id => "20275919") validate_response(response, :clusters) end end