Sha256: be7850d11997c5fe96447f60f00df4d1876f0e2174adbbf1b7f99f8b8cba566a
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
require "spec_helper" describe UrbanDictionary do let(:result){ mock :result } describe "class method" do describe "#define" do it "should delegate to Word#from_url" do UrbanDictionary::Word.should_receive(:from_url).with("#{UrbanDictionary::DEFINE_URL}?term=pie").and_return(result) UrbanDictionary.define("pie").should eq(result) end it "should url encode the request" do UrbanDictionary::Word.should_receive(:from_url).with("#{UrbanDictionary::DEFINE_URL}?term=asdf%25asdf").and_return(result) UrbanDictionary.define("asdf%asdf").should eq(result) end end describe "#random_word" do let(:request){ mock :request } let(:response){ {'location' => 'location'} } let(:http){ mock :http } it "should do an HTTP GET to determine the random word" do Net::HTTP.should_receive(:start).with("www.urbandictionary.com", 80).and_yield(http).and_return(response) http.should_receive(:request).with(an_instance_of(Net::HTTP::Get)) UrbanDictionary.should_receive(:define).with('location').and_return(result) UrbanDictionary.random_word.should eq(result) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
urban_dictionary-0.0.2 | spec/urban_dictionary_spec.rb |