sistrix 1.0.0
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.
- data/.document +5 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/sistrix.rb +28 -0
- data/lib/sistrix/base.rb +23 -0
- data/lib/sistrix/config.rb +15 -0
- data/lib/sistrix/domain.rb +60 -0
- data/lib/sistrix/domain/age.rb +32 -0
- data/lib/sistrix/domain/competitors/sem.rb +50 -0
- data/lib/sistrix/domain/competitors/seo.rb +52 -0
- data/lib/sistrix/domain/competitors/us.rb +53 -0
- data/lib/sistrix/domain/kwcount/sem.rb +54 -0
- data/lib/sistrix/domain/kwcount/seo.rb +54 -0
- data/lib/sistrix/domain/overview.rb +71 -0
- data/lib/sistrix/domain/pagerank.rb +51 -0
- data/lib/sistrix/domain/pages.rb +51 -0
- data/lib/sistrix/domain/sichtbarkeitsindex.rb +49 -0
- data/lib/sistrix/domain/social/latest.rb +52 -0
- data/lib/sistrix/domain/social/overview.rb +36 -0
- data/lib/sistrix/domain/social/top.rb +52 -0
- data/lib/sistrix/domain/social/url.rb +63 -0
- data/lib/sistrix/keyword.rb +60 -0
- data/lib/sistrix/keyword/domain/sem.rb +59 -0
- data/lib/sistrix/keyword/domain/seo.rb +65 -0
- data/lib/sistrix/keyword/domain/us.rb +61 -0
- data/lib/sistrix/keyword/sem.rb +58 -0
- data/lib/sistrix/keyword/seo.rb +57 -0
- data/lib/sistrix/keyword/us.rb +56 -0
- data/lib/sistrix/links/linktargets.rb +57 -0
- data/lib/sistrix/links/linktexts.rb +61 -0
- data/lib/sistrix/links/list.rb +53 -0
- data/lib/sistrix/links/overview.rb +36 -0
- data/lib/sistrix/monitoring/folders.rb +53 -0
- data/lib/sistrix/monitoring/projects.rb +51 -0
- data/lib/sistrix/monitoring/report.rb +74 -0
- data/lib/sistrix/monitoring/report/download.rb +60 -0
- data/lib/sistrix/monitoring/reports.rb +52 -0
- data/lib/sistrix/record.rb +13 -0
- data/sistrix.gemspec +146 -0
- data/spec/sistrix_domain_spec.rb +685 -0
- data/spec/sistrix_keyword_spec.rb +216 -0
- data/spec/sistrix_links_spec.rb +221 -0
- data/spec/sistrix_monitoring_spec.rb +190 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/xml/domain.age.xml +19 -0
- data/spec/xml/domain.competitors.sem.xml +23 -0
- data/spec/xml/domain.competitors.seo.xml +23 -0
- data/spec/xml/domain.competitors.us.xml +23 -0
- data/spec/xml/domain.kwcount.sem.xml +19 -0
- data/spec/xml/domain.kwcount.seo.xml +19 -0
- data/spec/xml/domain.overview.xml +24 -0
- data/spec/xml/domain.pagerank.xml +19 -0
- data/spec/xml/domain.pages.xml +19 -0
- data/spec/xml/domain.sichtbarkeitsindex.xml +19 -0
- data/spec/xml/domain.social.latest.xml +28 -0
- data/spec/xml/domain.social.overview.xml +21 -0
- data/spec/xml/domain.social.top.xml +28 -0
- data/spec/xml/domain.social.url.xml +19 -0
- data/spec/xml/domain.social.url_with_history.xml +23 -0
- data/spec/xml/domain.xml +29 -0
- data/spec/xml/keyword.domain.sem.xml +24 -0
- data/spec/xml/keyword.domain.seo.xml +24 -0
- data/spec/xml/keyword.domain.us.xml +24 -0
- data/spec/xml/keyword.sem.xml +22 -0
- data/spec/xml/keyword.sem_with_domain.xml +212 -0
- data/spec/xml/keyword.sem_with_domain2.xml +20 -0
- data/spec/xml/keyword.seo.xml +29 -0
- data/spec/xml/keyword.seo_with_url.xml +20 -0
- data/spec/xml/keyword.us.xml +28 -0
- data/spec/xml/keyword.us_nodate.xml +19 -0
- data/spec/xml/keyword.xml +21 -0
- data/spec/xml/links.linktargets.xml +118 -0
- data/spec/xml/links.linktexts.xml +28 -0
- data/spec/xml/links.list.xml +10018 -0
- data/spec/xml/links.overview.xml +23 -0
- data/spec/xml/monitoring.folders.xml +20 -0
- data/spec/xml/monitoring.projects.xml +37 -0
- data/spec/xml/monitoring.report.download.pdf +0 -0
- data/spec/xml/monitoring.report.download_error.xml +18 -0
- data/spec/xml/monitoring.report.xml +181 -0
- data/spec/xml/monitoring.reports.xml +19 -0
- data/test/helper.rb +18 -0
- data/test/test_sistrix.rb +7 -0
- metadata +232 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'sistrix'
|
|
5
|
+
require 'pp'
|
|
6
|
+
|
|
7
|
+
WebMock.disable_net_connect!
|
|
8
|
+
include WebMock::API
|
|
9
|
+
|
|
10
|
+
xml_base = File.join(File.dirname(__FILE__), 'xml')
|
|
11
|
+
domain = 'zeit.de'
|
|
12
|
+
keyword = 'auto'
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
describe "Sistrix.keyword(:kw => '[keyword]') returns a list of available API methods for the given keyword" do
|
|
16
|
+
subject {
|
|
17
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/keyword?api_key=&kw=#{keyword}").to_return(File.new(File.join(xml_base, 'keyword.xml')))
|
|
18
|
+
Sistrix.keyword(:kw => keyword)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
its(:credits) { should == 0 }
|
|
22
|
+
its("options.size") { should == 3}
|
|
23
|
+
|
|
24
|
+
describe "options[0]" do
|
|
25
|
+
let(:option) { subject.options[0] }
|
|
26
|
+
|
|
27
|
+
it "should be" do
|
|
28
|
+
option.should be
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "method should be 'keyword.seo'" do
|
|
32
|
+
option.method.should == 'keyword.seo'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "url should be 'http://api.sistrix.net/keyword.seo?api_key=&kw=auto'" do
|
|
36
|
+
option.url.should == 'http://api.sistrix.net/keyword.seo?api_key=&kw=auto'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "name should be 'Organisches Ranking'" do
|
|
40
|
+
option.name.should == 'Organisches Ranking'
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "options[1]" do
|
|
45
|
+
let(:option) { subject.options[1] }
|
|
46
|
+
|
|
47
|
+
it "should be" do
|
|
48
|
+
option.should be
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "method should be 'keyword.sem'" do
|
|
52
|
+
option.method.should == 'keyword.sem'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "url should be 'http://api.sistrix.net/keyword.sem?api_key=&kw=auto'" do
|
|
56
|
+
option.url.should == 'http://api.sistrix.net/keyword.sem?api_key=&kw=auto'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "name should be 'Bezahlte Werbung'" do
|
|
60
|
+
option.name.should == 'Bezahlte Werbung'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "options[2]" do
|
|
65
|
+
let(:option) { subject.options[2] }
|
|
66
|
+
|
|
67
|
+
it "should be" do
|
|
68
|
+
option.should be
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "method should be 'keyword.us'" do
|
|
72
|
+
option.method.should == 'keyword.us'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "url should be 'http://api.sistrix.net/keyword.us?api_key=&kw=auto'" do
|
|
76
|
+
option.url.should == 'http://api.sistrix.net/keyword.us?api_key=&kw=auto'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "name should be 'Universal Search-Integrationen'" do
|
|
80
|
+
option.name.should == 'Universal Search-Integrationen'
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "Sistrix.keyword_seo(:kw => '[keyword]', :num => [number_of_results], :date => [date]) returns a SEO rank list of domains and URLs for the given keyword and date" do
|
|
86
|
+
subject {
|
|
87
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/keyword.seo?api_key=&date=last%20week&kw=#{keyword}&num=10&url=").to_return(File.new(File.join(xml_base, 'keyword.seo.xml')))
|
|
88
|
+
Sistrix.keyword_seo(:kw => keyword, :num => 10, :date => 'last week')
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
its(:credits) { should == 10 }
|
|
92
|
+
its(:date) { should == Time.parse('2012-04-02T00:00:00+02:00') }
|
|
93
|
+
its("results.size") { should == 10 }
|
|
94
|
+
|
|
95
|
+
describe "results[0]" do
|
|
96
|
+
let(:result) { subject.results[0] }
|
|
97
|
+
|
|
98
|
+
it "should be" do
|
|
99
|
+
result.should be
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "position should be 1" do
|
|
103
|
+
result.position.should == 1
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "domain should be 'auto.de'" do
|
|
107
|
+
result.domain.should == 'auto.de'
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "url should be 'http://www.auto.de/'" do
|
|
111
|
+
result.url.should == 'http://www.auto.de/'
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe "results[9]" do
|
|
116
|
+
let(:result) { subject.results[9] }
|
|
117
|
+
|
|
118
|
+
it "should be" do
|
|
119
|
+
result.should be
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "position should be 10" do
|
|
123
|
+
result.position.should == 10
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "domain should be 'bmw.de'" do
|
|
127
|
+
result.domain.should == 'bmw.de'
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "url should be 'http://www.bmw.de/'" do
|
|
131
|
+
result.url.should == 'http://www.bmw.de/'
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe "Sistrix.keyword_seo(:kw => '[keyword]', :num => [number_of_results], :date => [date], :url => [url]) returns the current SEO position for the given keyword, date and url" do
|
|
137
|
+
subject {
|
|
138
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/keyword.seo?api_key=&date=last%20week&kw=#{keyword}&num=10&url=http://www.autobild.de/").to_return(File.new(File.join(xml_base, 'keyword.seo_with_url.xml')))
|
|
139
|
+
Sistrix.keyword_seo(:kw => keyword, :num => 10, :date => 'last week', :url => 'http://www.autobild.de/')
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
its(:credits) { should == 1 }
|
|
143
|
+
its(:date) { should == Time.parse('2012-04-02T00:00:00+02:00') }
|
|
144
|
+
its("results.size") { should == 1 }
|
|
145
|
+
|
|
146
|
+
its("results.first") { should be }
|
|
147
|
+
its("results.first.position") { should == 4 }
|
|
148
|
+
its("results.first.domain") { should == 'autobild.de' }
|
|
149
|
+
its("results.first.url") { should == 'http://www.autobild.de/' }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
describe "Sistrix.keyword_sem(:kw => '[keyword]', :num => [number_of_results], :date => [date]) returns a list of SEM bookings for the given keyword and date" do
|
|
153
|
+
subject {
|
|
154
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/keyword.sem?api_key=&date=now&domain=&kw=#{keyword}&num=3").to_return(File.new(File.join(xml_base, 'keyword.sem.xml')))
|
|
155
|
+
Sistrix.keyword_sem(:kw => keyword, :num => 3, :date => 'now')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
its(:credits) { should == 3 }
|
|
159
|
+
its(:date) { should == Time.parse('2012-04-09T00:00:00+02:00') }
|
|
160
|
+
its("results.size") { should == 3 }
|
|
161
|
+
|
|
162
|
+
its("results.first.position") { should == 1 }
|
|
163
|
+
its("results.first.title") { should == 'mobile.de - Deutschlands größter Fahrzeugmarkt.' }
|
|
164
|
+
its("results.first.text") { should == 'Welcher ist dein Nächster? Geprüfte Gebrauchtwagen - Günstige Jahreswagen - Neuwagen - Limousine' }
|
|
165
|
+
its("results.first.displayurl") { should == 'www.mobile.de/' }
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
describe "Sistrix.keyword_us(:kw => '[keyword]', :date => [date]) returns a list of Universal Search integration for the given keyword and date" do
|
|
169
|
+
subject {
|
|
170
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/keyword.us?api_key=&date=now&kw=angela+merkel").to_return(File.new(File.join(xml_base, 'keyword.us.xml')))
|
|
171
|
+
Sistrix.keyword_us(:kw => 'angela merkel', :date => 'now')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
its(:credits) { should == 9 }
|
|
175
|
+
its(:date) { should == Time.parse('2012-04-09T00:00:00+02:00') }
|
|
176
|
+
its("results.size") { should == 9 }
|
|
177
|
+
its("results.first.type") { should == 'x' }
|
|
178
|
+
its("results.first.position") { should == 6 }
|
|
179
|
+
its("results.first.position_intern") { should == 'x' }
|
|
180
|
+
its("results.first.url") { should == 'hxxxx//xxxxxxxxxx.xxxxx.xxxxxxxxx.xxx/xxxx/xx/xxxxxx-xxxxxxx.xxx' }
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
describe "Sistrix.keyword_domain_seo(:kw => '[keyword]', :date => [date], :domain => [domain], :num => [number_of_results]) returns a list of keyword rankings for the given domain and date" do
|
|
184
|
+
subject {
|
|
185
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/keyword.domain.seo?api_key=&date=now&domain=mobile.de&from_pos=&host=&num=5&path=&search=&to_pos=&url=").to_return(File.new(File.join(xml_base, 'keyword.domain.seo.xml')))
|
|
186
|
+
Sistrix.keyword_domain_seo(:date => 'now', :domain => 'mobile.de', :num => 5)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
its(:credits) { should == 5 }
|
|
190
|
+
its(:date) { should == Time.parse('2012-04-09T00:00:00+02:00') }
|
|
191
|
+
its("results.size") { should == 5 }
|
|
192
|
+
its("results.first.kw") { should == 'mobile' }
|
|
193
|
+
its("results.first.position") { should == 1 }
|
|
194
|
+
its("results.first.competition") { should == 67 }
|
|
195
|
+
its("results.first.traffic") { should == 70 }
|
|
196
|
+
its("results.first.url") { should == 'http://suchen.mobile.de/fahrzeuge/auto/' }
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
describe "Sistrix.keyword_domain_sem(:date => [date], :domain => [domain], :num => [number_of_results]) returns a list of keywords with SEM bookings for the given domain and date" do
|
|
200
|
+
subject {
|
|
201
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/keyword.domain.us?api_key=&date=now&domain=mobile.de&num=5&search=").to_return(File.new(File.join(xml_base, 'keyword.domain.us.xml')))
|
|
202
|
+
Sistrix.keyword_domain_us(:date => 'now', :domain => 'mobile.de', :num => 5)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
its(:credits) { should == 5 }
|
|
206
|
+
its(:date) { should == Time.parse('2012-01-16T00:00:00+01:00') }
|
|
207
|
+
its("results.size") { should == 5 }
|
|
208
|
+
|
|
209
|
+
its("results.first.kw") { should == 'hxxxxxxx xxxxxxxx' }
|
|
210
|
+
its("results.first.type") { should == 'x' }
|
|
211
|
+
its("results.first.position") { should == 'x' }
|
|
212
|
+
its("results.first.position_intern") { should == 'x' }
|
|
213
|
+
its("results.first.competition") { should == 'xx' }
|
|
214
|
+
its("results.first.traffic") { should == 'xx' }
|
|
215
|
+
end
|
|
216
|
+
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'sistrix'
|
|
5
|
+
require 'pp'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
WebMock.disable_net_connect!
|
|
10
|
+
include WebMock::API
|
|
11
|
+
|
|
12
|
+
xml_base = File.join(File.dirname(__FILE__), 'xml')
|
|
13
|
+
domain = 'zeit.de'
|
|
14
|
+
keyword = 'auto'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
describe "Sistrix.links_overview(:domain => [domain]) returns an overview of the link statistics for the given domain" do
|
|
19
|
+
subject {
|
|
20
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/links.overview?api_key=&domain=#{domain}").to_return(File.new(File.join(xml_base, 'links.overview.xml')))
|
|
21
|
+
Sistrix.links_overview(:domain => domain)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
it { should be }
|
|
25
|
+
|
|
26
|
+
its(:credits) { should be 25 }
|
|
27
|
+
its(:total) { should be 2357268 }
|
|
28
|
+
its(:hosts) { should be 84489 }
|
|
29
|
+
its(:domains) { should be 51929 }
|
|
30
|
+
its(:networks) { should be 28613 }
|
|
31
|
+
its(:class_c) { should be 11878 }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
describe "Sistrix.links_list(:domain => [domain]) returns the complete list of backlinks for the given domain" do
|
|
37
|
+
subject {
|
|
38
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/links.list?api_key=&domain=#{domain}").to_return(File.new(File.join(xml_base, 'links.list.xml')))
|
|
39
|
+
Sistrix.links_list(:domain => domain)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
it { should be }
|
|
43
|
+
|
|
44
|
+
its(:credits) { should be 250 }
|
|
45
|
+
|
|
46
|
+
its(:links) { should be }
|
|
47
|
+
it { should have(10000).links }
|
|
48
|
+
|
|
49
|
+
describe "links[0]" do
|
|
50
|
+
let(:link) { subject.links[0] }
|
|
51
|
+
|
|
52
|
+
it "url_from should be 'http://zeit-spiel.de/shop.html'" do
|
|
53
|
+
link.url_from { should be 'http://zeit-spiel.de/shop.html' }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "text should be 'About Time im DIE ZEIT Online Shop'" do
|
|
57
|
+
link.text { should be 'About Time im DIE ZEIT Online Shop' }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "url_to should be 'https://shop.zeit.de/category/745-DIE-ZEIT-Spiel-ABOUT-TIME'" do
|
|
61
|
+
link.url_to { should be 'https://shop.zeit.de/category/745-DIE-ZEIT-Spiel-ABOUT-TIME' }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe "links[9999]" do
|
|
66
|
+
let(:link) { subject.links[9999] }
|
|
67
|
+
|
|
68
|
+
it "url_from should be 'http://mooszka.blogspot.com/2008/09/johnny-clarke-yard-style.html'" do
|
|
69
|
+
link.url_from { should be 'http://mooszka.blogspot.com/2008/09/johnny-clarke-yard-style.html' }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "text should be 'Zuender (D)'" do
|
|
73
|
+
link.text { should be 'Zuender (D)' }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "url_to should be 'http://zuender.zeit.de/'" do
|
|
77
|
+
link.url_to { should be 'http://zuender.zeit.de/' }
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
describe "Sistrix.links_linktargets(:domain => [domain], :num => [number_of_results]) returns a list of pages with backlink statistics within the given domain" do
|
|
85
|
+
subject {
|
|
86
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/links.linktargets?api_key=&domain=#{domain}&num=").to_return(File.new(File.join(xml_base, 'links.linktargets.xml')))
|
|
87
|
+
Sistrix.links_linktargets(:domain => domain)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
it { should be }
|
|
91
|
+
its(:credits) { should be 100 }
|
|
92
|
+
its(:targets) { should be }
|
|
93
|
+
it { should have(100).targets }
|
|
94
|
+
|
|
95
|
+
describe "targets[0]" do
|
|
96
|
+
let(:target) { subject.targets[0] }
|
|
97
|
+
|
|
98
|
+
it "url should be 'http://zeit.de/'" do
|
|
99
|
+
target.url { should be 'http://zeit.de/' }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "links should be 4148" do
|
|
103
|
+
target.links { should be 4148 }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "hosts should be 321" do
|
|
107
|
+
target.hosts { should be 321 }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "domains should be 230" do
|
|
111
|
+
target.domains { should be 230 }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "nets should be 185" do
|
|
115
|
+
target.nets { should be 185 }
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "ips should be 204" do
|
|
119
|
+
target.ips { should be 204 }
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
describe "targets[99]" do
|
|
124
|
+
let(:target) { subject.targets[99] }
|
|
125
|
+
|
|
126
|
+
it "url should be 'http://www.zeit.de/wissen/2011-08/depressionen-pille'" do
|
|
127
|
+
target.url { should be 'http://www.zeit.de/wissen/2011-08/depressionen-pille' }
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "links should be 101" do
|
|
131
|
+
target.links { should be 101 }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "hosts should be 33" do
|
|
135
|
+
target.hosts { should be 33 }
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it "domains should be 29" do
|
|
139
|
+
target.domains { should be 29 }
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "nets should be 24" do
|
|
143
|
+
target.nets { should be 24 }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it "ips should be 29" do
|
|
147
|
+
target.ips { should be 29 }
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
describe "Sistrix.links_linktexts(:domain => [domain], :num => [number_of_results]) returns a list of backlink texts to the given domain" do
|
|
155
|
+
subject {
|
|
156
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/links.linktexts?api_key=&domain=#{domain}&num=10").to_return(File.new(File.join(xml_base, 'links.linktexts.xml')))
|
|
157
|
+
Sistrix.links_linktexts(:domain => domain, :num => 10)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
it { should be }
|
|
161
|
+
its(:credits) { should be 10 }
|
|
162
|
+
its(:linktexts) { should be }
|
|
163
|
+
it { should have(10).linktexts }
|
|
164
|
+
|
|
165
|
+
describe "linktexts[0]" do
|
|
166
|
+
let(:linktext) { subject.linktexts[0] }
|
|
167
|
+
|
|
168
|
+
it "text should be ''" do
|
|
169
|
+
linktext.text { should be '' }
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
it "links should be 2992" do
|
|
173
|
+
linktext.links { should be 2992 }
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "hosts should be 836" do
|
|
177
|
+
linktext.hosts { should be 836 }
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "domains should be 576" do
|
|
181
|
+
linktext.domains { should be 576 }
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it "nets should be 327" do
|
|
185
|
+
linktext.nets { should be 327 }
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "ips should be 406" do
|
|
189
|
+
linktext.ips { should be 406 }
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe "linktexts[9]" do
|
|
194
|
+
let(:linktext) { subject.linktexts[9] }
|
|
195
|
+
|
|
196
|
+
it "text should be 'N/A'" do
|
|
197
|
+
linktext.text { should be 'N/A' }
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
it "links should be 172" do
|
|
201
|
+
linktext.links { should be 172 }
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it "hosts should be 140" do
|
|
205
|
+
linktext.hosts { should be 140 }
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it "domains should be 117" do
|
|
209
|
+
linktext.domains { should be 117 }
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it "nets should be 68" do
|
|
213
|
+
linktext.nets { should be 68 }
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it "ips should be 77" do
|
|
217
|
+
linktext.ips { should be 77 }
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
end
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'sistrix'
|
|
5
|
+
require 'digest/md5'
|
|
6
|
+
require 'pp'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
WebMock.disable_net_connect!
|
|
11
|
+
include WebMock::API
|
|
12
|
+
|
|
13
|
+
xml_base = File.join(File.dirname(__FILE__), 'xml')
|
|
14
|
+
domain = 'zeit.de'
|
|
15
|
+
keyword = 'auto'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
describe "Sistrix.monitoring_projects() returns the complete list of projects for your API key" do
|
|
21
|
+
subject {
|
|
22
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/monitoring.projects?api_key=").to_return(File.new(File.join(xml_base, 'monitoring.projects.xml')))
|
|
23
|
+
Sistrix.monitoring_projects()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
it { should be }
|
|
27
|
+
|
|
28
|
+
its(:credits) { should be 0 }
|
|
29
|
+
|
|
30
|
+
its(:projects) { should be }
|
|
31
|
+
it { should have(19).projects }
|
|
32
|
+
|
|
33
|
+
describe "projects[0]" do
|
|
34
|
+
let(:project) { subject.projects[0] }
|
|
35
|
+
|
|
36
|
+
it "name should be 'aaaaaaaaaaa.aa'" do
|
|
37
|
+
project.name { should be 'aaaaaaaaaaa.aa' }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "id should be 'aaaaaaaa'" do
|
|
41
|
+
project.id { should be 'aaaaaaaa' }
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "projects.last" do
|
|
46
|
+
let(:project) { subject.projects.last }
|
|
47
|
+
|
|
48
|
+
it "name should be 'sssssssssssss'" do
|
|
49
|
+
project.name { should be 'sssssssssssss' }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "id should be 'ssssssss'" do
|
|
53
|
+
project.id { should be 'ssssssss' }
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "Sistrix.monitoring_folders(:project => [project]) returns the list of folders for one project" do
|
|
60
|
+
subject {
|
|
61
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/monitoring.folders?api_key=&project=56366").to_return(File.new(File.join(xml_base, 'monitoring.folders.xml')))
|
|
62
|
+
Sistrix.monitoring_folders(:project => '56366')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
it { should be }
|
|
66
|
+
|
|
67
|
+
its(:credits) { should be 0 }
|
|
68
|
+
|
|
69
|
+
its(:folders) { should be }
|
|
70
|
+
it { should have(2).folders }
|
|
71
|
+
|
|
72
|
+
describe "folders[0]" do
|
|
73
|
+
let(:folder) { subject.folders[0] }
|
|
74
|
+
|
|
75
|
+
it "name should be 'aaaaa a aaaa'" do
|
|
76
|
+
folder.name { should be 'aaaaa a aaaa' }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "id should be 1111" do
|
|
80
|
+
folder.id { should be 5360 }
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "parent should be 0" do
|
|
84
|
+
folder.parent { should be 0 }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "Sistrix.monitoring_reports(:project => [project]) returns the list of available reports for one project" do
|
|
91
|
+
subject {
|
|
92
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/monitoring.reports?api_key=&project=56366").to_return(File.new(File.join(xml_base, 'monitoring.reports.xml')))
|
|
93
|
+
Sistrix.monitoring_reports(:project => '56366')
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
it { should be }
|
|
97
|
+
|
|
98
|
+
its(:credits) { should be 0 }
|
|
99
|
+
|
|
100
|
+
its(:reports) { should be }
|
|
101
|
+
it { should have(1).reports }
|
|
102
|
+
|
|
103
|
+
describe "reports[0]" do
|
|
104
|
+
let(:report) { subject.reports[0] }
|
|
105
|
+
|
|
106
|
+
it "name should be 'Oktober'" do
|
|
107
|
+
report.name { should be 'Oktober' }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "id should be aaaaaaaaaaaaaaaa" do
|
|
111
|
+
report.id { should be 'aaaaaaaaaaaaaaaa' }
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
describe "Sistrix.monitoring_report(:project => [project], :report => [report]) returns the list of available report instances for the given project and report" do
|
|
118
|
+
subject {
|
|
119
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/monitoring.report?api_key=&project=56366&report=12356").to_return(File.new(File.join(xml_base, 'monitoring.report.xml')))
|
|
120
|
+
Sistrix.monitoring_report(:project => '56366', :report => 12356)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
it { should be }
|
|
124
|
+
|
|
125
|
+
its(:credits) { should be 0 }
|
|
126
|
+
|
|
127
|
+
its(:frequency) { should == 'weekly' }
|
|
128
|
+
its(:name) { should == 'Oktober'}
|
|
129
|
+
its(:id) { should == 'aaaaaaaaaaaaaaaa' }
|
|
130
|
+
its(:format) { should == 'pdf' }
|
|
131
|
+
|
|
132
|
+
its(:recipients) { should be }
|
|
133
|
+
it { should have(1).recipients }
|
|
134
|
+
|
|
135
|
+
describe "recipients[0]" do
|
|
136
|
+
let(:recipient) { subject.recipients[0] }
|
|
137
|
+
|
|
138
|
+
it "value should be 'aa'" do
|
|
139
|
+
recipient.value { should be 'aa' }
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "type should be 'user'" do
|
|
143
|
+
recipient.type { should be 'user' }
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it { should have(154).reports }
|
|
148
|
+
describe "reports[0]" do
|
|
149
|
+
let(:report) { subject.reports[0] }
|
|
150
|
+
|
|
151
|
+
it "date should be '2009-11-04T00:00:00+01:00'" do
|
|
152
|
+
report.date { should be Time.parse('2009-11-04T00:00:00+01:00') }
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "format should be 'pdf'" do
|
|
156
|
+
report.format { should be 'pdf' }
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
describe "Sistrix.monitoring_report_download(:project => [project], :report => [report], :date => [date]) downloads a PDF or XLS version of the specified report" do
|
|
165
|
+
subject {
|
|
166
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/monitoring.report.download?api_key=&project=56366&report=12356&date=2009-11-04").to_return(File.new(File.join(xml_base, 'monitoring.report.download.pdf')))
|
|
167
|
+
Sistrix.monitoring_report_download(:project => '56366', :report => '12356', :date => '2009-11-04')
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
it { should be }
|
|
171
|
+
|
|
172
|
+
its("data.length") { should be 85487 }
|
|
173
|
+
|
|
174
|
+
its(:data) { should satisfy { |data| Digest::MD5.hexdigest(data) == 'cf916dbe79c66e19b4e662ce376e8ae1' } }
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
describe "Sistrix.monitoring_report_download(:project => [project], :report => [report], :date => [erroneous_date]) returns an error when downloading a PDF or XLS version of the specified report" do
|
|
179
|
+
subject {
|
|
180
|
+
stub_request(:get, Sistrix::SERVICE_HOST + "/monitoring.report.download?api_key=&project=56366&report=12356&date=2009-11-04653").to_return(File.new(File.join(xml_base, 'monitoring.report.download_error.xml')))
|
|
181
|
+
Sistrix.monitoring_report_download(:project => '56366', :report => '12356', :date => '2009-11-04653')
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
it { should be }
|
|
185
|
+
|
|
186
|
+
its("error?") { should be_true }
|
|
187
|
+
its("error.code") { should == '005' }
|
|
188
|
+
its("error.message") { should == 'Date not found' }
|
|
189
|
+
|
|
190
|
+
end
|