Sha256: e1b7b5e34286032aa974bbe6a1edf904f432cbe0ef153ab6b5fc126f3b849033
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
# require 'spec_helper' describe Popularity::Search do context "single url" do use_vcr_cassette "search" subject { Popularity.search('http://google.com') } it "should return correct total" do expect(23422351).to equal subject.total end context "json" do let(:json) { subject.to_json } it "should have each url as root json key" do subject.sources.each do |source| expect(json[source.to_s]).to_not be_nil end end it "should have each network as root json key" do subject.searches.each do |search| expect(json[search.url.to_s]).to_not be_nil end end it "should have each total as root json key" do expect(json["total"]).to_not be_nil end end end context "multiple url" do use_vcr_cassette "search-multi" subject { Popularity.search("http://google.com", "http://yahoo.com") } it "should return correct aggregates" do shares = subject.searches.collect do |search| search.facebook.shares end expect(subject.facebook.shares).to eq(shares.reduce(:+)) end it "should combine results" do expect(subject.searches.collect(&:results).reduce(:+).size).to eq(subject.results.size) end it "should allow access to individual results" do expect(subject.facebook.results.size).to eq(2) end context "json" do let(:json) { subject.to_json } it "should have each url as root json key" do subject.sources.each do |source| expect(json[source.to_s]).to_not be_nil end end it "should have each network as root json key" do subject.searches.each do |search| expect(json[search.url.to_s]).to_not be_nil end end it "should have each total as root json key" do expect(json["total"]).to_not be_nil end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
popularity-0.1.1 | spec/search_spec.rb |
popularity-0.1.0 | spec/search_spec.rb |
popularity-0.0.1 | spec/search_spec.rb |