shortly 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a1da9df6df9580e9a5ac2858d19f0c36652f1d8
4
- data.tar.gz: 2deb47bb0e8ef4655ea042433bb1cb5ed27a71f9
3
+ metadata.gz: 2e60f051f3f6369b07920ec839acc557f1fd8ace
4
+ data.tar.gz: 4c17b8dfcb2452cfa723c519a5acd9cef5779d73
5
5
  SHA512:
6
- metadata.gz: b6dd8c828081cc9a7424426caf6e1f63a83d9a31a9d0515e24fa2b9191e090dd772a5fb6be257232c8fec932aa87c70bd07488456b9f6837757fe848d854404c
7
- data.tar.gz: e06e14199445b72d8d5384aa43c648ea7c2153794c71bac9fd5641b7f8f41aec67165a17c96c4df3fe82597f5031e9c24bc0913f2adbbe9223c827b19a649cdd
6
+ metadata.gz: 4e856b9c0c725b1e992b8440103137242ef1fe2aef54c6fa3832cbba3a75500722810340092ef1a7ae6f9eb9ba08d57a0ab71607d074215d2cc1812b92f6c5d2
7
+ data.tar.gz: c7765e132eecf30d6aec1919a74635fde0d24e6fca13b6d1b0dd1058fd5dfac9cc2208986c2cf812700efa2bbe5c534d70d13188d452bef9a160e7ab23569267
@@ -1,13 +1,17 @@
1
1
  # Shortly
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/shortly.png)](http://badge.fury.io/rb/shortly)
4
+
5
+ [![Build Status](https://travis-ci.org/bagwanpankaj/shortly.svg?branch=master)](https://travis-ci.org/bagwanpankaj/shortly)
6
+
3
7
  <a style="float:right" href='https://pledgie.com/campaigns/24609'><img alt='Click here to lend your support to: Shortly and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/24609.png?skin_name=chrome' border='0' ></a><div style="clear:both"></div>
4
-
5
- ____ _ _ _
6
- / ___|| |__ ___ _ __| |_| |_ _
8
+
9
+ ____ _ _ _
10
+ / ___|| |__ ___ _ __| |_| |_ _
7
11
  \___ \| '_ \ / _ \| '__| __| | | | |
8
12
  ___) | | | | (_) | | | |_| | |_| |
9
13
  |____/|_| |_|\___/|_| \__|_|\__, |
10
- |___/
14
+ |___/
11
15
 
12
16
 
13
17
  A Ruby wrapper for various url shortener services
@@ -123,9 +127,9 @@ Copyright (c) 2010 Bagwan Pankaj: http://bagwanpankaj.com, released under the MI
123
127
  * Example series
124
128
 
125
129
  ## Contributing to shortly
126
-
130
+
127
131
  * Fork, code, and then send me a pull request.
128
132
 
129
133
  ## Copyright
130
134
 
131
- Copyright (c) 2010-2014 [Bagwan Pankaj]. See LICENSE.txt for further details.
135
+ Copyright (c) 2010-2014 [Bagwan Pankaj]. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.3.6
@@ -18,17 +18,17 @@ require 'shortly/clients/snim'
18
18
  require 'shortly/clients/bitdo'
19
19
 
20
20
  module Shortly
21
-
21
+
22
22
  #gem version
23
23
  def self.version #:nodoc
24
24
  File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
25
25
  end
26
-
26
+
27
27
  #returns active services
28
28
  def self.active_services
29
29
  Client.registered
30
30
  end
31
-
31
+
32
32
  Helper::MonkeyPatches.activate!
33
-
34
- end
33
+
34
+ end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2011 Bagwan Pankaj
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -20,48 +20,48 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Shortly
23
-
23
+
24
24
  class Client
25
-
25
+
26
26
  include HTTParty
27
27
  include Shortly::Errors
28
28
  include Shortly::Helper
29
-
29
+
30
30
  base_uri ''
31
-
31
+
32
32
  @@registered = []
33
-
33
+
34
34
  def self.method_missing(method_sym, *params) #:nodoc
35
35
  raise MethodNotAvailableError.new("Sorry, #{method_sym} method is not implemented/available for this service.")
36
36
  end
37
-
37
+
38
38
  protected
39
-
39
+
40
40
  def self.register! #:nodoc
41
41
  @@registered = [] unless @@registered
42
42
  @@registered << self.name.to_sym
43
43
  end
44
-
44
+
45
45
  def self.registered #:nodoc
46
46
  @@registered
47
47
  end
48
-
48
+
49
49
  def self.validate_uri!(url)
50
50
  raise InvalidURIError.new("provided URI is invalid.") unless valid_uri?(url)
51
51
  end
52
-
52
+
53
53
  #returns a uri is valid or not
54
54
  def self.valid_uri?(url)
55
55
  !!(url =~ URI::regexp)
56
56
  end
57
-
57
+
58
58
  def self.post_params(options = {})
59
59
  {:body => options}
60
60
  end
61
-
61
+
62
62
  def self.get_params(options = {})
63
63
  {:query => options}
64
64
  end
65
-
65
+
66
66
  end
67
- end
67
+ end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2011 Bagwan Pankaj
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -20,21 +20,21 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Shortly
23
-
23
+
24
24
  module Errors
25
-
25
+
26
26
  class ShortlyError < StandardError
27
-
27
+
28
28
  def initialize(msg)
29
29
  super("ShortlyError - #{msg}")
30
30
  end
31
-
31
+
32
32
  end
33
-
33
+
34
34
  class ShortlyArgumentError < ArgumentError; end
35
35
  class InvalidURIError < ShortlyError; end
36
36
  class NotAuthorizedError < ShortlyArgumentError; end
37
37
  class MethodNotAvailableError < ShortlyError; end
38
38
  end
39
-
40
- end
39
+
40
+ end
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2011 Bagwan Pankaj
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -20,44 +20,44 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Shortly
23
-
23
+
24
24
  module Helper
25
-
25
+
26
26
  module MonkeyPatches
27
-
27
+
28
28
  def self.activate!
29
29
  Hash.send(:include, MonkeyHash)
30
30
  Object.send(:include, MonkeyObject)
31
31
  end
32
-
32
+
33
33
  module MonkeyHash
34
-
34
+
35
35
  def authenticable?(*args)
36
36
  args.all?{|k| self.key?(k)} && !self.values.any?(&:blank?)
37
37
  end
38
-
38
+
39
39
  def to_params
40
40
  collect do |key, value|
41
41
  "#{key}=#{value}"
42
42
  end.sort * '&'
43
43
  end
44
-
44
+
45
45
  end
46
-
46
+
47
47
  module MonkeyObject
48
-
48
+
49
49
  def blank?
50
50
  instance_of?(Array) ? empty? : nil?
51
51
  end
52
-
52
+
53
53
  def present?
54
54
  !blank?
55
55
  end
56
-
56
+
57
57
  end
58
-
58
+
59
59
  end
60
-
60
+
61
61
  end
62
-
63
- end
62
+
63
+ end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Shortly" do
4
-
4
+
5
5
  #tests for client googl
6
6
  describe "Googl" do
7
7
  before(:all) do
@@ -11,50 +11,50 @@ describe "Shortly" do
11
11
  @googl = Shortly::Clients::Googl
12
12
  @uri = @googl.base_uri + @googl.send(:relative_path)
13
13
  end
14
-
15
- it "should get a short url from googl(provided valid url)" do
14
+
15
+ it ".shorten" do
16
16
  mock_request_for(@uri, :method => :post, :fixture => "googl_shorten")
17
17
  res = @googl.shorten(@long_url)
18
- res.shortUrl.should_not be_empty
19
- res.shortUrl.should == @short_url
18
+ expect(res.shortUrl).not_to be_empty
19
+ expect(res.shortUrl).to eq @short_url
20
20
  end
21
-
22
- it "result of shorten should be an instance of OpenStruct" do
21
+
22
+ it ".shorten should respond_with OpenStruct" do
23
23
  res = @googl.shorten(@long_url)
24
- res.should be_an_instance_of(OpenStruct)
24
+ expect(res).to be_an_instance_of(OpenStruct)
25
25
  end
26
-
27
- it "should get a long url back for given valid short url" do
26
+
27
+ it ".expand" do
28
28
  mock_request_for(@uri + "?shortUrl=#{CGI.escape(@short_url)}", :method => :get, :fixture => "googl_expand")
29
29
  res = @googl.expand(@short_url)
30
- res.longUrl.should_not be_empty
31
- res.longUrl.should == @long_url
30
+ expect(res.longUrl).not_to be_empty
31
+ expect(res.longUrl).to eq @long_url
32
32
  end
33
-
34
- it "result of expand should be an instance of OpenStruct" do
33
+
34
+ it ".expand should respond_with OpenStruct" do
35
35
  res = @googl.expand(@short_url)
36
- res.should be_an_instance_of(OpenStruct)
36
+ expect(res).to be_an_instance_of(OpenStruct)
37
37
  end
38
-
39
- it "should give analytics for given short url" do
38
+
39
+ it ".analytics" do
40
40
  mock_request_for(@uri + "?shortUrl=#{CGI.escape(@short_url)}&projection=FULL",
41
41
  :fixture => "googl_analytics")
42
-
42
+
43
43
  res = @googl.analytics(@short_url)
44
- res.analytics.should_not be_empty
45
- res.analytics.should be_an_instance_of(Hash)
46
- res.analytics["week"].should be_an_instance_of(Hash)
47
- res.analytics["day"].should be_an_instance_of(Hash)
48
- end
49
-
50
- it "should throw an error on wrong uri format" do
51
- lambda do
44
+ expect(res.analytics).not_to be_empty
45
+ expect(res.analytics).to be_an_instance_of(Hash)
46
+ expect(res.analytics["week"]).to be_an_instance_of(Hash)
47
+ expect(res.analytics["day"]).to be_an_instance_of(Hash)
48
+ end
49
+
50
+ it "InvalidURIError" do
51
+ expect(lambda do
52
52
  @googl.shorten(@invalid_url)
53
- end.should raise_error(Shortly::Errors::InvalidURIError)
53
+ end).to raise_error(Shortly::Errors::InvalidURIError)
54
54
  end
55
-
55
+
56
56
  end
57
-
57
+
58
58
  #tests for client isgd
59
59
  describe "Isgd" do
60
60
  before(:all) do
@@ -64,73 +64,73 @@ describe "Shortly" do
64
64
  @invalid_url = "bagwanpankaj.com"
65
65
  @uri = @isgd.base_uri
66
66
  end
67
-
68
- it "should get a short url from Is.gd(provided valid url)" do
67
+
68
+ it ".shorten" do
69
69
  mock_request_for(@uri + "/create.php?url=#{CGI.escape(@long_url)}&format=json",
70
70
  :fixture => "isgd_shorten")
71
-
71
+
72
72
  res = @isgd.shorten(@long_url)
73
- res.shorturl.should_not be_empty
74
- res.shorturl.should == @shorturl
73
+ expect(res.shorturl).not_to be_empty
74
+ expect(res.shorturl).to eq @shorturl
75
75
  end
76
-
77
- it "result should be an instance of OpenStruct" do
76
+
77
+ it ".shorten should respond_with OpenStruct" do
78
78
  res = @isgd.shorten(@long_url)
79
- res.should be_an_instance_of(OpenStruct)
79
+ expect(res).to be_an_instance_of(OpenStruct)
80
80
  end
81
-
82
- it "should throw an error on wrong uri format" do
83
- lambda do
81
+
82
+ it "InvalidURIError" do
83
+ expect(lambda do
84
84
  @isgd.shorten(@invalid_url)
85
- end.should raise_error(Shortly::Errors::InvalidURIError)
85
+ end).to raise_error(Shortly::Errors::InvalidURIError)
86
86
  end
87
-
88
- it "should raise MethodNotAvailableError if method is not implemented for" do
89
- lambda do
87
+
88
+ it "MethodNotAvailableError" do
89
+ expect(lambda do
90
90
  @isgd.expand(@long_url)
91
- end.should raise_error(Shortly::Errors::MethodNotAvailableError)
91
+ end).to raise_error(Shortly::Errors::MethodNotAvailableError)
92
92
  end
93
93
  end
94
-
94
+
95
95
  #tests for client vgd
96
- describe "Vgd" do
97
- before(:all) do
98
- @vgd = Shortly::Clients::Vgd
99
- @long_url = "http://bagwanpankaj.com"
100
- @invalid_url = "bagwanpankaj.com"
101
- @uri = @vgd.base_uri
102
- end
103
-
104
- it "should get a short url from v.gd(provided valid url)" do
105
- mock_request_for(@uri + "/create.php?url=#{CGI.escape(@long_url)}&format=json",
106
- :fixture => "vgd_shorten")
107
-
108
- res = @vgd.shorten(@long_url)
109
- res.shorturl.should_not be_empty
110
- res.shorturl.should == @vgd.shorten(@long_url).shorturl
111
- end
112
-
113
- it "result should be an instance of OpenStruct" do
114
- res = @vgd.shorten(@long_url)
115
- res.should be_an_instance_of(OpenStruct)
116
- end
117
-
118
- it "should throw an error on wrong uri format" do
119
- lambda do
120
- @vgd.shorten(@invalid_url)
121
- end.should raise_error(Shortly::Errors::InvalidURIError)
122
- end
123
-
124
- it "should raise MethodNotAvailableError if method is not implemented for" do
125
- lambda do
126
- @vgd.expand(@long_url)
127
- end.should raise_error(Shortly::Errors::MethodNotAvailableError)
128
- end
129
- end
130
-
96
+ describe "Vgd" do
97
+ before(:all) do
98
+ @vgd = Shortly::Clients::Vgd
99
+ @long_url = "http://bagwanpankaj.com"
100
+ @invalid_url = "bagwanpankaj.com"
101
+ @uri = @vgd.base_uri
102
+ end
103
+
104
+ it ".shorten" do
105
+ mock_request_for(@uri + "/create.php?url=#{CGI.escape(@long_url)}&format=json",
106
+ :fixture => "vgd_shorten")
107
+
108
+ res = @vgd.shorten(@long_url)
109
+ expect(res.shorturl).not_to be_empty
110
+ expect(res.shorturl).to eq @vgd.shorten(@long_url).shorturl
111
+ end
112
+
113
+ it ".shorten should respond_with OpenStruct" do
114
+ res = @vgd.shorten(@long_url)
115
+ expect(res).to be_an_instance_of(OpenStruct)
116
+ end
117
+
118
+ it "InvalidURIError" do
119
+ expect(lambda do
120
+ @vgd.shorten(@invalid_url)
121
+ end).to raise_error(Shortly::Errors::InvalidURIError)
122
+ end
123
+
124
+ it "MethodNotAvailableError" do
125
+ expect(lambda do
126
+ @vgd.expand(@long_url)
127
+ end).to raise_error(Shortly::Errors::MethodNotAvailableError)
128
+ end
129
+ end
130
+
131
131
  #tests for client bitly
132
132
  describe "Bitly" do
133
-
133
+
134
134
  before(:all) do
135
135
  @bitly = Shortly::Clients::Bitly
136
136
  @bitly.login = "TEST_LOGIN"
@@ -140,40 +140,40 @@ describe "Shortly" do
140
140
  @short_url = "http://bit.ly/dUdiIJ"
141
141
  @uri = @bitly.base_uri + "/v3"
142
142
  end
143
-
144
- it "should get a short url from bitly(provided valid url)" do
145
- mock_request_for(@uri + "/shorten?longUrl=#{CGI.escape(@long_url)}&format=json&login=#{@bitly.login}&apiKey=#{@bitly.apiKey}",
143
+
144
+ it ".shorten" do
145
+ mock_request_for(@uri + "/shorten?longUrl=#{CGI.escape(@long_url)}&format=json&login=#{@bitly.login}&apiKey=#{@bitly.apiKey}",
146
146
  :fixture => "bitly_shorten")
147
-
147
+
148
148
  res = @bitly.shorten(@long_url)
149
- res.url.should_not be_empty
150
- res.url.should == @short_url
149
+ expect(res.url).not_to be_empty
150
+ expect(res.url).to eq @short_url
151
151
  end
152
-
153
- it "result should be an instance of OpenStruct" do
152
+
153
+ it ".shorten should respond_with OpenStruct" do
154
154
  res = @bitly.shorten(@long_url)
155
- res.should be_an_instance_of(OpenStruct)
155
+ expect(res).to be_an_instance_of(OpenStruct)
156
156
  end
157
-
158
- it "should throw an error on wrong uri format" do
159
- lambda do
160
- @bitly.shorten(@invalid_url)
161
- end.should raise_error(Shortly::Errors::InvalidURIError)
157
+
158
+ it "InvalidURIError" do
159
+ expect(lambda do
160
+ @bitly.shorten(@invalid_url)
161
+ end).to raise_error(Shortly::Errors::InvalidURIError)
162
162
  end
163
-
164
- it "should expand a given short url" do
165
- mock_request_for(@uri + "/expand?shortUrl=#{CGI.escape(@short_url)}&format=json&login=#{@bitly.login}&apiKey=#{@bitly.apiKey}",
163
+
164
+ it ".expand" do
165
+ mock_request_for(@uri + "/expand?shortUrl=#{CGI.escape(@short_url)}&format=json&login=#{@bitly.login}&apiKey=#{@bitly.apiKey}",
166
166
  :fixture => "bitly_expand")
167
-
167
+
168
168
  res = @bitly.expand("http://bit.ly/dUdiIJ")
169
- res.long_url.should == @long_url
169
+ expect(res.long_url).to eq @long_url
170
170
  end
171
-
171
+
172
172
  end
173
-
173
+
174
174
  #tests for client jmp
175
175
  describe "Jmp" do
176
-
176
+
177
177
  before(:all) do
178
178
  @jmp = Shortly::Clients::Jmp
179
179
  @jmp.login = "TEST_LOGIN"
@@ -183,37 +183,37 @@ describe "Shortly" do
183
183
  @short_url = "http://j.mp/dUdiIJ"
184
184
  @uri = @jmp.base_uri + '/v3'
185
185
  end
186
-
187
- it "should get a short url from jmp(provided valid url)" do
188
- mock_request_for(@uri + "/shorten?longUrl=#{CGI.escape(@long_url)}&format=json&login=#{@jmp.login}&apiKey=#{@jmp.apiKey}",
186
+
187
+ it ".shorten" do
188
+ mock_request_for(@uri + "/shorten?longUrl=#{CGI.escape(@long_url)}&format=json&login=#{@jmp.login}&apiKey=#{@jmp.apiKey}",
189
189
  :fixture => "jmp_shorten")
190
-
190
+
191
191
  res = @jmp.shorten(@long_url)
192
- res.url.should_not be_empty
193
- res.url.should == @short_url
192
+ expect(res.url).not_to be_empty
193
+ expect(res.url).to eq @short_url
194
194
  end
195
-
196
- it "result should be an instance of OpenStruct" do
195
+
196
+ it ".shorten should respond_with OpenStruct" do
197
197
  res = @jmp.shorten(@long_url)
198
- res.should be_an_instance_of(OpenStruct)
198
+ expect(res).to be_an_instance_of(OpenStruct)
199
199
  end
200
-
201
- it "should throw an error on wrong uri format" do
202
- lambda do
203
- @jmp.shorten(@invalid_url)
204
- end.should raise_error(Shortly::Errors::InvalidURIError)
200
+
201
+ it "InvalidURIError" do
202
+ expect(lambda do
203
+ @jmp.shorten(@invalid_url)
204
+ end).to raise_error(Shortly::Errors::InvalidURIError)
205
205
  end
206
-
207
- it "should expand a given short url" do
208
- mock_request_for(@uri + "/expand?shortUrl=#{CGI.escape(@short_url)}&format=json&login=#{@jmp.login}&apiKey=#{@jmp.apiKey}",
206
+
207
+ it ".expand" do
208
+ mock_request_for(@uri + "/expand?shortUrl=#{CGI.escape(@short_url)}&format=json&login=#{@jmp.login}&apiKey=#{@jmp.apiKey}",
209
209
  :fixture => "jmp_expand")
210
-
210
+
211
211
  res = @jmp.expand(@short_url)
212
- res.long_url.should == @long_url
212
+ expect(res.long_url).to eq @long_url
213
213
  end
214
-
214
+
215
215
  end
216
-
216
+
217
217
  #tests for client tinyurl
218
218
  describe "TinyUrl" do
219
219
  before(:all) do
@@ -221,37 +221,37 @@ describe "Shortly" do
221
221
  @invalid_url = "bagwanpankaj.com"
222
222
  @uri = Shortly::Clients::Tinyurl.base_uri
223
223
  end
224
-
225
- it "should get a short url from TinyUrl(provided valid url)" do
224
+
225
+ it ".shorten" do
226
226
  mock_request_for(@uri + "/api-create.php", :method => :post,
227
227
  :fixture => "tinyurl_shorten", :content_type => "text/plain")
228
-
228
+
229
229
  res = Shortly::Clients::Tinyurl.shorten(@long_url)
230
- res.shorturl.should_not be_empty
231
- res.shorturl.should == "http://tinyurl.com/6jt3pjr"
230
+ expect(res.shorturl).not_to be_empty
231
+ expect(res.shorturl).to eq "http://tinyurl.com/6jt3pjr"
232
232
  end
233
-
234
- it "result should be an instance of OpenStruct" do
233
+
234
+ it ".shorten should respond_with OpenStruct" do
235
235
  res = Shortly::Clients::Tinyurl.shorten(@long_url)
236
- res.should be_an_instance_of(OpenStruct)
236
+ expect(res).to be_an_instance_of(OpenStruct)
237
237
  end
238
-
239
- it "should throw an error on wrong uri format" do
240
- lambda do
241
- Shortly::Clients::Tinyurl.shorten(@invalid_url)
242
- end.should raise_error(Shortly::Errors::InvalidURIError)
238
+
239
+ it "InvalidURIError" do
240
+ expect(lambda do
241
+ Shortly::Clients::Tinyurl.shorten(@invalid_url)
242
+ end).to raise_error(Shortly::Errors::InvalidURIError)
243
243
  end
244
-
245
- it "should raise MethodNotAvailableError if method is not implemented for" do
246
- lambda do
247
- Shortly::Clients::Tinyurl.expand(@long_url)
248
- end.should raise_error(Shortly::Errors::MethodNotAvailableError)
244
+
245
+ it "should raise MethodNotAvailableError" do
246
+ expect(lambda do
247
+ Shortly::Clients::Tinyurl.expand(@long_url)
248
+ end).to raise_error(Shortly::Errors::MethodNotAvailableError)
249
249
  end
250
250
  end
251
-
251
+
252
252
  #tests for client ShortSwitch
253
253
  describe "ShortSwitch" do
254
-
254
+
255
255
  before(:all) do
256
256
  @ss = Shortly::Clients::ShortSwitch
257
257
  Shortly::Clients::ShortSwitch.apiKey = "TESTKEY"
@@ -261,28 +261,28 @@ describe "Shortly" do
261
261
  @uri = @ss.base_uri
262
262
  end
263
263
 
264
- it "should get a short url from ShortSwitch(provided valid url)" do
264
+ it ".shorten" do
265
265
  mock_request_for(@uri + "/shorten?longUrl=#{CGI.escape(@long_url)}&format=json&apiKey=TESTKEY",
266
266
  :fixture => "shortswitch_shorten")
267
-
267
+
268
268
  res = Shortly::Clients::ShortSwitch.shorten(@long_url)
269
- res.shortUrl.should_not be_empty
270
- res.shortUrl.should == @short_url
269
+ expect(res.shortUrl).not_to be_empty
270
+ expect(res.shortUrl).to eq @short_url
271
271
  end
272
-
273
- it "result should be an instance of OpenStruct" do
272
+
273
+ it ".shorten should respond_with OpenStruct" do
274
274
  res = Shortly::Clients::ShortSwitch.shorten(@long_url)
275
- res.should be_an_instance_of(OpenStruct)
275
+ expect(res).to be_an_instance_of(OpenStruct)
276
276
  end
277
-
278
- it "should throw an error on wrong uri format" do
279
- lambda do
280
- Shortly::Clients::ShortSwitch.shorten(@invalid_url)
281
- end.should raise_error(Shortly::Errors::InvalidURIError)
277
+
278
+ it "InvalidURIError" do
279
+ expect(lambda do
280
+ Shortly::Clients::ShortSwitch.shorten(@invalid_url)
281
+ end).to raise_error(Shortly::Errors::InvalidURIError)
282
282
  end
283
-
283
+
284
284
  end
285
-
285
+
286
286
  #tests for client sn.im
287
287
  describe "Snim" do
288
288
  before(:all) do
@@ -294,96 +294,96 @@ describe "Shortly" do
294
294
  @short_url = "http://sn.im/1wvkof"
295
295
  @uri = @snim.base_uri
296
296
  end
297
-
298
- it "should get a short url from Snim(provided valid url)" do
297
+
298
+ it ".shorten" do
299
299
  mock_request_for(@uri + "/getsnip", :method => :post,
300
300
  :fixture => "snim_shorten")
301
-
301
+
302
302
  res = @snim.shorten(@long_url)
303
- res.shortUrl.should_not be_empty
304
- res.shortUrl.should == @short_url
303
+ expect(res.shortUrl).not_to be_empty
304
+ expect(res.shortUrl).to eq @short_url
305
305
  end
306
-
307
- it "should get analytics from Snim(provided valid id)" do
306
+
307
+ it ".analytics" do
308
308
  mock_request_for(@uri + "/getsnipdetails", :method => :post,
309
309
  :fixture => "snim_analytics")
310
-
310
+
311
311
  res = @snim.analytics("1wvkof")
312
- res.url.should_not be_empty
313
- res.clicks.should_not be_nil
314
- res.clicks.should == 10000
312
+ expect(res.url).not_to be_empty
313
+ expect(res.clicks).not_to be_nil
314
+ expect(res.clicks).to eq 10000
315
315
  end
316
-
317
- it "should get long url from Snim(provided valid shorturl)" do
316
+
317
+ it ".expand" do
318
318
  mock_request_for(@uri + "/getsnipdetails", :method => :post,
319
319
  :fixture => "snim_analytics")
320
-
320
+
321
321
  res = @snim.expand(@short_url)
322
- res.url.should_not be_empty
323
- res.url.should == @long_url
322
+ expect(res.url).not_to be_empty
323
+ expect(res.url).to eq @long_url
324
324
  end
325
325
  end
326
-
326
+
327
327
  describe "Client" do
328
-
328
+
329
329
  before(:all) do
330
330
  @valid_uri = "http://bagwanpankaj.com"
331
- @invalid_uri = "someinveliduri"
331
+ @invalid_uri = "someinveliduri"
332
332
  end
333
-
334
- it "should include HTTParty" do
335
- Shortly::Client.included_modules.should include HTTParty
333
+
334
+ it "includes HTTParty" do
335
+ expect(Shortly::Client.included_modules).to include HTTParty
336
336
  end
337
-
338
- it "should include Shortly::Errors" do
339
- Shortly::Client.included_modules.should include Shortly::Errors
337
+
338
+ it "includes Shortly::Errors" do
339
+ expect(Shortly::Client.included_modules).to include Shortly::Errors
340
340
  end
341
-
342
- it "should include Shortly::Helper" do
343
- Shortly::Client.included_modules.should include Shortly::Helper
341
+
342
+ it "includes Shortly::Helper" do
343
+ expect(Shortly::Client.included_modules).to include Shortly::Helper
344
344
  end
345
-
346
- it "should respond to resitered class variable" do
347
- Shortly::Client.class_variables.should include :"@@registered"
345
+
346
+ it ":@@registered" do
347
+ expect(Shortly::Client.class_variables).to include :"@@registered"
348
348
  end
349
-
350
- it "should respond to register/valid_uri? and registered methods" do
351
- Shortly::Client.should respond_to :register!
352
- Shortly::Client.should respond_to :registered
353
- Shortly::Client.should respond_to :valid_uri?
349
+
350
+ it ".register/.valid_uri?/.registered" do
351
+ expect(Shortly::Client).to respond_to :register!
352
+ expect(Shortly::Client).to respond_to :registered
353
+ expect(Shortly::Client).to respond_to :valid_uri?
354
354
  end
355
-
356
- it "should test a uri is valid or not" do
357
- Shortly::Client.valid_uri?(@valid_uri).should be true
358
- Shortly::Client.valid_uri?(@invalid_uri).should_not be true
355
+
356
+ it ".valid_uri" do
357
+ expect(Shortly::Client.valid_uri?(@valid_uri)).to be true
358
+ expect(Shortly::Client.valid_uri?(@invalid_uri)).to be false
359
359
  end
360
-
360
+
361
361
  end
362
-
362
+
363
363
  describe "Misc" do
364
-
364
+
365
365
  describe "Errors" do
366
-
367
- it "should have various error classes implemented" do
368
- Shortly::Errors::ShortlyError.superclass.name.should == "StandardError"
369
- Shortly::Errors::ShortlyArgumentError.superclass.name.should == "ArgumentError"
370
- Shortly::Errors::InvalidURIError.superclass.name.should == "Shortly::Errors::ShortlyError"
371
- Shortly::Errors::NotAuthorizedError.superclass.name.should == "Shortly::Errors::ShortlyArgumentError"
372
- Shortly::Errors::MethodNotAvailableError.superclass.name.should == "Shortly::Errors::ShortlyError"
366
+
367
+ it "CustomErrors" do
368
+ expect(Shortly::Errors::ShortlyError.superclass.name).to eq "StandardError"
369
+ expect(Shortly::Errors::ShortlyArgumentError.superclass.name).to eq "ArgumentError"
370
+ expect(Shortly::Errors::InvalidURIError.superclass.name).to eq "Shortly::Errors::ShortlyError"
371
+ expect(Shortly::Errors::NotAuthorizedError.superclass.name).to eq "Shortly::Errors::ShortlyArgumentError"
372
+ expect(Shortly::Errors::MethodNotAvailableError.superclass.name).to eq "Shortly::Errors::ShortlyError"
373
373
  end
374
-
374
+
375
375
  end
376
-
376
+
377
377
  describe "Shortly" do
378
- it "should return current version of gem" do
379
- Shortly.version.should == File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
378
+ it ".version" do
379
+ expect(Shortly.version).to eq File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
380
380
  end
381
-
382
- it "should return all registered services" do
383
- Shortly.active_services.should == Shortly::Client.registered
381
+
382
+ it ".active_services" do
383
+ expect(Shortly.active_services).to eq Shortly::Client.registered
384
384
  end
385
-
385
+
386
386
  end
387
387
  end
388
-
388
+
389
389
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shortly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bagwan Pankaj
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.2.1
90
+ rubygems_version: 2.4.5
91
91
  signing_key:
92
92
  specification_version: 3
93
93
  summary: Url Shortner Services Ruby Wrapper
@@ -95,3 +95,4 @@ test_files:
95
95
  - spec/shortly_spec.rb
96
96
  - spec/spec_helper.rb
97
97
  - spec/support/fakeweb_stub.rb
98
+ has_rdoc: