virility 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 192acfdf2d757a8fd21934d481e5b76879bce823
4
- data.tar.gz: 71f7a4ff20a49e39d5228132ed10513485afff84
3
+ metadata.gz: 554a235ea250af95894241a6e9355737a26bee66
4
+ data.tar.gz: c3a69e3f7d9b7e54ee8eac49e49eb1e488c29ab1
5
5
  SHA512:
6
- metadata.gz: 86ac8277dcb48e7559f035b24e3d736e3c37c53fbd70dfcd17cf62452de1fb020f5e37a83824881cab6462f428d8140f9dce3ec3c331e1671dd94f53f9be9b8d
7
- data.tar.gz: 0fe93108823ec634512bb5810524fa8a8a384a7c3df89bb38efc72959958abefccaa77ef96c5925f20484df0224612adab85129e6edcbe740f946b302556d977
6
+ metadata.gz: cead613eadceaec0a0f9d2535e9ab44c585e96a17a6906b22c911b20625494db85a4b80b87e9515392eda63b39d04c801ad096fb816c675ee78fbbbdd8f29beb
7
+ data.tar.gz: 07c0df627f75818bce04941e27fdb88d754a0b66c36e3dd917da84028d705650911ad4ff2d3df4b40e24c15e4b881712fad5dba375d28f58d743c6e303d6afc7
@@ -1 +1 @@
1
- ruby-2.0.0-p451
1
+ ruby-2.2.4
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Virility calls upon the API's of many popular social services such as Facebook, Twitter and Pinterest to collect the number of likes, tweets, pins etc. of a particular URL. Written with a modular construction, Virility makes it easy to drop new data collection strategies into the framework so that you can collect all of your statistics in one easy location.
4
4
 
5
+ View a demo online: http://virility.herokuapp.com/
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -39,7 +41,6 @@ The Virility::Excitation object does the heavy lifting of collecting the data fr
39
41
  Currently there is support for the following social resources:
40
42
  * Facebook
41
43
  * Twitter
42
- * Delicious
43
44
  * Pinterest
44
45
  * Google Plus One
45
46
  * Stumble Upon
@@ -131,7 +132,7 @@ On this particular day, there was a 5,495 count difference between the two value
131
132
  Virility::Excitation.new("http://www.ruby-lang.org/en/").counts
132
133
  # => {:delicious=>4314, :facebook=>813, :pinterest=>22, :plusone=>406, :stumbleupon=>246937, :twitter=>698}
133
134
 
134
- Stumbleupon and Twitter are consistent while Delicious, Facebook, Pinterest and Google Plus One return different results. Depending on your needs, you could craft an algorithm that takes all of this into account and attempts to deliver an accurate number by combining the data sets that are different and trusting the ones that are the same.
135
+ Stumbleupon and Twitter are consistent while Facebook, Pinterest and Google Plus One return different results. Depending on your needs, you could craft an algorithm that takes all of this into account and attempts to deliver an accurate number by combining the data sets that are different and trusting the ones that are the same.
135
136
 
136
137
  Based on this logic, it is possible to consider that the true total share count is closer to _253,250_. Not only is this an opinionated number, it's accuracy is questionable based on assumptions, however if you are just trying to get a ballpark feeling of the virility of your content, this number should suffice.
137
138
 
@@ -146,4 +147,4 @@ Based on this logic, it is possible to consider that the true total share count
146
147
  ## Copyright
147
148
 
148
149
  Copyright (c) 2012 Jay Sanders. See LICENSE.txt for
149
- further details.
150
+ further details.
@@ -3,13 +3,14 @@ module Virility
3
3
  include HTTParty
4
4
  include Virility::Supporter
5
5
 
6
- attr_accessor :url, :response, :results
6
+ attr_accessor :url, :response, :results, :original_url
7
7
 
8
8
  def initialize url
9
- @url = encode url
9
+ @original_url = url
10
+ @url = encode(url)
10
11
  @results = {}
11
12
  end
12
-
13
+
13
14
  #
14
15
  # Abstract Methods - Delete eventually
15
16
  #
@@ -21,20 +22,20 @@ module Virility
21
22
  def count
22
23
  raise "Abstract Method count called on #{self.class} - Please define this method"
23
24
  end
24
-
25
+
25
26
  #
26
27
  # Poll
27
28
  #
28
-
29
+
29
30
  def poll
30
31
  call_strategy
31
32
  collect_results
32
33
  end
33
-
34
+
34
35
  #
35
36
  # Call Strategy
36
37
  #
37
-
38
+
38
39
  def call_strategy
39
40
  @response = census
40
41
  end
@@ -42,7 +43,7 @@ module Virility
42
43
  #
43
44
  # Results
44
45
  #
45
-
46
+
46
47
  def collect_results
47
48
  if respond_to?(:outcome)
48
49
  @results = valid_response_test ? outcome : {}
@@ -1,3 +1,3 @@
1
1
  module Virility
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -11,7 +11,7 @@ describe "Excitation" do
11
11
 
12
12
  context "initialization" do
13
13
  it "should raise an error if a URL is not set" do
14
- lambda {Virility::Excitation.new}.should raise_error
14
+ expect{Virility::Excitation.new}.to raise_error(ArgumentError, "wrong number of arguments (0 for 1)")
15
15
  end
16
16
  end
17
17
 
@@ -19,11 +19,11 @@ describe "Excitation" do
19
19
  # Get Virility
20
20
  #
21
21
 
22
- # context "poll" do
23
- # it "should not raise an error" do
24
- # lambda {Virility::Excitation.new(@url).poll}.should_not raise_error
25
- # end
26
- # end
22
+ context "poll" do
23
+ it "should not raise an error" do
24
+ expect{Virility::Excitation.new(@url).poll}.not_to raise_error
25
+ end
26
+ end
27
27
 
28
28
  #
29
29
  # Collect Strategies
@@ -31,15 +31,15 @@ describe "Excitation" do
31
31
 
32
32
  context "collect_strategies" do
33
33
  it "should assign a hash to the strategies variable" do
34
- Virility::Excitation.new(@url).strategies.should be_a_kind_of Hash
34
+ expect(Virility::Excitation.new(@url).strategies).to be_a_kind_of Hash
35
35
  end
36
36
 
37
37
  it "strategies should be inherited from the Strategy" do
38
- Virility::Excitation.new(@url).strategies.first.last.should be_a_kind_of Virility::Strategy
38
+ expect(Virility::Excitation.new(@url).strategies.first.last).to be_a_kind_of Virility::Strategy
39
39
  end
40
40
 
41
41
  it "should load all of the strategies" do
42
- Virility::Excitation.new(@url).strategies.count.should == Dir[File.join('lib', 'virility', 'strategies', '**', '*')].count { |file| File.file?(file) }
42
+ expect(Virility::Excitation.new(@url).strategies.count).to eq(Dir[File.join('lib', 'virility', 'strategies', '**', '*')].count { |file| File.file?(file) })
43
43
  end
44
44
  end
45
45
 
@@ -50,7 +50,7 @@ describe "Excitation" do
50
50
  context "encode" do
51
51
  it "should encode the url" do
52
52
  v = Virility::Excitation.new(@url)
53
- v.encode(@url).should == "http%3A%2F%2Fcreativeallies.com"
53
+ expect(v.encode(@url)).to eq("http%3A%2F%2Fcreativeallies.com")
54
54
  end
55
55
  end
56
56
 
@@ -60,7 +60,7 @@ describe "Excitation" do
60
60
 
61
61
  context "symbolize_for_key" do
62
62
  it "should return a symbol with the name of the class" do
63
- Virility::Excitation.new(@url).symbolize_for_key(Virility::Excitation.new(@url)).should == :excitation
63
+ expect(Virility::Excitation.new(@url).symbolize_for_key(Virility::Excitation.new(@url))).to eq(:excitation)
64
64
  end
65
65
  end
66
66
 
@@ -72,13 +72,13 @@ describe "Excitation" do
72
72
  context "overall testing" do
73
73
  Virility::TESTING_STRATEGIES.each do |method, klass|
74
74
  it "should return a #{klass} object when the method #{method} is called" do
75
- Virility::Excitation.new(@url).send(method).should be_a_kind_of klass
75
+ expect(Virility::Excitation.new(@url).send(method)).to be_a_kind_of(klass)
76
76
  end
77
77
  end
78
78
 
79
79
  Virility::FAKE_TESTING_STRATEGIES.each do |method|
80
80
  it "should raise an error if the strategy (#{method}) does not exist" do
81
- lambda { Virility::Excitation.new(@url).send(method) }.should raise_error(Virility::UnknownStrategy, "#{method} Is Not A Known Strategy")
81
+ expect{ Virility::Excitation.new(@url).send(method) }.to raise_error(Virility::UnknownStrategy, "#{method} Is Not A Known Strategy")
82
82
  end
83
83
  end
84
84
  end
@@ -86,13 +86,13 @@ describe "Excitation" do
86
86
  context "strategy_exists?" do
87
87
  Virility::TESTING_STRATEGIES.keys.each do |strategy|
88
88
  it "should return true for #{strategy}" do
89
- Virility::Excitation.new(@url).strategy_exists?(strategy).should be true
89
+ expect(Virility::Excitation.new(@url).strategy_exists?(strategy)).to be(true)
90
90
  end
91
91
  end
92
92
 
93
93
  Virility::FAKE_TESTING_STRATEGIES.each do |strategy|
94
94
  it "should return false for #{strategy}" do
95
- Virility::Excitation.new(@url).strategy_exists?(strategy).should be false
95
+ expect(Virility::Excitation.new(@url).strategy_exists?(strategy)).to be(false)
96
96
  end
97
97
  end
98
98
  end
@@ -100,17 +100,15 @@ describe "Excitation" do
100
100
  context "get_strategy" do
101
101
  Virility::TESTING_STRATEGIES.each do |method, klass|
102
102
  it "should return a #{klass} object when get_strategy is called with #{method}" do
103
- Virility::Excitation.new(@url).get_strategy(method).should be_a_kind_of klass
103
+ expect(Virility::Excitation.new(@url).get_strategy(method)).to be_a_kind_of(klass)
104
104
  end
105
105
  end
106
106
 
107
107
  Virility::FAKE_TESTING_STRATEGIES.each do |method|
108
108
  it "should raise an error if the strategy (#{method}) does not exist" do
109
- lambda { Virility::Excitation.new(@url).get_strategy(method) }.should raise_error(Virility::UnknownStrategy, "#{method} Is Not A Known Strategy")
109
+ expect(lambda { Virility::Excitation.new(@url).get_strategy(method) }).to raise_error(Virility::UnknownStrategy, "#{method} Is Not A Known Strategy")
110
110
  end
