active_diigo 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -42,7 +42,7 @@ module ActiveDiigo
42
42
  end
43
43
 
44
44
  def parse!
45
- @parsed_response = JSON.parse(@raw_response)
45
+ @parsed_response = JSON.parse(@raw_response) rescue @raw_response.parsed_response
46
46
  end
47
47
 
48
48
  def validate_response!
@@ -2,6 +2,56 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "ActiveDiigo" do
4
4
 
5
+ describe ActiveDiigo do
6
+ before(:all) do
7
+ ActiveDiigo.api_key = 'TEST_API_KEY'
8
+ ActiveDiigo.username = 'test-user'
9
+ ActiveDiigo.password = 'test-pass'
10
+ end
11
+
12
+ it "should have api_key as an accessor" do
13
+ ActiveDiigo.should respond_to(:api_key)
14
+ ActiveDiigo.api_key.should == 'TEST_API_KEY'
15
+ end
16
+
17
+ it "should allow to set api_key" do
18
+ ActiveDiigo.should respond_to(:api_key)
19
+ ActiveDiigo.api_key = 'TEST_API_KEY_CHANGED'
20
+ ActiveDiigo.api_key.should == 'TEST_API_KEY_CHANGED'
21
+ end
22
+
23
+ it "should have username as an accessor" do
24
+ ActiveDiigo.should respond_to(:username)
25
+ ActiveDiigo.username.should == 'test-user'
26
+ end
27
+
28
+ it "should allow to set username" do
29
+ ActiveDiigo.should respond_to(:username)
30
+ ActiveDiigo.username = 'TEST_USER'
31
+ ActiveDiigo.username.should == 'TEST_USER'
32
+ end
33
+
34
+ it "should have password as an accessor" do
35
+ ActiveDiigo.should respond_to(:password)
36
+ ActiveDiigo.password.should == 'test-pass'
37
+ end
38
+
39
+ it "should allow to set password" do
40
+ ActiveDiigo.should respond_to(:password)
41
+ ActiveDiigo.password = 'TEST_PASS'
42
+ ActiveDiigo.password.should == 'TEST_PASS'
43
+ end
44
+
45
+ it "should respond version method" do
46
+ ActiveDiigo.should respond_to(:version)
47
+ end
48
+
49
+ it "should return current version of gem" do
50
+ ActiveDiigo.version.should == File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
51
+ end
52
+
53
+ end
54
+
5
55
  describe ActiveDiigo::Request do
6
56
  before(:all) do
7
57
  ActiveDiigo.api_key = 'TEST_API_KEY'
@@ -74,6 +124,61 @@ describe "ActiveDiigo" do
74
124
  response.size.should == 10
75
125
  end
76
126
 
127
+ it "should find bookmarks with user test-user and return 2 bookmarks" do
128
+ mock_request_for("https://test-user:test-pass@secure.diigo.com/api/v2/bookmarks?count=2&user=test-user&key=TEST_API_KEY",
129
+ :fixture => 'bookmarks_count')
130
+
131
+ response = ActiveDiigo::Base.find('test-user', :count => 2)
132
+ response.size.should == 2
133
+ end
134
+
135
+ it "should find bookmarks with specified tags" do
136
+ mock_request_for("https://test-user:test-pass@secure.diigo.com/api/v2/bookmarks?tags=mysql%2C%20rvm&user=test-user&key=TEST_API_KEY",
137
+ :fixture => 'bookmarks_with_tags')
138
+
139
+ response = ActiveDiigo::Base.find('test-user', :tags => 'mysql, rvm')
140
+ response.size.should == 1
141
+ response.first.tags.should include('mysql')
142
+ end
143
+
144
+ it "should find bookmarks that includes tags searched for" do
145
+ mock_request_for("https://test-user:test-pass@secure.diigo.com/api/v2/bookmarks?tags=mysql%2C%20rvm&user=test-user&key=TEST_API_KEY",
146
+ :fixture => 'bookmarks_with_tags')
147
+
148
+ response = ActiveDiigo::Base.find('test-user', :tags => 'mysql, rvm')
149
+ response.first.tags.should include('mysql')
150
+ response.first.tags.should include('rvm')
151
+ end
152
+
153
+ it "should save bookmark and should return success" do
154
+ mock_request_for("https://test-user:test-pass@secure.diigo.com/api/v2/bookmarks", :method => :post,
155
+ :fixture => 'save_success')
156
+ response = ActiveDiigo::Base.save('test-title', 'http://testtitle.com')
157
+ response["message"].should == "Saved 1 bookmark(s)"
158
+ response['code'].should == 1
159
+ end
160
+
161
+ it "should get ArgumentError while calling save without arguments" do
162
+ Proc.new do
163
+ response = ActiveDiigo::Base.save()
164
+ end.should raise_error(ArgumentError)
165
+ end
166
+
167
+ it "should return object of class that inherits ActiveDiigo::Base" do
168
+ class MyDiigo < ActiveDiigo::Base; end
169
+ mock_request_for("https://test-user:test-pass@secure.diigo.com/api/v2/bookmarks?user=test-user&key=TEST_API_KEY")
170
+
171
+ response = MyDiigo.find('test-user')
172
+ response.size.should == 10
173
+ response.first.should be_an_instance_of MyDiigo
174
+ end
175
+
176
+ it "should respond to all methods in class that inherits ActiveDiigo::Base" do
177
+ class MyDiigo < ActiveDiigo::Base; end
178
+ MyDiigo.should respond_to(:find)
179
+ MyDiigo.should respond_to(:save)
180
+ end
181
+
77
182
  end
78
183
 
79
184
  describe "Misc" do
