virility 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/virility.rb +29 -29
- data/lib/virility/exceptions.rb +1 -1
- data/lib/virility/excitation.rb +102 -102
- data/lib/virility/strategies/delicious.rb +8 -8
- data/lib/virility/strategies/facebook.rb +19 -16
- data/lib/virility/strategies/pinterest.rb +13 -13
- data/lib/virility/strategies/plus_one.rb +17 -17
- data/lib/virility/strategies/stumble_upon.rb +16 -16
- data/lib/virility/strategies/twitter.rb +11 -11
- data/lib/virility/strategy.rb +83 -83
- data/lib/virility/supporter.rb +53 -53
- data/lib/virility/version.rb +1 -1
- data/spec/excitation_spec.rb +111 -111
- data/spec/spec_helper.rb +11 -11
- data/spec/strategies/delicious_spec.rb +51 -51
- data/spec/strategies/facebook_spec.rb +93 -93
- data/spec/strategies/pinterest_spec.rb +51 -51
- data/spec/strategies/plus_one_spec.rb +51 -51
- data/spec/strategies/stumble_upon_spec.rb +51 -51
- data/spec/strategies/twitter_spec.rb +51 -51
- data/spec/strategy_spec.rb +98 -98
- data/spec/virility_spec.rb +64 -64
- data/virility.gemspec +1 -1
- metadata +3 -3
data/spec/spec_helper.rb
CHANGED
@@ -18,11 +18,11 @@ end
|
|
18
18
|
#
|
19
19
|
|
20
20
|
module Virility
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
TESTING_STRATEGIES = {:facebook => Virility::Facebook, :twitter => Virility::Twitter, :delicious => Virility::Delicious, :pinterest => Virility::Pinterest, :plus_one => Virility::PlusOne, :stumble_upon => Virility::StumbleUpon}
|
22
|
+
FAKE_TESTING_STRATEGIES = [:digg, :reddit, :linked_in, :instagram, :tumblr]
|
23
|
+
|
24
|
+
FB_RESULTS = {"like_count"=>"19", "click_count"=>"0", "share_count"=>"3", "comment_count"=>"0", "commentsbox_count"=>"0", "total_count"=>"22"}
|
25
|
+
FAKE_FB_RESULTS = [:face_count, :pages, :friends]
|
26
26
|
end
|
27
27
|
|
28
28
|
|
@@ -31,11 +31,11 @@ end
|
|
31
31
|
#
|
32
32
|
|
33
33
|
share_examples_for "no context results" do
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
it "should not raise an error" do
|
35
|
+
lambda { @virility.poll }.should_not raise_error
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
it "should return 0 for count" do
|
39
|
+
@virility.count.should == 0
|
40
|
+
end
|
41
41
|
end
|
@@ -1,66 +1,66 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe "Virility::Delicious" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
before(:each) do
|
5
|
+
@url = "http://creativeallies.com"
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "poll" do
|
9
|
+
context "when there is not a valid result" do
|
10
|
+
before(:each) do
|
11
|
+
response = double("HTTParty::Response", :parsed_response => {"fake_return_value"=> "OICU812"})
|
12
|
+
Virility::Delicious.stub(:get).and_return(response)
|
13
|
+
@virility = Virility::Delicious.new(@url)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
it_should_behave_like "no context results"
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
context "when there is no result" do
|
20
|
+
before(:each) do
|
21
|
+
response = double("HTTParty::Response")
|
22
|
+
Virility::Delicious.stub(:get).and_return(response)
|
23
|
+
@virility = Virility::Delicious.new(@url)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
it_should_behave_like "no context results"
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
context "when there is a result but no specific hash value" do
|
30
|
+
before(:each) do
|
31
|
+
response = double("HTTParty::Response", :parsed_response => {})
|
32
|
+
Virility::Delicious.stub(:get).and_return(response)
|
33
|
+
@virility = Virility::Delicious.new(@url)
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
it_should_behave_like "no context results"
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
context "when there is a result but parsed_response is weird" do
|
40
|
+
before(:each) do
|
41
|
+
response = double("HTTParty::Response", :parsed_response => Object.new)
|
42
|
+
Virility::Delicious.stub(:get).and_return(response)
|
43
|
+
@virility = Virility::Delicious.new(@url)
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
it_should_behave_like "no context results"
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
context "when there is a valid result" do
|
50
|
+
before(:each) do
|
51
|
+
response = double("HTTParty::Response", :parsed_response => {"url"=>"http://creativeallies.com/", "total_posts"=>50, "top_tags"=>{"graphic"=>1, "art"=>1, "contest"=>1, "photography"=>1, "creativity"=>1, "design"=>1, "online"=>1, "music"=>1, "contests"=>1, "freelance"=>1}, "hash"=>"f9468b2d2842d4a9685af46e1b8e9349", "title"=>"Creative Allies | Create Art For Rockstars"})
|
52
|
+
Virility::Delicious.stub(:get).and_return(response)
|
53
|
+
@virility = Virility::Delicious.new(@url)
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
it "should not raise an error" do
|
57
|
+
lambda { @virility.poll }.should_not raise_error
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
it "should return 50 for the count" do
|
61
|
+
@virility.count.should == 50
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
65
|
|
66
66
|
end
|
@@ -1,98 +1,98 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe "Virility::Facebook" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
4
|
+
before(:each) do
|
5
|
+
@url = "http://creativeallies.com"
|
6
|
+
end
|
7
|
+
|
8
|
+
share_examples_for "no facebook results" do
|
9
|
+
it "should not raise an error" do
|
10
|
+
lambda { @virility.poll }.should_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
["like_count", "click_count", "share_count", "comment_count", "commentsbox_count", "total_count"].each do |attribute|
|
14
|
+
it "should return 0 for #{attribute}" do
|
15
|
+
@virility.send(attribute.to_sym).should == 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "poll" do
|
21
|
+
context "when there is not a valid result" do
|
22
|
+
before(:each) do
|
23
|
+
response = double("HTTParty::Response", :parsed_response => {"fql_query_response"=>{"list"=>"true"}})
|
24
|
+
Virility::Facebook.stub(:get).and_return(response)
|
25
|
+
@virility = Virility::Facebook.new(@url)
|
26
|
+
end
|
27
|
+
|
28
|
+
it_should_behave_like "no facebook results"
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when there is no result" do
|
32
|
+
before(:each) do
|
33
|
+
response = double("HTTParty::Response")
|
34
|
+
Virility::Facebook.stub(:get).and_return(response)
|
35
|
+
@virility = Virility::Facebook.new(@url)
|
36
|
+
end
|
37
|
+
|
38
|
+
it_should_behave_like "no facebook results"
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when there is a result but no fql_query_response" do
|
42
|
+
before(:each) do
|
43
|
+
response = double("HTTParty::Response", :parsed_response => {})
|
44
|
+
Virility::Facebook.stub(:get).and_return(response)
|
45
|
+
@virility = Virility::Facebook.new(@url)
|
46
|
+
end
|
47
|
+
|
48
|
+
it_should_behave_like "no facebook results"
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when there is a result but parsed_response is weird" do
|
52
|
+
before(:each) do
|
53
|
+
response = double("HTTParty::Response", :parsed_response => Object.new)
|
54
|
+
Virility::Facebook.stub(:get).and_return(response)
|
55
|
+
@virility = Virility::Facebook.new(@url)
|
56
|
+
end
|
57
|
+
|
58
|
+
it_should_behave_like "no facebook results"
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when there is a valid result" do
|
62
|
+
before(:each) do
|
63
|
+
response = double("HTTParty::Response", :parsed_response => {"fql_query_response"=>{"list"=>"true", "link_stat"=>{"like_count"=>"977662", "click_count"=>"265614", "share_count"=>"3020040", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}}})
|
64
|
+
Virility::Facebook.stub(:get).and_return(response)
|
65
|
+
@virility = Virility::Facebook.new(@url)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should not raise an error" do
|
69
|
+
lambda { @virility.poll }.should_not raise_error
|
70
|
+
end
|
71
|
+
|
72
|
+
{"like_count"=>"977662", "click_count"=>"265614", "share_count"=>"3020040", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}.each do |key, value|
|
73
|
+
it "should return #{value} for #{key}" do
|
74
|
+
@virility.send(key.to_sym).should == value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "when there is a valid result, but not all fields are present" do
|
80
|
+
before(:each) do
|
81
|
+
response = double("HTTParty::Response", :parsed_response => {"fql_query_response"=>{"list"=>"true", "link_stat"=>{"like_count"=>"977662", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}}})
|
82
|
+
Virility::Facebook.stub(:get).and_return(response)
|
83
|
+
@virility = Virility::Facebook.new(@url)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should not raise an error" do
|
87
|
+
lambda { @virility.poll }.should_not raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
{"like_count"=>"977662", "click_count"=>0, "share_count"=>0, "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}.each do |key, value|
|
91
|
+
it "should return #{value} for #{key}" do
|
92
|
+
@virility.send(key.to_sym).should == value
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
97
|
|
98
98
|
end
|
@@ -1,66 +1,66 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe "Virility::Pinterest" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
before(:each) do
|
5
|
+
@url = "http://creativeallies.com"
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "poll" do
|
9
|
+
context "when there is not a valid result" do
|
10
|
+
before(:each) do
|
11
|
+
response = double("HTTParty::Response", :parsed_response => {"fake_return_value"=> "OICU812"})
|
12
|
+
Virility::Pinterest.stub(:get).and_return(response)
|
13
|
+
@virility = Virility::Pinterest.new(@url)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
it_should_behave_like "no context results"
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
context "when there is no result" do
|
20
|
+
before(:each) do
|
21
|
+
response = double("HTTParty::Response")
|
22
|
+
Virility::Pinterest.stub(:get).and_return(response)
|
23
|
+
@virility = Virility::Pinterest.new(@url)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
it_should_behave_like "no context results"
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
context "when there is a result but no specific hash value" do
|
30
|
+
before(:each) do
|
31
|
+
response = double("HTTParty::Response", :parsed_response => {})
|
32
|
+
Virility::Pinterest.stub(:get).and_return(response)
|
33
|
+
@virility = Virility::Pinterest.new(@url)
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
it_should_behave_like "no context results"
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
context "when there is a result but parsed_response is weird" do
|
40
|
+
before(:each) do
|
41
|
+
response = double("HTTParty::Response", :parsed_response => Object.new)
|
42
|
+
Virility::Pinterest.stub(:get).and_return(response)
|
43
|
+
@virility = Virility::Pinterest.new(@url)
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
it_should_behave_like "no context results"
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
context "when there is a valid result" do
|
50
|
+
before(:each) do
|
51
|
+
response = double("HTTParty::Response", :parsed_response => {"count"=>1, "url"=>"http://creativeallies.com"})
|
52
|
+
Virility::Pinterest.stub(:get).and_return(response)
|
53
|
+
@virility = Virility::Pinterest.new(@url)
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
it "should not raise an error" do
|
57
|
+
lambda { @virility.poll }.should_not raise_error
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
it "should return 1 for the count" do
|
61
|
+
@virility.count.should == 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
65
|
|
66
66
|
end
|