111
111
  end
112
112
  end
113
-
114
113
  end
115
-
116
114
  end
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
+ require 'pry'
4
5
  require 'virility'
5
6
 
6
7
  # Requires supporting files with custom matchers and macros, etc,
@@ -10,7 +11,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
11
  RSpec.configure do |config|
11
12
  config.filter_run :focus => true
12
13
  config.run_all_when_everything_filtered = true
13
- config.mock_with :rspec
14
+ config.mock_with :rspec
14
15
  end
15
16
 
16
17
  #
@@ -18,24 +19,29 @@ end
18
19
  #
19
20
 
20
21
  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
+ TESTING_STRATEGIES = {
23
+ :facebook => Virility::Facebook,
24
+ :twitter => Virility::Twitter,
25
+ :pinterest => Virility::Pinterest,
26
+ :plus_one => Virility::PlusOne,
27
+ :stumble_upon => Virility::StumbleUpon
28
+ }
22
29
  FAKE_TESTING_STRATEGIES = [:digg, :reddit, :linked_in, :instagram, :tumblr]
23
-
30
+
24
31
  FB_RESULTS = {"like_count"=>"19", "click_count"=>"0", "share_count"=>"3", "comment_count"=>"0", "commentsbox_count"=>"0", "total_count"=>"22"}
25
32
  FAKE_FB_RESULTS = [:face_count, :pages, :friends]
26
33
  end
27
34
 
28
-
29
35
  #
30
36
  # Example Groups
31
37
  #
32
38
 
33
- share_examples_for "no context results" do
39
+ RSpec.shared_examples "no context results" do
34
40
  it "should not raise an error" do
35
- lambda { @virility.poll }.should_not raise_error
41
+ expect{ @virility.poll }.not_to raise_error
36
42
  end
37
43
 
38
44
  it "should return 0 for count" do
39
- @virility.count.should == 0
45
+ expect(@virility.count).to eq(0)
40
46
  end
41
47
  end
@@ -4,24 +4,24 @@ describe "Virility::Facebook" do
4
4
  before(:each) do
5
5
  @url = "http://creativeallies.com"
6
6
  end
7
-
8
- share_examples_for "no facebook results" do
7
+
8
+ RSpec.shared_examples "no facebook results" do
9
9
  it "should not raise an error" do
10
- lambda { @virility.poll }.should_not raise_error
10
+ expect{ @virility.poll }.not_to raise_error
11
11
  end
12
12
 
13
13
  ["like_count", "click_count", "share_count", "comment_count", "commentsbox_count", "total_count"].each do |attribute|
14
14
  it "should return 0 for #{attribute}" do
15
- @virility.send(attribute.to_sym).should == 0
15
+ expect(@virility.send(attribute.to_sym)).to eq(0)
16
16
  end
17
- end
17
+ end
18
18
  end
19
19
 
20
20
  describe "poll" do
21
21
  context "when there is not a valid result" do
22
22
  before(:each) do
23
23
  response = double("HTTParty::Response", :parsed_response => {"fql_query_response"=>{"list"=>"true"}})
24
- Virility::Facebook.stub(:get).and_return(response)
24
+ allow(Virility::Facebook).to receive(:get) { response }
25
25
  @virility = Virility::Facebook.new(@url)
26
26
  end
27
27
 
@@ -31,7 +31,7 @@ describe "Virility::Facebook" do
31
31
  context "when there is no result" do
32
32
  before(:each) do
33
33
  response = double("HTTParty::Response")
34
- Virility::Facebook.stub(:get).and_return(response)
34
+ allow(Virility::Facebook).to receive(:get) { response }
35
35
  @virility = Virility::Facebook.new(@url)
36
36
  end
37
37
 
@@ -41,7 +41,7 @@ describe "Virility::Facebook" do
41
41
  context "when there is a result but no fql_query_response" do
42
42
  before(:each) do
43
43
  response = double("HTTParty::Response", :parsed_response => {})
44
- Virility::Facebook.stub(:get).and_return(response)
44
+ allow(Virility::Facebook).to receive(:get) { response }
45
45
  @virility = Virility::Facebook.new(@url)
46
46
  end
47
47
 
@@ -51,7 +51,7 @@ describe "Virility::Facebook" do
51
51
  context "when there is a result but parsed_response is weird" do
52
52
  before(:each) do
53
53
  response = double("HTTParty::Response", :parsed_response => Object.new)
54
- Virility::Facebook.stub(:get).and_return(response)
54
+ allow(Virility::Facebook).to receive(:get) { response }
55
55
  @virility = Virility::Facebook.new(@url)
56
56
  end
57
57
 
@@ -61,17 +61,17 @@ describe "Virility::Facebook" do
61
61
  context "when there is a valid result" do
62
62
  before(:each) do
63
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)
64
+ allow(Virility::Facebook).to receive(:get) { response }
65
65
  @virility = Virility::Facebook.new(@url)
66
66
  end
67
67
 
68
68
  it "should not raise an error" do
69
- lambda { @virility.poll }.should_not raise_error
69
+ expect{ @virility.poll }.not_to raise_error
70
70
  end
71
71
 
72
72
  {"like_count"=>"977662", "click_count"=>"265614", "share_count"=>"3020040", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}.each do |key, value|
