zunnit 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zunnit (0.1.0)
4
+ zunnit (0.2.0)
5
5
  faraday
6
6
 
7
7
  GEM
data/lib/zunnit/api.rb CHANGED
@@ -1,4 +1,11 @@
1
- module Zunnit
1
+ module Zunnit
2
+
3
+ # Singleton API Accessor
4
+ def self.api
5
+ @api ||= Api.new
6
+ end
7
+
8
+ # API Class
2
9
  class Api
3
10
  attr_accessor :client, :key, :version
4
11
 
@@ -1,4 +1,4 @@
1
1
  module Zunnit
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
4
4
 
data/spec/zunnit_spec.rb CHANGED
@@ -4,23 +4,40 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
4
  describe Zunnit do
5
5
  # let(zunnit) { Zunnit::Api.new }
6
6
 
7
- describe "get" do
8
- it "should return related items" do
9
- zunnit = Zunnit::Api.new
10
- response = zunnit.get(:related_items,
7
+ describe "get" do
8
+ it "should instanciate a Zunnit::Api object" do
9
+ default_key = Zunnit.key
10
+ default_client = Zunnit.client
11
+ default_version = Zunnit.version
12
+
13
+ zunnit = Zunnit::Api.new do |z|
14
+ z.key = "new-key"
15
+ z.version = "1.1"
16
+ end
17
+
18
+ zunnit.class.should == Zunnit::Api
19
+ zunnit.client.should == default_client
20
+ zunnit.key.should == "new-key"
21
+ zunnit.version.should == "1.1"
22
+
23
+ Zunnit.client.should == default_client
24
+ Zunnit.key.should == default_key
25
+ Zunnit.version.should == default_version
26
+ end
27
+
28
+ it "should return related items" do
29
+ response = Zunnit.api.get(:related_items,
11
30
  :item_id => "20275919", :user_id => "255")
12
31
  validate_response(response, :items)
13
32
  end
14
33
 
15
34
  it "should get 400 error if :item_id is not given to related items" do
16
- zunnit = Zunnit::Api.new
17
- response = zunnit.get(:related_items)
35
+ response = Zunnit.api.get(:related_items)
18
36
  response[:status].should == 400
19
37
  end
20
38
 
21
39
  it "should return recommendation items for user" do
22
- zunnit = Zunnit::Api.new
23
- response = zunnit.get(:recommendation_items_for_user,
40
+ response = Zunnit.api.get(:recommendation_items_for_user,
24
41
  :user_id => "255")
25
42
  validate_response(response, :items)
26
43
  end
@@ -28,40 +45,35 @@ describe Zunnit do
28
45
 
29
46
  it "should return recommendation groups for user" do
30
47
  pending "404"
31
- zunnit = Zunnit::Api.new
32
- response = zunnit.get(:recommendation_groups_for_user,
48
+ response = Zunnit.api.get(:recommendation_groups_for_user,
33
49
  :user_id => "255")
34
50
  validate_response(response, :groups)
35
51
  end
36
52
 
37
53
  it "should return recommendation users for user" do
38
54
  pending "404"
39
- zunnit = Zunnit::Api.new
40
- response = zunnit.get(:recommendation_groups_for_user,
55
+ response = Zunnit.api.get(:recommendation_groups_for_user,
41
56
  :user_id => "2155")
42
57
  validate_response(response, :users)
43
58
  end
44
59
 
45
60
  it "should return recommendation users for item" do
46
61
  pending "It should return a collection of users but is returning items"
47
- zunnit = Zunnit::Api.new
48
- response = zunnit.get(:recommendation_items_for_user,
62
+ response = Zunnit.api.get(:recommendation_items_for_user,
49
63
  :item_id => "20275919", :user_id => "255")
50
64
  validate_response(response, :users)
51
65
  end
52
66
 
53
67
  it "should return recommendation tags for item" do
54
68
  pending "404"
55
- zunnit = Zunnit::Api.new
56
- response = zunnit.get(:recommendation_tags_for_item,
69
+ response = Zunnit.api.get(:recommendation_tags_for_item,
57
70
  :item_id => "20275919")
58
71
  validate_response(response, :tags)
59
72
  end
60
73
 
61
74
  it "should return recommendation cluster for item" do
62
75
  pending "404"
63
- zunnit = Zunnit::Api.new
64
- response = zunnit.get(:recommendation_cluster_for_item,
76
+ response = Zunnit.api.get(:recommendation_cluster_for_item,
65
77
  :item_id => "20275919")
66
78
  validate_response(response, :clusters)
67
79
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: zunnit
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Marcelo Eden
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-21 00:00:00 -03:00
13
+ date: 2011-06-23 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency