PageRankr 4.4.1 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +3 -1
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +1 -2
  6. data/PageRankr.gemspec +3 -2
  7. data/README.md +2 -0
  8. data/lib/page_rankr/backlinks.rb +1 -2
  9. data/lib/page_rankr/backlinks/yahoo.rb +1 -1
  10. data/lib/page_rankr/indexes/yahoo.rb +1 -1
  11. data/lib/page_rankr/ranks/alexa_country.rb +4 -4
  12. data/lib/page_rankr/ranks/alexa_global.rb +4 -4
  13. data/lib/page_rankr/ranks/alexa_us.rb +2 -2
  14. data/lib/page_rankr/ranks/domain_authority.rb +4 -4
  15. data/lib/page_rankr/ranks/page_authority.rb +5 -5
  16. data/lib/page_rankr/site.rb +4 -4
  17. data/lib/page_rankr/version.rb +1 -1
  18. data/spec/backlinks/bing_spec.rb +21 -0
  19. data/spec/backlinks/google_spec.rb +20 -0
  20. data/spec/backlinks/yahoo_spec.rb +21 -0
  21. data/spec/fixtures/vcr_cassettes/PageRankr_Backlinks_Bing/_run/with_match/.yml +2346 -0
  22. data/spec/fixtures/vcr_cassettes/PageRankr_Backlinks_Bing/_run/with_no_match/.yml +1493 -0
  23. data/spec/fixtures/vcr_cassettes/PageRankr_Backlinks_Google/_run/with_match/.yml +1788 -0
  24. data/spec/fixtures/vcr_cassettes/PageRankr_Backlinks_Google/_run/with_no_match/.yml +57 -0
  25. data/spec/fixtures/vcr_cassettes/PageRankr_Backlinks_Yahoo/_run/with_match/.yml +1929 -0
  26. data/spec/fixtures/vcr_cassettes/PageRankr_Backlinks_Yahoo/_run/with_no_match/.yml +642 -0
  27. data/spec/fixtures/vcr_cassettes/PageRankr_Indexes_Bing/_run/with_match/.yml +1648 -0
  28. data/spec/fixtures/vcr_cassettes/PageRankr_Indexes_Bing/_run/with_no_match/.yml +1312 -0
  29. data/spec/fixtures/vcr_cassettes/PageRankr_Indexes_Google/_run/with_match/.yml +1769 -0
  30. data/spec/fixtures/vcr_cassettes/PageRankr_Indexes_Google/_run/with_no_match/.yml +57 -0
  31. data/spec/fixtures/vcr_cassettes/PageRankr_Indexes_Yahoo/_run/with_match/.yml +2062 -0
  32. data/spec/fixtures/vcr_cassettes/PageRankr_Indexes_Yahoo/_run/with_no_match/.yml +553 -0
  33. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_AlexaCountry/_run/with_match/.yml +45 -0
  34. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_AlexaCountry/_run/with_no_match/.yml +37 -0
  35. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_AlexaGlobal/_run/with_match/.yml +45 -0
  36. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_AlexaGlobal/_run/with_no_match/.yml +37 -0
  37. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_AlexaUs/_run/with_match/.yml +45 -0
  38. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_AlexaUs/_run/with_no_match/.yml +37 -0
  39. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_DomainAuthority/_run/with_match/.yml +54 -0
  40. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_DomainAuthority/_run/with_no_match/.yml +54 -0
  41. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_Google/_run/with_match/.yml +54 -0
  42. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_Google/_run/with_no_match/.yml +49 -0
  43. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_MozRank/_run/with_match/.yml +92 -0
  44. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_MozRank/_run/with_no_match/.yml +93 -0
  45. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_PageAuthority/_run/with_match/.yml +54 -0
  46. data/spec/fixtures/vcr_cassettes/PageRankr_Ranks_PageAuthority/_run/with_no_match/.yml +54 -0
  47. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Facebook/_run/with_match/.yml +54 -0
  48. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Facebook/_run/with_no_match/.yml +52 -0
  49. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Google/_run/with_match/.yml +42 -0
  50. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Google/_run/with_no_match/.yml +42 -0
  51. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_LinkedIn/_run/with_match/.yml +58 -0
  52. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_LinkedIn/_run/with_no_match/.yml +58 -0
  53. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Pinterest/_run/with_match/.yml +45 -0
  54. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Pinterest/_run/with_no_match/.yml +45 -0
  55. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_StumbleUpon/_run/with_match/.yml +42 -0
  56. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_StumbleUpon/_run/with_no_match/.yml +42 -0
  57. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Twitter/_run/with_match/.yml +57 -0
  58. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Twitter/_run/with_no_match/.yml +57 -0
  59. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Vk/_run/with_match/.yml +41 -0
  60. data/spec/fixtures/vcr_cassettes/PageRankr_Socials_Vk/_run/with_no_match/.yml +41 -0
  61. data/spec/fixtures/vcr_cassettes/alexa_ranks_edge_case_1.yml +91 -208
  62. data/spec/fixtures/vcr_cassettes/failure_socials.yml +233 -170
  63. data/spec/fixtures/vcr_cassettes/success_socials.yml +578 -160
  64. data/spec/indexes/bing_spec.rb +20 -0
  65. data/spec/indexes/google_spec.rb +20 -0
  66. data/spec/indexes/yahoo_spec.rb +20 -0
  67. data/spec/page_rankr_spec.rb +10 -169
  68. data/spec/proxy_services/random_spec.rb +2 -2
  69. data/spec/proxy_services/round_robin_spec.rb +4 -4
  70. data/spec/ranks/alexa_country_spec.rb +20 -0
  71. data/spec/ranks/alexa_global_spec.rb +20 -0
  72. data/spec/ranks/alexa_us_spec.rb +20 -0
  73. data/spec/ranks/domain_authority_spec.rb +21 -0
  74. data/spec/ranks/google/checksum_spec.rb +2 -2
  75. data/spec/ranks/google_spec.rb +20 -0
  76. data/spec/ranks/moz_rank_spec.rb +21 -0
  77. data/spec/ranks/page_authority_spec.rb +21 -0
  78. data/spec/site_spec.rb +3 -3
  79. data/spec/socials/facebook_spec.rb +20 -0
  80. data/spec/socials/google_spec.rb +20 -0
  81. data/spec/socials/linkedin_spec.rb +20 -0
  82. data/spec/socials/pinterest_spec.rb +20 -0
  83. data/spec/socials/stumble_upon_spec.rb +20 -0
  84. data/spec/socials/twitter_spec.rb +20 -0
  85. data/spec/socials/vk_spec.rb +20 -0
  86. data/spec/spec_helper.rb +7 -13
  87. data/spec/support/custom_matchers.rb +39 -0
  88. metadata +142 -23
  89. data/lib/page_rankr/backlinks/alexa.rb +0 -25
  90. data/spec/edge_cases_spec.rb +0 -26
  91. data/spec/fixtures/vcr_cassettes/failure_backlinks.yml +0 -1740
  92. data/spec/fixtures/vcr_cassettes/failure_indexes.yml +0 -1705
  93. data/spec/fixtures/vcr_cassettes/failure_ranks.yml +0 -422
  94. data/spec/fixtures/vcr_cassettes/success_backlinks.yml +0 -7651
  95. data/spec/fixtures/vcr_cassettes/success_indexes.yml +0 -7295
  96. data/spec/fixtures/vcr_cassettes/success_ranks.yml +0 -652
  97. data/spec/socials_spec.rb +0 -66
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Indexes::Bing do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ it{is_expected.to be_nil}
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Indexes::Google do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ it{is_expected.to be_nil}
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Indexes::Yahoo do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ it{is_expected.to be_nil}
18
+ end
19
+ end
20
+ end
@@ -1,192 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec::Matchers.define :be_in do |expected|
4
- match do |actual|
5
- expected === actual
6
- end
7
-
8
- failure_message_for_should do |actual|
9
- "expected that #{actual} would be in #{expected}"
10
- end
11
- end
12
-
13
- RSpec::Matchers.define :be_number do
14
- match do |actual|
15
- actual.is_a?(Numeric) && actual.send(@symbol, @expected)
16
- end
17
-
18
- chain :>= do |expected|
19
- @symbol = :>=
20
- @expected = expected
21
- end
22
-
23
- chain :> do |expected|
24
- @symbol = :>
25
- @expected = expected
26
- end
27
-
28
- chain :< do |expected|
29
- @symbol = :<
30
- @expected = expected
31
- end
32
-
33
- chain :<= do |expected|
34
- @symbol = :<=
35
- @expected = expected
36
- end
37
-
38
- failure_message_for_should do |actual|
39
- "expected that #{actual.inspect} would be a number and #{@symbol} than #{@expected}"
40
- end
41
- end
42
-
43
3
  describe PageRankr do
44
4
  describe "#rank_trackers" do
45
5
  subject{ PageRankr.rank_trackers }
46
6
 
47
- it{ should include(:alexa_us) }
48
- it{ should include(:alexa_global) }
49
- it{ should include(:google) }
50
- it{ should include(:moz_rank) }
51
- end
52
-
53
- describe "#ranks", :focus => true do
54
- describe "success" do
55
- subject do
56
- VCR.use_cassette(:success_ranks, :record => :new_episodes) do
57
- PageRankr.ranks("http://www.google.com")
58
- end
59
- end
60
-
61
- it{ should have_key(:alexa_us) }
62
- it{ should have_key(:alexa_global) }
63
- it{ should have_key(:alexa_country) }
64
- it{ should have_key(:google) }
65
- it{ should have_key(:moz_rank) }
66
- it{ should have_key(:page_authority) }
67
- it{ should have_key(:domain_authority) }
68
-
69
- it{ subject[:alexa_us].should be_number >= 1 }
70
- it{ subject[:alexa_global].should be_number >= 1 }
71
- it{ subject[:alexa_country].should be_number >= 1 }
72
- it{ subject[:google].should be_in(0..10) }
73
- it{ subject[:moz_rank].should be_in(5..9) }
74
- it{ subject[:page_authority].should be_in(90..99) }
75
- it{ subject[:domain_authority].should be_in(90..100) }
76
- end
77
-
78
- describe "failure" do
79
- subject do
80
- VCR.use_cassette(:failure_ranks, :record => :new_episodes) do
81
- PageRankr.ranks("http://please-dont-register-a-site-that-breaks-this-test.com")
82
- end
83
- end
84
-
85
- it{ should have_key(:alexa_us) }
86
- it{ should have_key(:alexa_global) }
87
- it{ should have_key(:alexa_country) }
88
- it{ should have_key(:google) }
89
- it{ should have_key(:moz_rank) }
90
- it{ should have_key(:page_authority) }
91
- it{ should have_key(:domain_authority) }
92
-
93
- it{ subject[:alexa_us].should be_nil }
94
- it{ subject[:alexa_global].should be_nil }
95
- it{ subject[:alexa_country].should be_nil }
96
- it{ subject[:google].should be_nil }
97
- it{ subject[:moz_rank].should == 0 }
98
- it{ subject[:page_authority].should == 1 }
99
- it{ subject[:domain_authority].should == 1 }
100
- end
7
+ it{ is_expected.to include(:alexa_us) }
8
+ it{ is_expected.to include(:alexa_global) }
9
+ it{ is_expected.to include(:google) }
10
+ it{ is_expected.to include(:moz_rank) }
101
11
  end
102
12
 
103
13
  describe "#backlink_trackers" do
104
14
  subject{ PageRankr.backlink_trackers }
105
15
 
106
- it{ should include(:alexa) }
107
- it{ should include(:bing) }
108
- it{ should include(:google) }
109
- it{ should include(:yahoo) }
110
- end
111
-
112
- describe "#backlinks" do
113
- describe "success" do
114
- subject do
115
- VCR.use_cassette(:success_backlinks, :record => :new_episodes) do
116
- PageRankr.backlinks("http://www.google.com")
117
- end
118
- end
119
-
120
- PageRankr.backlink_trackers.each do |tracker|
121
- it{ should have_key(tracker) }
122
-
123
- it "#{tracker} should have a value greater than zero" do
124
- subject[tracker].should be_number > 0
125
- end
126
- end
127
- end
128
-
129
- describe "failure" do
130
- subject do
131
- VCR.use_cassette(:failure_backlinks, :record => :new_episodes) do
132
- PageRankr.backlinks("http://please-dont-register-a-site-that-breaks-this-test.com")
133
- end
134
- end
135
-
136
- PageRankr.backlink_trackers.each do |tracker|
137
- it{ should have_key(tracker) }
138
-
139
- it "#{tracker} should have a nil value" do
140
- subject[tracker].should be_nil
141
- end
142
- end
143
- end
16
+ it{ is_expected.to include(:bing) }
17
+ it{ is_expected.to include(:google) }
18
+ it{ is_expected.to include(:yahoo) }
144
19
  end
145
20
 
146
21
  describe "#index_trackers" do
147
22
  subject{ PageRankr.index_trackers }
148
23
 
149
- it{ should include(:google) }
150
- it{ should include(:bing) }
151
- end
152
-
153
- describe "#indexes" do
154
- describe "success" do
155
- subject do
156
- VCR.use_cassette(:success_indexes, :record => :new_episodes) do
157
- PageRankr.indexes("http://www.google.com")
158
- end
159
- end
160
-
161
- PageRankr.index_trackers.each do |tracker|
162
- it{ should have_key(tracker) }
163
-
164
- it "#{tracker} should have a value greater than zero" do
165
- subject[tracker].should be_number > 0
166
- end
167
- end
168
- end
169
-
170
- describe "failure" do
171
- subject do
172
- VCR.use_cassette(:failure_indexes, :record => :new_episodes) do
173
- PageRankr.indexes("http://please-dont-register-a-site-that-breaks-this-test.com")
174
- end
175
- end
176
-
177
- PageRankr.index_trackers.each do |tracker|
178
- it{ should have_key(tracker) }
179
-
180
- it "#{tracker} should have a nil value" do
181
- subject[tracker].should be_nil
182
- end
183
- end
184
- end
24
+ it{ is_expected.to include(:google) }
25
+ it{ is_expected.to include(:bing) }
185
26
  end
186
27
 
187
28
  describe "::Site" do
188
29
  [nil, '', 'batman.thedarkknight'].each do |value|
189
- it "should raise an exception when given #{value.inspect}" do
30
+ it "raises an exception when given #{value.inspect}" do
190
31
  expect{PageRankr::Site(value)}.to raise_error(PageRankr::DomainInvalid)
191
32
  end
192
33
  end
@@ -15,7 +15,7 @@ describe PageRankr::ProxyServices::Random do
15
15
 
16
16
  it "should return a proxy from the list of proxies" do
17
17
  10.times do
18
- proxies.should include(subject.proxy(name, site))
18
+ expect(proxies).to include(subject.proxy(name, site))
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -14,17 +14,17 @@ describe PageRankr::ProxyServices::RoundRobin do
14
14
  it{should respond_to(:proxy).with(2).arguments}
15
15
 
16
16
  it "should return the first proxy on the first call" do
17
- subject.proxy(name, site).should == proxies.first
17
+ expect(subject.proxy(name, site)).to eq(proxies.first)
18
18
  end
19
19
 
20
20
  it "should return the second proxy on the second call" do
21
21
  subject.proxy(name, site)
22
- subject.proxy(name, site).should == proxies.last
22
+ expect(subject.proxy(name, site)).to eq(proxies.last)
23
23
  end
24
24
 
25
25
  it "should return the first proxy on the third call" do
26
26
  subject.proxy(name, site)
27
27
  subject.proxy(name, site)
28
- subject.proxy(name, site).should == proxies.first
28
+ expect(subject.proxy(name, site)).to eq(proxies.first)
29
29
  end
30
- end
30
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Ranks::AlexaCountry do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ it{is_expected.to be_nil}
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Ranks::AlexaGlobal do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ it{is_expected.to be_nil}
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Ranks::AlexaUs do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ it{is_expected.to be_nil}
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Ranks::DomainAuthority do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ # always returns a result
18
+ it{is_expected.to eq(1)}
19
+ end
20
+ end
21
+ end
@@ -60,8 +60,8 @@ describe PageRankr::Ranks::Google::Checksum do
60
60
  describe "#generate" do
61
61
  SAMPLES.each do |input, output|
62
62
  it "should generate #{output} as a checksum for #{input}" do
63
- PageRankr::Ranks::Google::Checksum.generate(input).should == output
63
+ expect(PageRankr::Ranks::Google::Checksum.generate(input)).to eq(output)
64
64
  end
65
65
  end
66
66
  end
67
- end
67
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Ranks::Google do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ it{is_expected.to be_nil}
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Ranks::MozRank do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ # always returns a result
18
+ it{is_expected.to eq(0)}
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageRankr::Ranks::PageAuthority do
4
+ describe '#run' do
5
+ let(:tracker){described_class.new(site)}
6
+ subject(:result){tracker.run}
7
+
8
+ context 'with match', :vcr do
9
+ let(:site){'http://www.google.com'}
10
+
11
+ it{is_expected.to be_number > 0}
12
+ end
13
+
14
+ context 'with no match', :vcr do
15
+ let(:site){'http://please-dont-register-a-site-that-breaks-this-test.com'}
16
+
17
+ # always returns result
18
+ it{is_expected.to eq(1)}
19
+ end
20
+ end
21
+ end