require 'spec_helper' describe UptimeRobot::Client do let(:client) { UptimeRobot::Client.new('abc123') } subject { client } describe 'attributes' do it { should respond_to :api_key } end describe '#get' do context 'when Uptime Robot responds with a good status code' do before { RestClient.stub(:get).and_raise(RestClient::Exception) } it "should raise UptimeRobot::Exception" do expect { client.get('resource') }.to raise_error(UptimeRobot::Exception) end end context 'when Uptime Robot responds with a bad status code' do before { RestClient.stub(:get).and_return("{\"foo\":\"bar\",\"baz\":\"qux\"}") } subject { client.get('resource') } it { should be_a(Hash) } end end end