Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add report 'phrase_organic' + 'display_sort' & 'display_filter' param…
…eters
- Loading branch information
Showing
6 changed files
with
139 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
require 'spec_helper' | ||
|
||
describe "Reports:" do | ||
before(:all) do #once (and could be modified by the following tests) | ||
Semrush.config do |config| | ||
config.api_key = API_KEY | ||
config.debug = true | ||
end | ||
end | ||
|
||
describe Semrush, "running basic reports" do | ||
it "works with the root method 'domain_rank'" do | ||
lambda{Semrush::Report.new.domain_rank(:request_type => :domain, :request => "seobook.com", :db => :us, :limit => 5)}.should_not raise_error | ||
end | ||
end | ||
|
||
describe Semrush, "running domain reports" do | ||
it "initializes correctly" do | ||
lambda{Semrush::Report.domain("seobook.com", :db => :us)}.should_not raise_error | ||
end | ||
it "initializes correctly with params" do | ||
lambda{Semrush::Report.domain("seobook.com", :db => :us)}.should_not raise_error | ||
end | ||
[:basics, :organic, :adwords].each do |method| | ||
it "works with the method '#{method}'" do | ||
lambda{@parsed = Semrush::Report.domain("seobook.com").send(method, :db => :us, :limit => 5)}.should_not raise_error | ||
@parsed.should_not be_nil | ||
@parsed.should be_a_kind_of(Array) | ||
@parsed.first.should be_a_kind_of(Hash) if !@parsed.first.nil? | ||
end | ||
end | ||
|
||
end | ||
|
||
describe Semrush, "running url reports" do | ||
it "initializes correctly" do | ||
lambda{Semrush::Report.url("http://tools.seobook.com/", :db => :us)}.should_not raise_error | ||
end | ||
it "initializes correctly with params" do | ||
lambda{Semrush::Report.url("http://tools.seobook.com/", :db => :us)}.should_not raise_error | ||
end | ||
[:organic, :adwords].each do |method| | ||
it "works with the method '#{method}'" do | ||
lambda{@parsed = Semrush::Report.url("http://tools.seobook.com/").send(method, :db => :us, :limit => 5)}.should_not raise_error | ||
@parsed.should_not be_nil | ||
@parsed.should be_a_kind_of(Array) | ||
@parsed.first.should be_a_kind_of(Hash) if !@parsed.first.nil? | ||
end | ||
end | ||
[:basics, :competitors_organic, :competitors_adwords, :competitors_organic_by_adwords, :competitors_adwords_by_organic].each do |method| | ||
it "should not work with the method '#{method}'" do | ||
lambda{@parsed = Semrush::Report.url("http://tools.seobook.com/").send(method, :db => :us, :limit => 5)}.should raise_error | ||
end | ||
end | ||
end | ||
|
||
describe Semrush, "running phrase reports" do | ||
it "initializes correctly" do | ||
lambda{Semrush::Report.phrase("search+engine+optimization", :db => :us)}.should_not raise_error | ||
end | ||
it "initializes correctly with params" do | ||
lambda{Semrush::Report.phrase("search+engine+optimization", :db => :us)}.should_not raise_error | ||
end | ||
[:basics, :related, :organic].each do |method| | ||
it "works with the method '#{method}'" do | ||
lambda{@parsed = Semrush::Report.phrase("search+engine+optimization").send(method, :db => :us, :limit => 5)}.should_not raise_error | ||
@parsed.should_not be_nil | ||
@parsed.should be_a_kind_of(Array) | ||
@parsed.first.should be_a_kind_of(Hash) if !@parsed.first.nil? | ||
end | ||
end | ||
[:basics, :related].each do |method| | ||
it "deals correctly with & in phrase" do | ||
lambda{Semrush::Report.phrase("calvin & hobbs").send(method, :db => :us, :limit => 5)}.should_not raise_error | ||
end | ||
end | ||
end | ||
|
||
describe Semrush, "parameters positions in reports" do | ||
it "could be set in the class method" do | ||
lambda{Semrush::Report.domain("seobook.com", :db => :fr, :limit => 5, :offset => 2)}.should_not raise_error | ||
end | ||
it "could be set in the instance method" do | ||
lambda{Semrush::Report.domain("seobook.com").organic(:db => :fr, :limit => 5, :offset => 2)}.should_not raise_error | ||
end | ||
it "both methods get the same results" do | ||
in_class = Semrush::Report.domain("seobook.com", :db => :fr, :limit => 5, :offset => 2).organic | ||
in_object = Semrush::Report.domain("seobook.com").organic(:db => :fr, :limit => 5, :offset => 2) | ||
in_class.should == in_object | ||
end | ||
end | ||
|
||
describe Semrush, "using display_sort parameter" do | ||
it "works with domain_organic" do | ||
lambda{Semrush::Report.domain("wikipedia.org", :limit => 5, :display_sort => 'tr_asc').organic}.should_not raise_error | ||
end | ||
end | ||
describe Semrush, "using display_filter parameter" do | ||
it "returns an Array with elements if Po<5" do | ||
r = Semrush::Report.domain("wikipedia.org", :limit => 5, :display_filter => '+|Po|Lt|5').organic | ||
r.should be_a_kind_of Array | ||
r.count.should > 0 | ||
end | ||
it "returns empty Array if Po<1" do | ||
Semrush::Report.domain("wikipedia.org", :limit => 5, :display_filter => '+|Po|Lt|1').organic.should == [] | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters