virility 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,66 +1,66 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "Virility::PlusOne" 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::PlusOne.stub(:get).and_return(response)
13
- @virility = Virility::PlusOne.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::PlusOne.stub(:get).and_return(response)
13
+ @virility = Virility::PlusOne.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::PlusOne.stub(:get).and_return(response)
23
- @virility = Virility::PlusOne.new(@url)
24
- end
19
+ context "when there is no result" do
20
+ before(:each) do
21
+ response = double("HTTParty::Response")
22
+ Virility::PlusOne.stub(:get).and_return(response)
23
+ @virility = Virility::PlusOne.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::PlusOne.stub(:get).and_return(response)
33
- @virility = Virility::PlusOne.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::PlusOne.stub(:get).and_return(response)
33
+ @virility = Virility::PlusOne.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::PlusOne.stub(:get).and_return(response)
43
- @virility = Virility::PlusOne.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::PlusOne.stub(:get).and_return(response)
43
+ @virility = Virility::PlusOne.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 => {"shares"=>"8"})
52
- Virility::PlusOne.stub(:get).and_return(response)
53
- @virility = Virility::PlusOne.new(@url)
54
- end
49
+ context "when there is a valid result" do
50
+ before(:each) do
51
+ response = double("HTTParty::Response", :parsed_response => {"shares"=>"8"})
52
+ Virility::PlusOne.stub(:get).and_return(response)
53
+ @virility = Virility::PlusOne.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 8 for the count" do
61
- @virility.count.should == 8
62
- end
63
- end
64
- end
60
+ it "should return 8 for the count" do
61
+ @virility.count.should == 8
62
+ end
63
+ end
64
+ end
65
65
 
66
66
  end
@@ -1,66 +1,66 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "Virility::StumbleUpon" 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::StumbleUpon.stub(:get).and_return(response)
13
- @virility = Virility::StumbleUpon.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::StumbleUpon.stub(:get).and_return(response)
13
+ @virility = Virility::StumbleUpon.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::StumbleUpon.stub(:get).and_return(response)
23
- @virility = Virility::StumbleUpon.new(@url)
24
- end
19
+ context "when there is no result" do
20
+ before(:each) do
21
+ response = double("HTTParty::Response")
22
+ Virility::StumbleUpon.stub(:get).and_return(response)
23
+ @virility = Virility::StumbleUpon.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::StumbleUpon.stub(:get).and_return(response)
33
- @virility = Virility::StumbleUpon.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::StumbleUpon.stub(:get).and_return(response)
33
+ @virility = Virility::StumbleUpon.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::StumbleUpon.stub(:get).and_return(response)
43
- @virility = Virility::StumbleUpon.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::StumbleUpon.stub(:get).and_return(response)
43
+ @virility = Virility::StumbleUpon.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/", "in_index"=>true, "publicid"=>"2UhTwK", "views"=>4731, "title"=>"Creative Allies | Create Art For Rockstars | Upload For A Chance To Win", "thumbnail"=>"http://cdn.stumble-upon.com/mthumb/388/49348388.jpg", "thumbnail_b"=>"http://cdn.stumble-upon.com/images/nobthumb.png", "submit_link"=>"http://www.stumbleupon.com/submit/?url=http://creativeallies.com/", "badge_link"=>"http://www.stumbleupon.com/badge/?url=http://creativeallies.com/", "info_link"=>"http://www.stumbleupon.com/url/creativeallies.com/"})
52
- Virility::StumbleUpon.stub(:get).and_return(response)
53
- @virility = Virility::StumbleUpon.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/", "in_index"=>true, "publicid"=>"2UhTwK", "views"=>4731, "title"=>"Creative Allies | Create Art For Rockstars | Upload For A Chance To Win", "thumbnail"=>"http://cdn.stumble-upon.com/mthumb/388/49348388.jpg", "thumbnail_b"=>"http://cdn.stumble-upon.com/images/nobthumb.png", "submit_link"=>"http://www.stumbleupon.com/submit/?url=http://creativeallies.com/", "badge_link"=>"http://www.stumbleupon.com/badge/?url=http://creativeallies.com/", "info_link"=>"http://www.stumbleupon.com/url/creativeallies.com/"})
52
+ Virility::StumbleUpon.stub(:get).and_return(response)
53
+ @virility = Virility::StumbleUpon.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 4731 for the count" do
61
- @virility.count.should == 4731
62
- end
63
- end
64
- end
60
+ it "should return 4731 for the count" do
61
+ @virility.count.should == 4731
62
+ end
63
+ end
64
+ end
65
65
 
