shortly 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/spec/shortly_spec.rb +95 -2
  2. metadata +4 -4
data/spec/shortly_spec.rb CHANGED
@@ -1,7 +1,100 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Shortly" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
4
+
5
+ #tests for client googl
6
+ describe "Googl" do
7
+ before(:all) do
8
+ @long_url = "http://bagwanpankaj.com"
9
+ @invalid_url = "bagwanpankaj.com"
10
+ end
11
+
12
+ it "should get a short url from googl(provided valid url)" do
13
+ res = Shortly::Clients::Googl.shorten(@long_url)
14
+ res.short_url.should_not be_empty
15
+ res.short_url.should == "http://goo.gl/17pbM"
16
+ end
17
+
18
+ it "result should be an instance of OpenStruct" do
19
+ res = Shortly::Clients::Googl.shorten(@long_url)
20
+ res.should be_an_instance_of(OpenStruct)
21
+ end
22
+
23
+ it "should not be added to history(by default)" do
24
+ res = Shortly::Clients::Googl.shorten(@long_url)
25
+ res.added_to_history.should be_an_instance_of(FalseClass)
26
+ end
27
+
28
+ it "should throw an error on wrong uri format" do
29
+ lambda do
30
+ Shortly::Clients::Googl.shorten(@invalid_url)
31
+ end.should raise_error(Shortly::Errors::InvalidURIError)
32
+ end
33
+
34
+ it "should raise MethodNotAvailableError if method is not implemented for" do
35
+ lambda do
36
+ Shortly::Clients::Googl.expand(@long_url)
37
+ end.should raise_error(Shortly::Errors::MethodNotAvailableError)
38
+ end
6
39
  end
40
+
41
+ #tests for client isgd
42
+ describe "Isgd" do
43
+ before(:all) do
44
+ @long_url = "http://bagwanpankaj.com"
45
+ @invalid_url = "bagwanpankaj.com"
46
+ end
47
+
48
+ it "should get a short url from googl(provided valid url)" do
49
+ res = Shortly::Clients::Isgd.shorten(@long_url)
50
+ res.shorturl.should_not be_empty
51
+ res.shorturl.should == "http://is.gd/5V9Unz"
52
+ end
53
+
54
+ it "result should be an instance of OpenStruct" do
55
+ res = Shortly::Clients::Isgd.shorten(@long_url)
56
+ res.should be_an_instance_of(OpenStruct)
57
+ end
58
+
59
+ it "should throw an error on wrong uri format" do
60
+ lambda do
61
+ Shortly::Clients::Isgd.shorten(@invalid_url)
62
+ end.should raise_error(Shortly::Errors::InvalidURIError)
63
+ end
64
+
65
+ it "should raise MethodNotAvailableError if method is not implemented for" do
66
+ lambda do
67
+ Shortly::Clients::Isgd.expand(@long_url)
68
+ end.should raise_error(Shortly::Errors::MethodNotAvailableError)
69
+ end
70
+ end
71
+
72
+ #tests for client bitly
73
+ describe "Bitly" do
74
+ before(:all) do
75
+ Shortly::Clients::Bitly.login = "modulo9"
76
+ Shortly::Clients::Bitly.apiKey = "R_0f17f32f11de7e3e953de49c6f255104"
77
+ @long_url = "http://bagwanpankaj.com"
78
+ @invalid_url = "bagwanpankaj.com"
79
+ end
80
+
81
+ it "should get a short url from googl(provided valid url)" do
82
+ res = Shortly::Clients::Bitly.shorten(@long_url)
83
+ res.url.should_not be_empty
84
+ res.url.should == "http://bit.ly/dUdiIJ"
85
+ end
86
+
87
+ it "result should be an instance of OpenStruct" do
88
+ res = Shortly::Clients::Bitly.shorten(@long_url)
89
+ res.should be_an_instance_of(OpenStruct)
90
+ end
91
+
92
+ it "should throw an error on wrong uri format" do
93
+ lambda do
94
+ Shortly::Clients::Bitly.shorten(@invalid_url)
95
+ end.should raise_error(Shortly::Errors::InvalidURIError)
96
+ end
97
+
98
+ end
99
+
7
100
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shortly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bagwan Pankaj
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-14 00:00:00 +05:30
18
+ date: 2011-01-15 00:00:00 +05:30
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency