zunnit 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -2
- data/lib/zunnit/version.rb +1 -1
- data/lib/zunnit.rb +1 -0
- data/spec/zunnit_spec.rb +34 -8
- data/zunnit.gemspec +1 -0
- metadata +12 -1
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zunnit (0.3.
|
4
|
+
zunnit (0.3.1)
|
5
5
|
faraday
|
6
6
|
|
7
7
|
GEM
|
@@ -9,7 +9,8 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
addressable (2.2.6)
|
11
11
|
diff-lcs (1.1.2)
|
12
|
-
|
12
|
+
fakeweb (1.3.0)
|
13
|
+
faraday (0.7.3)
|
13
14
|
addressable (~> 2.2.6)
|
14
15
|
multipart-post (~> 1.1.0)
|
15
16
|
rack (>= 1.1.0, < 2)
|
@@ -28,5 +29,6 @@ PLATFORMS
|
|
28
29
|
ruby
|
29
30
|
|
30
31
|
DEPENDENCIES
|
32
|
+
fakeweb
|
31
33
|
rspec
|
32
34
|
zunnit!
|
data/lib/zunnit/version.rb
CHANGED
data/lib/zunnit.rb
CHANGED
data/spec/zunnit_spec.rb
CHANGED
@@ -81,15 +81,41 @@ describe Zunnit do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
describe "post" do
|
84
|
+
describe "post" do
|
85
|
+
it "should return status 200 when add an item" do
|
86
|
+
intercept_resquest_to :post,
|
87
|
+
:action => :action_items_add,
|
88
|
+
:params => { :item_id => "2121", :item_text => "text" },
|
89
|
+
:response => { :status => 200, :body => {:msg => 'Ok', :status => 200}.to_json }
|
90
|
+
|
91
|
+
validate_response Zunnit.api.post :action_items_add, :item_id => "2121", :item_text => "text"
|
92
|
+
end
|
85
93
|
|
86
|
-
|
94
|
+
it "should return status 200 when user clip an item" do
|
95
|
+
intercept_resquest_to :post,
|
96
|
+
:action => :action_items_rate,
|
97
|
+
:params => { :item_id => "2121", :user_id => "2121", :rating => 1 },
|
98
|
+
:response => { :status => 200, :body => {:msg => 'Ok', :status => 200}.to_json }
|
87
99
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
100
|
+
validate_response Zunnit.api.post :action_items_rate, :item_id => "2121", :user_id => "2121"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
def validate_response(response, results_key = nil)
|
107
|
+
response[:status].should == 200
|
108
|
+
response[:msg].should == "Ok"
|
109
|
+
response[results_key].size.should >= 1 if results_key
|
110
|
+
end
|
111
|
+
|
112
|
+
def intercept_resquest_to(method, options)
|
113
|
+
action = options.delete(:action)
|
114
|
+
params = options.delete(:params)
|
115
|
+
response = options.delete(:response)
|
116
|
+
uri = "#{Zunnit::URL}#{Zunnit.client}#{Zunnit.actions[action]}"
|
117
|
+
uri = uri + params.map {|k,v| "#{k}=#{v}" }.join("&") unless method.to_s =~ /post|put/
|
118
|
+
FakeWeb.register_uri(method, uri, response)
|
119
|
+
end
|
94
120
|
end
|
95
121
|
|
data/zunnit.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: zunnit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Marcelo Eden
|
@@ -35,6 +35,17 @@ dependencies:
|
|
35
35
|
version: "0"
|
36
36
|
type: :development
|
37
37
|
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: fakeweb
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
38
49
|
description: Gem do access zunnit's API
|
39
50
|
email:
|
40
51
|
- marcelo@busk.com
|