can-has-lolcat 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/can-has-lolcat.gemspec +50 -0
- data/lib/can-has-lolcat.rb +48 -13
- data/test/fixtures/loldog.html +1067 -0
- data/test/fixtures/lolvideo.html +809 -0
- data/test/test_can-has-lolcat.rb +39 -6
- metadata +39 -60
- data/.gitignore +0 -21
data/test/test_can-has-lolcat.rb
CHANGED
@@ -6,20 +6,35 @@ class TestCanHasLolcat < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
context "Lolcat" do
|
8
8
|
context "#can_has" do
|
9
|
-
|
9
|
+
LOLCAT_URL = "http://icanhascheezburger.com/?random"
|
10
|
+
LOLDOG_URL = "http://dogs.icanhascheezburger.com/?random"
|
11
|
+
|
12
|
+
LOLCAT_REGEX = /http:\/\/icanhascheezburger\.files\.wordpress\.com\/.+/
|
13
|
+
LOLDOG_REGEX = /http:\/\/ihasahotdog\.files\.wordpress\.com\/.+/
|
14
|
+
MAX_STRING_LENGTH = 200
|
10
15
|
|
11
16
|
setup do
|
12
|
-
stub(Lolcat).
|
13
|
-
|
17
|
+
stub(Lolcat).get_html(LOLCAT_URL) do
|
18
|
+
File.read(File.dirname(__FILE__) + "/fixtures/lolcat.html")
|
19
|
+
end
|
20
|
+
|
21
|
+
stub(Lolcat).get_html(LOLDOG_URL) do
|
22
|
+
File.read(File.dirname(__FILE__) + "/fixtures/loldog.html")
|
14
23
|
end
|
15
24
|
end
|
16
25
|
|
17
26
|
should "without any arguments give clean `lolcat` url" do
|
18
|
-
|
27
|
+
cat = Lolcat.can_has
|
28
|
+
assert cat =~ LOLCAT_REGEX
|
29
|
+
assert cat.length < MAX_STRING_LENGTH
|
19
30
|
end
|
20
31
|
|
21
|
-
should "with url as
|
22
|
-
assert Lolcat.can_has(:url) =~
|
32
|
+
should "with (url, dog) as arguments give clean `loldog` url" do
|
33
|
+
assert Lolcat.can_has(:url, :dog) =~ LOLDOG_REGEX
|
34
|
+
end
|
35
|
+
|
36
|
+
should "with url as argument give clean url" do
|
37
|
+
assert Lolcat.can_has(:url) =~ LOLCAT_REGEX
|
23
38
|
end
|
24
39
|
|
25
40
|
should "with html as argument give HTML formatted `lolcat`" do
|
@@ -29,6 +44,24 @@ class TestCanHasLolcat < Test::Unit::TestCase
|
|
29
44
|
should "with bbcode as argument give bbcode formatted `lolcat`" do
|
30
45
|
assert Lolcat.can_has(:bbcode) =~ /\[img\].+\[\/img\]/
|
31
46
|
end
|
47
|
+
|
48
|
+
should "retry when video returned" do
|
49
|
+
attempts = 0
|
50
|
+
|
51
|
+
# This stub returns the video fixture the first time it's called
|
52
|
+
# and the correct image file the second time.
|
53
|
+
stub(Lolcat).get_html(LOLDOG_URL) do
|
54
|
+
if 0 == attempts
|
55
|
+
attempts += 1
|
56
|
+
File.read(File.dirname(__FILE__) + "/fixtures/lolvideo.html")
|
57
|
+
else
|
58
|
+
File.read(File.dirname(__FILE__) + "/fixtures/loldog.html")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
assert Lolcat.can_has(:url, :dog) =~ LOLDOG_REGEX
|
63
|
+
end
|
64
|
+
|
32
65
|
end
|
33
66
|
end
|
34
67
|
end
|
metadata
CHANGED
@@ -1,91 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: can-has-lolcat
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 1.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Sirupsen
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: shoulda
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
33
20
|
type: :development
|
34
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
35
27
|
description: Fetches a random lolcat, and returns the appropriate output format.
|
36
28
|
email: sirup@sirupsen.com
|
37
29
|
executables: []
|
38
|
-
|
39
30
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
31
|
+
extra_rdoc_files:
|
42
32
|
- LICENSE
|
43
33
|
- README.md
|
44
|
-
files:
|
34
|
+
files:
|
45
35
|
- .document
|
46
|
-
- .gitignore
|
47
36
|
- LICENSE
|
48
37
|
- README.md
|
49
38
|
- Rakefile
|
50
39
|
- VERSION
|
40
|
+
- can-has-lolcat.gemspec
|
51
41
|
- lib/can-has-lolcat.rb
|
52
42
|
- test/fixtures/lolcat.html
|
43
|
+
- test/fixtures/loldog.html
|
44
|
+
- test/fixtures/lolvideo.html
|
53
45
|
- test/helper.rb
|
54
46
|
- test/test_can-has-lolcat.rb
|
55
|
-
has_rdoc: true
|
56
47
|
homepage: http://github.com/Sirupsen/can-has-lolcat
|
57
48
|
licenses: []
|
58
|
-
|
49
|
+
metadata: {}
|
59
50
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
62
|
-
require_paths:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
63
53
|
- lib
|
64
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
hash: 3
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
version: "0"
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
82
64
|
requirements: []
|
83
|
-
|
84
65
|
rubyforge_project:
|
85
|
-
rubygems_version:
|
66
|
+
rubygems_version: 2.0.3
|
86
67
|
signing_key:
|
87
|
-
specification_version:
|
68
|
+
specification_version: 4
|
88
69
|
summary: can haz random lolcat?
|
89
|
-
test_files:
|
90
|
-
- test/test_can-has-lolcat.rb
|
91
|
-
- test/helper.rb
|
70
|
+
test_files: []
|