66
66
  end
@@ -1,66 +1,66 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "Virility::Twitter" 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::Twitter.stub(:get).and_return(response)
13
- @virility = Virility::Twitter.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::Twitter.stub(:get).and_return(response)
13
+ @virility = Virility::Twitter.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::Twitter.stub(:get).and_return(response)
23
- @virility = Virility::Twitter.new(@url)
24
- end
19
+ context "when there is no result" do
20
+ before(:each) do
21
+ response = double("HTTParty::Response")
22
+ Virility::Twitter.stub(:get).and_return(response)
23
+ @virility = Virility::Twitter.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::Twitter.stub(:get).and_return(response)
33
- @virility = Virility::Twitter.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::Twitter.stub(:get).and_return(response)
33
+ @virility = Virility::Twitter.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::Twitter.stub(:get).and_return(response)
43
- @virility = Virility::Twitter.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::Twitter.stub(:get).and_return(response)
43
+ @virility = Virility::Twitter.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"=>121, "url"=>"http://creativeallies.com/"})
52
- Virility::Twitter.stub(:get).and_return(response)
53
- @virility = Virility::Twitter.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"=>121, "url"=>"http://creativeallies.com/"})
52
+ Virility::Twitter.stub(:get).and_return(response)
53
+ @virility = Virility::Twitter.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 121 for the count" do
61
- @virility.count.should == 121
62
- end
63
- end
64
- end
60
+ it "should return 121 for the count" do
61
+ @virility.count.should == 121
62
+ end
63
+ end
64
+ end
65
65
 
66
66
  end
@@ -1,102 +1,102 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Strategy" do
4
- before(:each) do
5
- @url = "http://creativeallies.com"
6
- end
7
-
8
- #
9
- # Initialization
10
- #
11
-
12
- context "initialization" do
13
- it "should raise an error if a URL is not set" do
14
- lambda {Virility::Strategy.new}.should raise_error
15
- end
16
-
17
- it "should set and encode the url" do
18
- Virility::Facebook.new(@url).url.should == "http%3A%2F%2Fcreativeallies.com"
19
- end
20
- end
21
-
22
- #
23
- # Interface
24
- #
25
-
26
- context "interface" do
27
- it "should raise an error on poll" do
28
- lambda { Virility::Strategy.new(@url).poll }.should raise_error
29
- end
30
-
31
- it "should raise an error on count" do
32
- lambda { Virility::Strategy.new(@url).count }.should raise_error
33
- end
34
- end
35
-
36
- #
37
- # Dynamic Methods
38
- #
39
-
40
- describe "dynamic methods" do
41
- before(:each) do
42
- @virility = Virility::Facebook.new(@url)
43
- @virility.stub(:results).and_return(Virility::FB_RESULTS)
44
- end
45
-
46
- context "overall testing" do
47
- Virility::FB_RESULTS.each do |key, value|
48
- it "should return #{value} when get_result is called with #{key}" do
49
- @virility.send(key).should == value
50
- end
51
- end
52
-
53
- Virility::FAKE_FB_RESULTS.each do |key|
54
- it "should_not raise an error if the result (#{key}) does not exist" do
55
- lambda { @virility.send(key) }.should_not raise_error
56
- end
57
-
58
- it "should return 0 if the result (#{key}) does not exist" do
59
- @virility.send(key).should == 0
60
- end
61
- end
62
- end
63
-
64
- context "result_exists?" do
65
- before(:each) do
66
- @virility = Virility::Facebook.new(@url)
67
- @virility.stub(:results).and_return(Virility::FB_RESULTS)
68
- end
69
-
70
- Virility::FB_RESULTS.keys.each do |result|
71
- it "should return true for #{result}" do
72
- @virility.result_exists?(result).should be true
73
- end
74
- end
75
-
76
- Virility::FAKE_FB_RESULTS.each do |result|
77
- it "should return false for #{result}" do
78
- @virility.result_exists?(result).should be false
79
- end
80
- end
81
- end
82
-
83
- context "get_result" do
84
- Virility::FB_RESULTS.each do |key, value|
85
- it "should return #{value} when get_result is called with #{key}" do
86
- @virility.get_result(key).should == value
87
- end
88
- end
89
-
90
- Virility::FAKE_FB_RESULTS.each do |key|
91
- it "should_not raise an error if the result (#{key}) does not exist" do
92
- lambda { @virility.send(key) }.should_not raise_error
93
- end
94
-
95
- it "should return 0 if the result (#{key}) does not exist" do
96
- @virility.send(key).should == 0
97
- end
98
- end
99
- end
100
-
101
- end
4
+ before(:each) do
5
+ @url = "http://creativeallies.com"
6
+ end
7
+
8
+ #
9
+ # Initialization
10
+ #
11
+
12
+ context "initialization" do
13
+ it "should raise an error if a URL is not set" do
14
+ lambda {Virility::Strategy.new}.should raise_error
15
+ end
16
+
17
+ it "should set and encode the url" do
18
+ Virility::Facebook.new(@url).url.should == "http%3A%2F%2Fcreativeallies.com"
19
+ end
20
+ end
21
+
22
+ #
23
+ # Interface
24
+ #
25
+
26
+ context "interface" do
27
+ it "should raise an error on poll" do
28
+ lambda { Virility::Strategy.new(@url).poll }.should raise_error
29
+ end
30
+
31
+ it "should raise an error on count" do
32
+ lambda { Virility::Strategy.new(@url).count }.should raise_error
33
+ end
34
+ end
35
+
36
+ #
37
+ # Dynamic Methods
38
+ #
39
+
40
+ describe "dynamic methods" do
41
+ before(:each) do
42
+ @virility = Virility::Facebook.new(@url)
43
+ @virility.stub(:results).and_return(Virility::FB_RESULTS)
44
+ end
45
+
46
+ context "overall testing" do
47
+ Virility::FB_RESULTS.each do |key, value|
48
+ it "should return #{value} when get_result is called with #{key}" do
49
+ @virility.send(key).should == value
50
+ end
51
+ end
52
+
53
+ Virility::FAKE_FB_RESULTS.each do |key|
54
+ it "should_not raise an error if the result (#{key}) does not exist" do
55
+ lambda { @virility.send(key) }.should_not raise_error
56
+ end
57
+
58
+ it "should return 0 if the result (#{key}) does not exist" do
59
+ @virility.send(key).should == 0
60
+ end
61
+ end
62
+ end
63
+
64
+ context "result_exists?" do
65
+ before(:each) do
66
+ @virility = Virility::Facebook.new(@url)
67
+ @virility.stub(:results).and_return(Virility::FB_RESULTS)
68
+ end
69
+
70
+ Virility::FB_RESULTS.keys.each do |result|
71
+ it "should return true for #{result}" do
72
+ @virility.result_exists?(result).should be true
73
+ end
74
+ end
75
+
76
+ Virility::FAKE_FB_RESULTS.each do |result|
77
+ it "should return false for #{result}" do
78
+ @virility.result_exists?(result).should be false
79
+ end
80
+ end
81
+ end
82
+
83
+ context "get_result" do
84
+ Virility::FB_RESULTS.each do |key, value|
85
+ it "should return #{value} when get_result is called with #{key}" do
86
+ @virility.get_result(key).should == value
87
+ end
88
+ end
89
+
90
+ Virility::FAKE_FB_RESULTS.each do |key|
91
+ it "should_not raise an error if the result (#{key}) does not exist" do
92
+ lambda { @virility.send(key) }.should_not raise_error
93
+ end
94
+
95
+ it "should return 0 if the result (#{key}) does not exist" do
96
+ @virility.send(key).should == 0
97
+ end
98
+ end
99
+ end
100
+
101
+ end
102
102
  end