virility 0.1.0 → 0.1.1

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.
@@ -18,11 +18,11 @@ end
18
18
  #
19
19
 
20
20
  module Virility
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]
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
- it "should not raise an error" do
35
- lambda { @virility.poll }.should_not raise_error
36
- end
34
+ it "should not raise an error" do
35
+ lambda { @virility.poll }.should_not raise_error
36
+ end
37
37
 
38
- it "should return 0 for count" do
39
- @virility.count.should == 0
40
- end
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
- 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
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
- it_should_behave_like "no context results"
17
- end
16
+ it_should_behave_like "no context results"
17
+ end
18
18
 
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
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
- it_should_behave_like "no context results"
27
- end
26
+ it_should_behave_like "no context results"
27
+ end
28
28
 
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
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
- it_should_behave_like "no context results"
37
- end
36
+ it_should_behave_like "no context results"
37
+ end
38
38
 
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
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
- it_should_behave_like "no context results"
47
- end
46
+ it_should_behave_like "no context results"
47
+ end
48
48
 
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
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
- it "should not raise an error" do
57
- lambda { @virility.poll }.should_not raise_error
58
- end
56
+ it "should not raise an error" do
57
+ lambda { @virility.poll }.should_not raise_error
58
+ end
59
59
 
60
- it "should return 50 for the count" do
61
- @virility.count.should == 50
62
- end
63
- end
64
- end
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
- 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
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
- 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
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
- it_should_behave_like "no context results"
17
- end
16
+ it_should_behave_like "no context results"
17
+ end
18
18
 
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
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
- it_should_behave_like "no context results"
27
- end
26
+ it_should_behave_like "no context results"
27
+ end
28
28
 
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
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
- it_should_behave_like "no context results"
37
- end
36
+ it_should_behave_like "no context results"
37
+ end
38
38
 
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
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
- it_should_behave_like "no context results"
47
- end
46
+ it_should_behave_like "no context results"
47
+ end
48
48
 
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
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
- it "should not raise an error" do
57
- lambda { @virility.poll }.should_not raise_error
58
- end
56
+ it "should not raise an error" do
57
+ lambda { @virility.poll }.should_not raise_error
58
+ end
59
59
 
60
- it "should return 1 for the count" do
61
- @virility.count.should == 1
62
- end
63
- end
64
- end
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