Sha256: d36afe054d209ae02ad481c8cb56ab59e89b4b624618adef11bb25426d18fbcd
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require 'spec_helper' class BaseTester < Rapidash::Base url "tester" end class Base < Rapidash::Base end class Rapidash::Resource < Rapidash::Base end describe Rapidash::Base do describe ".initialize" do it "should assume a default based on the class name" do Base.new.instance_variable_get(:@url).should eql("base") end it "should ignore any modules when infering the URL" do Rapidash::Resource.new.instance_variable_get(:@url).should eql("resource") end it "should override the URL if set" do BaseTester.new.instance_variable_get(:@url).should eql("tester") end end let(:client) { mock } let(:headers) { {"content-type" => "application/json"} } let (:subject) { BaseTester.new(client) } describe ".call!" do it "should call get on the client" do subject.url = "tester/1" client.should_receive(:get).with("tester/1", {:header => headers}) subject.call! end it "should call a post on the client if set" do client.should_receive(:post).with("tester", {:header => headers}) subject.options = {:method => :post} subject.url = "tester" subject.call! end end describe ".base_url" do it "should return an empty string if no previous url is set" do subject.send(:base_url).should eql("") end it "should return the previous url if set" do subject.options = {:previous_url => "users/Gazler"} subject.send(:base_url).should eql("users/Gazler/") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rapidash-0.0.2 | spec/rapidash/base_spec.rb |