73
73
  it "should return #{value} for #{key}" do
74
- @virility.send(key.to_sym).should == value
74
+ expect(@virility.send(key.to_sym)).to eq(value)
75
75
  end
76
76
  end
77
77
  end
@@ -79,17 +79,17 @@ describe "Virility::Facebook" do
79
79
  context "when there is a valid result, but not all fields are present" do
80
80
  before(:each) do
81
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)
82
+ allow(Virility::Facebook).to receive(:get) { response }
83
83
  @virility = Virility::Facebook.new(@url)
84
84
  end
85
85
 
86
86
  it "should not raise an error" do
87
- lambda { @virility.poll }.should_not raise_error
87
+ expect{ @virility.poll }.not_to raise_error
88
88
  end
89
89
 
90
90
  {"like_count"=>"977662", "click_count"=>0, "share_count"=>0, "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}.each do |key, value|
91
91
  it "should return #{value} for #{key}" do
92
- @virility.send(key.to_sym).should == value
92
+ expect(@virility.send(key.to_sym)).to eq(value)
93
93
  end
94
94
  end
95
95
  end
@@ -4,12 +4,12 @@ describe "Virility::Pinterest" do
4
4
  before(:each) do
5
5
  @url = "http://creativeallies.com"
6
6
  end
7
-
7
+
8
8
  describe "poll" do
9
9
  context "when there is not a valid result" do
10
10
  before(:each) do
11
11
  response = double("HTTParty::Response", :parsed_response => {"fake_return_value"=> "OICU812"})
12
- Virility::Pinterest.stub(:get).and_return(response)
12
+ allow(Virility::Pinterest).to receive(:get) { response }
13
13
  @virility = Virility::Pinterest.new(@url)
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ describe "Virility::Pinterest" do
19
19
  context "when there is no result" do
20
20
  before(:each) do
21
21
  response = double("HTTParty::Response")
22
- Virility::Pinterest.stub(:get).and_return(response)
22
+ allow(Virility::Pinterest).to receive(:get) { response }
23
23
  @virility = Virility::Pinterest.new(@url)
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ describe "Virility::Pinterest" do
29
29
  context "when there is a result but no specific hash value" do
30
30
  before(:each) do
31
31
  response = double("HTTParty::Response", :parsed_response => {})
32
- Virility::Pinterest.stub(:get).and_return(response)
32
+ allow(Virility::Pinterest).to receive(:get) { response }
33
33
  @virility = Virility::Pinterest.new(@url)
34
34
  end
35
35
 
@@ -39,7 +39,7 @@ describe "Virility::Pinterest" do
39
39
  context "when there is a result but parsed_response is weird" do
40
40
  before(:each) do
41
41
  response = double("HTTParty::Response", :parsed_response => Object.new)
42
- Virility::Pinterest.stub(:get).and_return(response)
42
+ allow(Virility::Pinterest).to receive(:get) { response }
43
43
  @virility = Virility::Pinterest.new(@url)
44
44
  end
45
45
 
@@ -49,16 +49,16 @@ describe "Virility::Pinterest" do
49
49
  context "when there is a valid result" do
50
50
  before(:each) do
51
51
  response = double("HTTParty::Response", :parsed_response => {"count"=>1, "url"=>"http://creativeallies.com"})
52
- Virility::Pinterest.stub(:get).and_return(response)
52
+ allow(Virility::Pinterest).to receive(:get) { response }
53
53
  @virility = Virility::Pinterest.new(@url)
54
54
  end
55
55
 
56
56
  it "should not raise an error" do
57
- lambda { @virility.poll }.should_not raise_error
57
+ expect{ @virility.poll }.not_to raise_error
58
58
  end
59
59
 
60
60
  it "should return 1 for the count" do
61
- @virility.count.should == 1
61
+ expect(@virility.count).to eq(1)
62
62
  end
63
63
  end
64
64
  end
@@ -4,12 +4,12 @@ describe "Virility::PlusOne" do
4
4
  before(:each) do
5
5
  @url = "http://creativeallies.com"
6
6
  end
7
-
7
+
8
8
  describe "poll" do
9
9
  context "when there is not a valid result" do
10
10
  before(:each) do
11
11
  response = double("HTTParty::Response", :parsed_response => {"fake_return_value"=> "OICU812"})
12
- Virility::PlusOne.stub(:get).and_return(response)
12
+ allow(Virility::PlusOne).to receive(:get) { response }
13
13
  @virility = Virility::PlusOne.new(@url)
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ describe "Virility::PlusOne" do
19
19
  context "when there is no result" do
20
20
  before(:each) do
21
21
  response = double("HTTParty::Response")
22
- Virility::PlusOne.stub(:get).and_return(response)
22
+ allow(Virility::PlusOne).to receive(:get) { response }
23
23
  @virility = Virility::PlusOne.new(@url)
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ describe "Virility::PlusOne" do
29
29
  context "when there is a result but no specific hash value" do
30
30
  before(:each) do
31
31
  response = double("HTTParty::Response", :parsed_response => {})
32
- Virility::PlusOne.stub(:get).and_return(response)
32
+ allow(Virility::PlusOne).to receive(:get) { response }
33
33
  @virility = Virility::PlusOne.new(@url)
34
34
  end
35
35
 
@@ -39,7 +39,7 @@ describe "Virility::PlusOne" do
39
39
  context "when there is a result but parsed_response is weird" do
40
40
  before(:each) do
41
41
  response = double("HTTParty::Response", :parsed_response => Object.new)
42
- Virility::PlusOne.stub(:get).and_return(response)
42
+ allow(Virility::PlusOne).to receive(:get) { response }
43
43
  @virility = Virility::PlusOne.new(@url)
44
44
  end
45
45
 
@@ -49,16 +49,16 @@ describe "Virility::PlusOne" do
49
49
  context "when there is a valid result" do
50
50
  before(:each) do
51
51
  response = double("HTTParty::Response", :parsed_response => {"shares"=>"8"})
52
- Virility::PlusOne.stub(:get).and_return(response)
52
+ allow(Virility::PlusOne).to receive(:get) { response }
53
53
  @virility = Virility::PlusOne.new(@url)
54
54
  end
55
55
 
56
56
  it "should not raise an error" do
57
- lambda { @virility.poll }.should_not raise_error
57
+ expect{ @virility.poll }.not_to raise_error
58
58
  end
59
59
 
60
60
  it "should return 8 for the count" do
61
- @virility.count.should == 8
61
+ expect(@virility.count).to eq(8)
62
62
  end
63
63
  end
64
64
  end
@@ -4,12 +4,12 @@ describe "Virility::StumbleUpon" do
4
4
  before(:each) do
5
5
  @url = "http://creativeallies.com"
6
6
  end
7
-
7
+
8
8
  describe "poll" do
9
9
  context "when there is not a valid result" do
10
10
  before(:each) do
11
11
  response = double("HTTParty::Response", :parsed_response => {"fake_return_value"=> "OICU812"})
12
- Virility::StumbleUpon.stub(:get).and_return(response)
12
+ allow(Virility::StumbleUpon).to receive(:get) { response }
13
13
  @virility = Virility::StumbleUpon.new(@url)
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ describe "Virility::StumbleUpon" do
19
19
  context "when there is no result" do
20
20
  before(:each) do
21
21
  response = double("HTTParty::Response")
22
- Virility::StumbleUpon.stub(:get).and_return(response)
22
+ allow(Virility::StumbleUpon).to receive(:get) { response }
23
23
  @virility = Virility::StumbleUpon.new(@url)
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ describe "Virility::StumbleUpon" do
29
29
  context "when there is a result but no specific hash value" do
30
30
  before(:each) do
31
31
  response = double("HTTParty::Response", :parsed_response => {})
32
- Virility::StumbleUpon.stub(:get).and_return(response)
32
+ allow(Virility::StumbleUpon).to receive(:get) { response }
33
33
  @virility = Virility::StumbleUpon.new(@url)
34
34
  end
35
35
 
@@ -39,7 +39,7 @@ describe "Virility::StumbleUpon" do
39
39
  context "when there is a result but parsed_response is weird" do
40
40
  before(:each) do
41
41
  response = double("HTTParty::Response", :parsed_response => Object.new)
42
- Virility::StumbleUpon.stub(:get).and_return(response)
42
+ allow(Virility::StumbleUpon).to receive(:get) { response }
43
43
  @virility = Virility::StumbleUpon.new(@url)
44
44
  end
45
45
 
@@ -49,16 +49,16 @@ describe "Virility::StumbleUpon" do
49
49
  context "when there is a valid result" do
50
50
  before(:each) do
51
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)
52
+ allow(Virility::StumbleUpon).to receive(:get) { response }
53
53
  @virility = Virility::StumbleUpon.new(@url)
54
54
  end
55
55
 
56
56
  it "should not raise an error" do
57
- lambda { @virility.poll }.should_not raise_error
57
+ expect{ @virility.poll }.not_to raise_error
58
58
  end
59
59
 
60
60
  it "should return 4731 for the count" do
61
- @virility.count.should == 4731
61
+ expect(@virility.count).to eq(4731)
62
62
  end
63
63
  end
64
64
  end
@@ -4,12 +4,12 @@ describe "Virility::Twitter" do
4
4
  before(:each) do
5
5
  @url = "http://creativeallies.com"
6
6
  end
7
-
7
+
8
8
  describe "poll" do
9
9
  context "when there is not a valid result" do
10
10
  before(:each) do
11
11
  response = double("HTTParty::Response", :parsed_response => {"fake_return_value"=> "OICU812"})
12
- Virility::Twitter.stub(:get).and_return(response)
12
+ allow(Virility::Twitter).to receive(:get) { response }
13
13
  @virility = Virility::Twitter.new(@url)
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ describe "Virility::Twitter" do
19
19
  context "when there is no result" do
20
20
  before(:each) do
21
21
  response = double("HTTParty::Response")
22
- Virility::Twitter.stub(:get).and_return(response)
22
+ allow(Virility::Twitter).to receive(:get) { response }
23
23
  @virility = Virility::Twitter.new(@url)
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ describe "Virility::Twitter" do
29
29
  context "when there is a result but no specific hash value" do
30
30
  before(:each) do
31
31
  response = double("HTTParty::Response", :parsed_response => {})
32
- Virility::Twitter.stub(:get).and_return(response)
32
+ allow(Virility::Twitter).to receive(:get) { response }
33
33
  @virility = Virility::Twitter.new(@url)
34
34
  end
35
35
 
@@ -39,7 +39,7 @@ describe "Virility::Twitter" do
39
39
  context "when there is a result but parsed_response is weird" do
40
40
  before(:each) do
41
41
  response = double("HTTParty::Response", :parsed_response => Object.new)
42
- Virility::Twitter.stub(:get).and_return(response)
42
+ allow(Virility::Twitter).to receive(:get) { response }
43
43
  @virility = Virility::Twitter.new(@url)
44
44
  end
45
45
 
@@ -49,16 +49,16 @@ describe "Virility::Twitter" do
49
49
  context "when there is a valid result" do
50
50
  before(:each) do
51
51
  response = double("HTTParty::Response", :parsed_response => {"count"=>121, "url"=>"http://creativeallies.com/"})
52
- Virility::Twitter.stub(:get).and_return(response)
52
+ allow(Virility::Twitter).to receive(:get) { response }
53
53
  @virility = Virility::Twitter.new(@url)
54
54
  end
55
55
 
56
56
  it "should not raise an error" do
57
- lambda { @virility.poll }.should_not raise_error
57
+ expect{ @virility.poll }.not_to raise_error
58
58
  end
59
59
 
60
60
  it "should return 121 for the count" do
61
- @virility.count.should == 121
61
+ expect(@virility.count).to eq(121)
62
62
  end
63
63
  end
64
64
  end
@@ -11,11 +11,11 @@ describe "Strategy" do
11
11
 
12
12
  context "initialization" do
13
13
  it "should raise an error if a URL is not set" do
14
- lambda {Virility::Strategy.new}.should raise_error
14
+ expect{Virility::Strategy.new}.to raise_error(ArgumentError, "wrong number of arguments (0 for 1)")
15
15
  end
16
16
 
17
17
  it "should set and encode the url" do
18
- Virility::Facebook.new(@url).url.should == "http%3A%2F%2Fcreativeallies.com"
18
+ expect(Virility::Facebook.new(@url).url).to eq("http%3A%2F%2Fcreativeallies.com")
19
19
  end
20
20
  end
21
21
 
@@ -25,11 +25,11 @@ describe "Strategy" do
25
25
 
26
26
  context "interface" do
27
27
  it "should raise an error on poll" do
28
- lambda { Virility::Strategy.new(@url).poll }.should raise_error
28
+ expect{ Virility::Strategy.new(@url).poll }.to raise_error(RuntimeError, "Abstract Method census called on Virility::Strategy - Please define this method")
29
29
  end
30
30
 
31
31
  it "should raise an error on count" do
32
- lambda { Virility::Strategy.new(@url).count }.should raise_error
32
+ expect{ Virility::Strategy.new(@url).count }.to raise_error(RuntimeError, "Abstract Method count called on Virility::Strategy - Please define this method")
33
33
  end
34
34
  end
35
35
 
@@ -40,23 +40,23 @@ describe "Strategy" do
40
40
  describe "dynamic methods" do
41
41
  before(:each) do
42
42
  @virility = Virility::Facebook.new(@url)
43
- @virility.stub(:results).and_return(Virility::FB_RESULTS)
43
+ allow(@virility).to receive(:results) { Virility::FB_RESULTS }
44
44
  end
45
45
 
46
46
  context "overall testing" do
47
47
  Virility::FB_RESULTS.each do |key, value|
48
48
  it "should return #{value} when get_result is called with #{key}" do
49
- @virility.send(key).should == value
49
+ expect(@virility.send(key)).to eq(value)
50
50
  end
51
51
  end
52
52
 
53
53
  Virility::FAKE_FB_RESULTS.each do |key|
54
54
  it "should_not raise an error if the result (#{key}) does not exist" do
55
- lambda { @virility.send(key) }.should_not raise_error
55
+ expect{ @virility.send(key) }.not_to raise_error
56
56
  end
57
-
57
+
58
58
  it "should return 0 if the result (#{key}) does not exist" do
59
- @virility.send(key).should == 0
59
+ expect(@virility.send(key)).to eq(0)
60
60
  end
61
61
  end
62
62
  end
@@ -64,18 +64,18 @@ describe "Strategy" do
64
64
  context "result_exists?" do
65
65
  before(:each) do
66
66
  @virility = Virility::Facebook.new(@url)
67
- @virility.stub(:results).and_return(Virility::FB_RESULTS)
67
+ allow(@virility).to receive(:results) { Virility::FB_RESULTS }
68
68
  end
69
69
 
70
70
  Virility::FB_RESULTS.keys.each do |result|
71
71
  it "should return true for #{result}" do
72
- @virility.result_exists?(result).should be true
72
+ expect(@virility.result_exists?(result)).to eq(true)
73
73
  end
74
74
  end
75
75
 
76
76
  Virility::FAKE_FB_RESULTS.each do |result|
77
77
  it "should return false for #{result}" do
78
- @virility.result_exists?(result).should be false
78
+ expect(@virility.result_exists?(result)).to eq(false)
79
79
  end
80
80
  end
81
81
  end
@@ -83,17 +83,17 @@ describe "Strategy" do
83
83
  context "get_result" do
84
84
  Virility::FB_RESULTS.each do |key, value|
85
85
  it "should return #{value} when get_result is called with #{key}" do
86
- @virility.get_result(key).should == value
86
+ expect(@virility.get_result(key)).to eq(value)
87
87
  end
88
88
  end
89
89
 
90
90
  Virility::FAKE_FB_RESULTS.each do |key|