metadata CHANGED
@@ -1,153 +1,101 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_diigo
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Bagwan Pankaj
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-02-02 00:00:00 +05:30
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- prerelease: false
12
+ date: 2011-02-02 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
24
15
  name: httparty
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2153176140 !ruby/object:Gem::Requirement
26
17
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
34
- requirement: *id001
35
- - !ruby/object:Gem::Dependency
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
36
22
  type: :runtime
37
23
  prerelease: false
24
+ version_requirements: *2153176140
25
+ - !ruby/object:Gem::Dependency
38
26
  name: json
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2153175660 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
48
- requirement: *id002
49
- - !ruby/object:Gem::Dependency
50
- type: :development
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
51
34
  prerelease: false
35
+ version_requirements: *2153175660
36
+ - !ruby/object:Gem::Dependency
52
37
  name: rspec
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2153175180 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
40
+ requirements:
56
41
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 11
59
- segments:
60
- - 2
61
- - 1
62
- - 0
42
+ - !ruby/object:Gem::Version
63
43
  version: 2.1.0
64
- requirement: *id003
65
- - !ruby/object:Gem::Dependency
66
44
  type: :development
67
45
  prerelease: false
46
+ version_requirements: *2153175180
47
+ - !ruby/object:Gem::Dependency
68
48
  name: yard
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2153174700 !ruby/object:Gem::Requirement
70
50
  none: false
71
- requirements:
51
+ requirements:
72
52
  - - ~>
73
- - !ruby/object:Gem::Version
74
- hash: 7
75
- segments:
76
- - 0
77
- - 6
78
- - 0
53
+ - !ruby/object:Gem::Version
79
54
  version: 0.6.0
80
- requirement: *id004
81
- - !ruby/object:Gem::Dependency
82
55
  type: :development
83
56
  prerelease: false
57
+ version_requirements: *2153174700
58
+ - !ruby/object:Gem::Dependency
84
59
  name: bundler
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &2153174220 !ruby/object:Gem::Requirement
86
61
  none: false
87
- requirements:
62
+ requirements:
88
63
  - - ~>
89
- - !ruby/object:Gem::Version
90
- hash: 23
91
- segments:
92
- - 1
93
- - 0
94
- - 0
64
+ - !ruby/object:Gem::Version
95
65
  version: 1.0.0
96
- requirement: *id005
97
- - !ruby/object:Gem::Dependency
98
- type: :development
99
- prerelease: false
100
- name: jeweler
101
- version_requirements: &id006 !ruby/object:Gem::Requirement
102
- none: false
103
- requirements:
104
- - - ~>
105
- - !ruby/object:Gem::Version
106
- hash: 7
107
- segments:
108
- - 1
109
- - 5
110
- - 2
111
- version: 1.5.2
112
- requirement: *id006
113
- - !ruby/object:Gem::Dependency
114
66
  type: :development
115
67
  prerelease: false
68
+ version_requirements: *2153174220
69
+ - !ruby/object:Gem::Dependency
116
70
  name: rcov
117
- version_requirements: &id007 !ruby/object:Gem::Requirement
71
+ requirement: &2153173740 !ruby/object:Gem::Requirement
118
72
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
126
- requirement: *id007
127
- - !ruby/object:Gem::Dependency
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
128
77
  type: :development
129
78
  prerelease: false
79
+ version_requirements: *2153173740
80
+ - !ruby/object:Gem::Dependency
130
81
  name: fakeweb
131
- version_requirements: &id008 !ruby/object:Gem::Requirement
82
+ requirement: &2153173260 !ruby/object:Gem::Requirement
132
83
  none: false
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- hash: 3
137
- segments:
138
- - 0
139
- version: "0"
140
- requirement: *id008
141
- description: "ActiveDiigo is a wrapper for Diigo API(version: v2)."
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *2153173260
91
+ description: ! 'ActiveDiigo is a wrapper for Diigo API(version: v2).'
142
92
  email: me@bagwanpankaj.com
143
93
  executables: []
144
-
145
94
  extensions: []
146
-
147
- extra_rdoc_files:
95
+ extra_rdoc_files:
148
96
  - LICENSE.txt
149
97
  - README.markdown
150
- files:
98
+ files:
151
99
  - LICENSE.txt
152
100
  - VERSION
153
101
  - lib/active_diigo.rb
@@ -159,41 +107,33 @@ files:
159
107
  - spec/active_diigo_spec.rb
160
108
  - spec/spec_helper.rb
161
109
  - spec/support/fake_web_stub.rb
162
- has_rdoc: true
163
110
  homepage: http://github.com/bagwanpankaj/active_diigo
164
- licenses:
111
+ licenses:
165
112
  - MIT
166
113
  post_install_message:
167
114
  rdoc_options: []
168
-
169
- require_paths:
115
+ require_paths:
170
116
  - lib
171
- required_ruby_version: !ruby/object:Gem::Requirement
117
+ required_ruby_version: !ruby/object:Gem::Requirement
172
118
  none: false
173
- requirements:
174
- - - ">="
175
- - !ruby/object:Gem::Version
176
- hash: 3
177
- segments:
178
- - 0
179
- version: "0"
180
- required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
124
  none: false
182
- requirements:
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- hash: 3
186
- segments:
187
- - 0
188
- version: "0"
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
189
129
  requirements: []
190
-
191
130
  rubyforge_project:
192
- rubygems_version: 1.3.7
131
+ rubygems_version: 1.8.10
193
132
  signing_key:
194
133
  specification_version: 3
195
134
  summary: Diigo Restful API wrapper; much like ActiveRecord
196
- test_files:
135
+ test_files:
197
136
  - spec/active_diigo_spec.rb
198
137
  - spec/spec_helper.rb
199
138
  - spec/support/fake_web_stub.rb
139
+ has_rdoc: