Skip to content

Commit

Permalink
Clean up #261
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jun 1, 2012
1 parent 402792c commit 7a96bcd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 168 deletions.
54 changes: 3 additions & 51 deletions lib/twitter/search_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,14 @@

module Twitter
class SearchResults < Twitter::Base
lazy_attr_reader :completed_in, :max_id, :next_page, :page, :query,
:refresh_url, :results_per_page, :since_id

# @return [Array<Twitter::Status>]
def results
@results ||= (@attrs['results'] || []).map{ |status| Twitter::Status.new(status) }
@results ||= Array(@attrs['results']).map{|status| Twitter::Status.new(status)}
end
alias :collection :results

# @return [Float]
def completed_in
@attrs['completed_in']
end

# @return [Fixnum]
def max_id
@attrs['max_id']
end

# @return [String]
def max_id_str
@attrs['max_id_str']
end

# @return [String]
def next_page
@attrs['next_page']
end

# @return [Fixnum]
def page
@attrs['page']
end

# @return [String]
def query
@attrs['query']
end

# @return [String]
def refresh_url
@attrs['refresh_url']
end

# @return [Fixnum]
def results_per_page
@attrs['results_per_page']
end

# @return [Fixnum]
def since_id
@attrs['since_id']
end

# @return [String]
def since_id_str
@attrs['since_id_str']
end
end
end

117 changes: 0 additions & 117 deletions spec/twitter/search_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,116 +2,6 @@

describe Twitter::SearchResults do

describe "#completed_in" do
it "should return completed_in" do
results = Twitter::SearchResults.new('completed_in' => 23.5)
results.completed_in.should == 23.5
end
it "should return nil when no value exists" do
results = Twitter::SearchResults.new
results.completed_in.should be_nil
end
end

describe "#max_id" do
it "should contain the max_id" do
results = Twitter::SearchResults.new('max_id' => 123456)
results.max_id.should == 123456
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.max_id.should be_nil
end
end

describe "#max_id_str" do
it "should contain the max_id_str" do
results = Twitter::SearchResults.new('max_id_str' => '123456')
results.max_id_str.should == '123456'
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.max_id_str.should be_nil
end
end

describe "#next_page" do
it "should contain the next_page" do
results = Twitter::SearchResults.new('next_page' => "?page=2&max_id=122078461840982016&q=blue%20angels&rpp=5")
results.next_page.should == "?page=2&max_id=122078461840982016&q=blue%20angels&rpp=5"
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.next_page.should be_nil
end
end

describe "#page" do
it "should contain the page" do
results = Twitter::SearchResults.new('page' => 2)
results.page.should == 2
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.page.should be_nil
end
end

describe "#query" do
it "should contain the query" do
results = Twitter::SearchResults.new('query' => 'blue+angels')
results.query.should == 'blue+angels'
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.query.should be_nil
end
end

describe "#refresh_url" do
it "should contain the refresh_url" do
results = Twitter::SearchResults.new('refresh_url' => '?since_id=122078461840982016&q=blue%20angels')
results.refresh_url.should == '?since_id=122078461840982016&q=blue%20angels'
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.refresh_url.should be_nil
end
end

describe "#results_per_page" do
it "should contain the results_per_page" do
results = Twitter::SearchResults.new('results_per_page' => 10)
results.results_per_page.should == 10
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.results_per_page.should be_nil
end
end

describe "#since_id" do
it "should contain the since_id" do
results = Twitter::SearchResults.new('since_id' => 123456)
results.since_id.should == 123456
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.since_id.should be_nil
end
end

describe "#since_id_str" do
it "should contain the since_id_str" do
results = Twitter::SearchResults.new('since_id_str' => '123456')
results.since_id_str.should == '123456'
end
it "should be nil when no value passed" do
results = Twitter::SearchResults.new
results.since_id_str.should be_nil
end
end

describe "#results" do
it "should contain twitter status objects" do
search_results = Twitter::SearchResults.new('results' => [{'text' => 'tweet!'}])
Expand All @@ -125,11 +15,4 @@
end
end

describe "#collection" do
it "should alias collection to results" do
search_results = Twitter::SearchResults.new('results' => [{'text' => 'tweet!'}])
search_results.collection.should be_a Array
search_results.collection.first.should be_a Twitter::Status
end
end
end

0 comments on commit 7a96bcd

Please sign in to comment.