91
91
  it "should_not raise an error if the result (#{key}) does not exist" do
92
- lambda { @virility.send(key) }.should_not raise_error
92
+ expect{ @virility.send(key) }.not_to raise_error
93
93
  end
94
-
94
+
95
95
  it "should return 0 if the result (#{key}) does not exist" do
96
- @virility.send(key).should == 0
96
+ expect(@virility.send(key)).to eq(0)
97
97
  end
98
98
  end
99
99
  end
@@ -10,7 +10,7 @@ describe "Virility" do
10
10
  context "valid strategies" do
11
11
  Virility::TESTING_STRATEGIES.each do |strategy, object|
12
12
  it "#{strategy} should create and return a #{object} object" do
13
- Virility.factory(strategy, "http://creativeallies.com").should be_a_kind_of object
13
+ expect(Virility.factory(strategy, "http://creativeallies.com")).to be_a_kind_of(object)
14
14
  end
15
15
  end
16
16
  end
@@ -18,7 +18,7 @@ describe "Virility" do
18
18
  context "invalid strategies" do
19
19
  Virility::FAKE_TESTING_STRATEGIES.each do |strategy|
20
20
  it "#{strategy} should raise an error" do
21
- lambda { Virility.factory(strategy, "http://creativeallies.com") }.should raise_error
21
+ expect{ Virility.factory(strategy, "http://creativeallies.com") }.to raise_error(Virility::UnknownStrategy, "#{strategy} Is Not A Known Strategy")
22
22
  end
23
23
  end
24
24
  end
@@ -31,44 +31,51 @@ describe "Virility" do
31
31
  describe "Public API testing" do
32
32
  before(:each) do
33
33
  @url = "http://creativeallies.com"
34
- Virility::Delicious.stub(:get).and_return(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"}))
35
- Virility::Facebook.stub(:get).and_return(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"}}}))
36
- Virility::Pinterest.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"count"=>1, "url"=>"http://creativeallies.com"}))
37
- Virility::PlusOne.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"shares"=>"8"}))
38
- Virility::StumbleUpon.stub(:get).and_return(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/"}))
39
- Virility::Twitter.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"count"=>121, "url"=>"http://creativeallies.com/"}))
34
+ allow(Virility::Facebook).to receive(:get) { 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"}}}) }
35
+ allow(Virility::Pinterest).to receive(:get) { double("HTTParty::Response", :parsed_response => {"count"=>1, "url"=>"http://creativeallies.com"}) }
36
+ allow(Virility::PlusOne).to receive(:get) { double("HTTParty::Response", :parsed_response => {"shares"=>"8"}) }
37
+ allow(Virility::StumbleUpon).to receive(:get) { 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/"}) }
38
+ allow(Virility::Twitter).to receive(:get) { double("HTTParty::Response", :parsed_response => {"count"=>121, "url"=>"http://creativeallies.com/"}) }
39
+ allow(Virility::Linkedin).to receive(:get) { double("HTTParty::Response", :parsed_response => { "count":17, "fCnt":"17", "fCntPlusOne":"18", "url":"http:\/\/creativeallies.com" }) }
40
40
  end
41
-
41
+
42
42
  it "Virility.counts should return a hash of counts" do
43
- Virility.counts(@url).should == {:delicious=>50, :facebook=>5116303, :pinterest=>1, :plus_one=>8, :stumble_upon=>4731, :twitter=>121}
43
+ expect(Virility.counts(@url)).to eq({:facebook=>5116303, :linkedin => 17, :pinterest=>1, :plus_one=>8, :stumble_upon=>4731, :twitter=>121})
44
44
  end
45
-
45
+
46
46
  it "Virility.total should return the total count" do
47
- Virility.total(@url).should == 5121214
47
+ expect(Virility.total(@url)).to eq(5121181)
48
48
  end
49
-
49
+
50
50
  it "Virility.poll should return all of the hashed responses" do
51
- Virility.poll(@url).should == {:delicious=>{"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"}, :facebook=>{"like_count"=>"977662", "click_count"=>"265614", "share_count"=>"3020040", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}, :pinterest=>{"count"=>1, "url"=>"http://creativeallies.com"}, :plus_one=>{"shares"=>"8"}, :stumble_upon=>{"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/"}, :twitter=>{"count"=>121, "url"=>"http://creativeallies.com/"}}
51
+ expect(Virility.poll(@url)).to eq({
52
+ :facebook=>{"like_count"=>"977662", "click_count"=>"265614", "share_count"=>"3020040", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"},
53
+ :linkedin=>{ "count":17, "fCnt":"17", "fCntPlusOne":"18", "url":"http:\/\/creativeallies.com" },
54
+ :pinterest=>{"count"=>1, "url"=>"http://creativeallies.com"},
55
+ :plus_one=>{"shares"=>"8"},
56
+ :stumble_upon=>{"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/"},
57
+ :twitter=>{"count"=>121, "url"=>"http://creativeallies.com/"}
58
+ })
52
59
  end
53
-
60
+
54
61
  it "Virility.url should return a Virility::Excitation object" do
55
- Virility.url(@url).should be_a_kind_of Virility::Excitation
62
+ expect(Virility.url(@url)).to be_a_kind_of(Virility::Excitation)
56
63
  end
57
64
  end
58
65
 
59
66
  #
60
67
  # Error Proofing
61
68
  #
62
-
69
+
63
70
  describe "Error Proofing" do
64
71
  it "should not raise an error with a bad URL" do
65
- lambda { Virility.counts("http://this.is.a.crap.url") }.should_not raise_error
72
+ expect{ Virility.counts("http://this.is.a.crap.url") }.not_to raise_error
66
73
  end
67
-
74
+
68
75
  it "should return 0 for all strategy counts" do
69
76
  @virility = Virility.url("http://this.is.a.crap.url")
70
- @virility.total.should == 0
71
- @virility.counts.should == {:delicious=>0, :facebook=>0, :pinterest=>0, :plus_one=>0, :stumble_upon=>0, :twitter=>0}
77
+ expect(@virility.total).to eq(0)
78
+ expect(@virility.counts).to eq({:facebook=>0, :linkedin=>0, :pinterest=>0, :plus_one=>0, :stumble_upon=>0, :twitter=>0})
72
79
  end
73
80
  end
74
81
  end
@@ -18,8 +18,9 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
  # Development
21
- gem.add_development_dependency "rspec", "~> 2.6"
21
+ gem.add_development_dependency "rspec", "~> 3.4"
22
+ gem.add_development_dependency "pry", "~> 0.10"
22
23
  # Dependencies
23
24
  gem.add_dependency "httparty", "~> 0.13"
24
- gem.add_dependency "multi_json", "~> 1.0"
25
+ gem.add_dependency "multi_json", "~> 1.11"
25
26
  end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Sanders
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-01 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.6'
19
+ version: '3.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.6'
26
+ version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.10'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: httparty
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ~>
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0.13'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ~>
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0.13'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: multi_json
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ~>
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.0'
61
+ version: '1.11'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ~>
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.0'
68
+ version: '1.11'
55
69
  description: Virility leverages the API's of many popular social services to collect
56
70
  data about the virility of a particular URL.
57
71
  email:
@@ -60,10 +74,10 @@ executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
- - .gitignore
64
- - .rspec
65
- - .ruby-gemset
66
- - .ruby-version
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".ruby-gemset"
80
+ - ".ruby-version"
67
81
  - Gemfile
68
82
  - LICENSE.txt
69
83
  - README.md
@@ -71,7 +85,6 @@ files:
71
85
  - lib/virility.rb
72
86
  - lib/virility/exceptions.rb
73
87
  - lib/virility/excitation.rb
74
- - lib/virility/strategies/delicious.rb
75
88
  - lib/virility/strategies/facebook.rb
76
89
  - lib/virility/strategies/pinterest.rb
77
90
  - lib/virility/strategies/plus_one.rb
@@ -82,7 +95,6 @@ files:
82
95
  - lib/virility/version.rb
83
96
  - spec/excitation_spec.rb
84
97
  - spec/spec_helper.rb
85
- - spec/strategies/delicious_spec.rb
86
98
  - spec/strategies/facebook_spec.rb
87
99
  - spec/strategies/pinterest_spec.rb
88
100
  - spec/strategies/plus_one_spec.rb
@@ -100,17 +112,17 @@ require_paths:
100
112
  - lib
101
113
  required_ruby_version: !ruby/object:Gem::Requirement
102
114
  requirements:
103
- - - '>='
115
+ - - ">="
104
116
  - !ruby/object:Gem::Version
105
117
  version: '0'
106
118
  required_rubygems_version: !ruby/object:Gem::Requirement
107
119
  requirements:
108
- - - '>='
120
+ - - ">="
109
121
  - !ruby/object:Gem::Version
110
122
  version: '0'
111
123
  requirements: []
112
124
  rubyforge_project:
113
- rubygems_version: 2.2.2
125
+ rubygems_version: 2.4.8
114
126
  signing_key:
115
127
  specification_version: 4
116
128
  summary: Virility calls upon the API's of many popular social services such as Facebook,
@@ -121,7 +133,6 @@ summary: Virility calls upon the API's of many popular social services such as F
121
133
  test_files:
122
134
  - spec/excitation_spec.rb
123
135
  - spec/spec_helper.rb
124
- - spec/strategies/delicious_spec.rb
125
136
  - spec/strategies/facebook_spec.rb
126
137
  - spec/strategies/pinterest_spec.rb
127
138
  - spec/strategies/plus_one_spec.rb
@@ -1,19 +0,0 @@
1
- module Virility
2
- class Delicious < Strategy
3
-
4
- parser(
5
- Proc.new do |body, format|
6
- MultiJson.decode(body.scan(/(\{.+\})/).flatten.first)
7
- end
8
- )
9
-
10
- def census
11
- self.class.get("http://feeds.delicious.com/v2/json/urlinfo/data?url=#{@url}")
12
- end
13
-
14
- def count
15
- results["total_posts"] || 0
16
- end
17
-
18
- end
19
- end
@@ -1,66 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
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
15
-
16
- it_should_behave_like "no context results"
17
- end
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
25
-
26
- it_should_behave_like "no context results"
27
- end
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
35
-
36
- it_should_behave_like "no context results"
37
- end
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
45
-
46
- it_should_behave_like "no context results"
47
- end
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
55
-
56
- it "should not raise an error" do
57
- lambda { @virility.poll }.should_not raise_error
58
- end
59
-
60
- it "should return 50 for the count" do
61
- @virility.count.should == 50
62
- end
63
- end
64
- end
65
-
66
- end