Sha256: 74afcf336a7c89c67ce60a2a9214bd5fe7b94e15724e70d7997ea87ce16a7e6e
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require File.join(File.dirname(__FILE__), '..', 'spec_helper' ) describe "Itrigga::NetHelper::RestClient" do before do @mock_response = mock("Response", :to_str => "stuff") @client = mock("RestClient::Request") @client.stub!(:execute).and_return(@mock_response) RestClient::Request.stub!(:new).and_return(@client) end it "should raise error if no url" do lambda { Itrigga::NetHelper::RestClient.get }.should raise_error(ArgumentError,":url is required") end it "should call execute on new Request" do RestClient::Request.should_receive(:new).with(hash_including(:method => :get, :url => "abc", :param1 => "blart")).and_return(@client) Itrigga::NetHelper::RestClient.get :url => "abc", :param1 => "blart" end it "should return the correct value" do @mock_response.should_receive(:to_str).and_return("stuff") Itrigga::NetHelper::RestClient.get(:url => "abc").should == "stuff" end context "when given a :username" do it "should convert it to :user" do RestClient::Request.should_receive(:new).with(hash_including(:method => :get, :url => "abc", :user => "blart")).and_return(@client) Itrigga::NetHelper::RestClient.get :url => "abc", :username => "blart" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
itrigga-net_helper-0.3.0 | spec/net_helper/rest_client_spec.rb |