Sha256: 9cea02626bbd0d8e9d7f6e46b17d63383753a94f687be9749be507768d1e48fb
Contents?: true
Size: 1.5 KB
Versions: 7
Compression:
Stored size: 1.5 KB
Contents
require 'spec_helper' describe "CaseblocksAPI" do describe "When authorising with CaseBlocks" do context "when I have an account" do it "should respond with and auth token" do CaseblocksAPI::Client.stub(:post).and_return({"token" => "some_token"}) username = "mark@local.me" password = "password1" caseblocks = CaseblocksAPI::Client.new(username, password, "http://localhost:3000") caseblocks.auth_token.should eql "some_token" end end context "when I don't have an account" do it "should raise an error" do CaseblocksAPI::Client.stub(:post).and_return({"message" => "You must have an account to do that"}) lambda { CaseblocksAPI::Client.new("blah@blah.com", "blahblah", "http://localhost:3000")}.should raise_error(CaseblocksAPI::AuthenticationException) end end end describe "creating a case" do let(:caseblocks_client) { CaseblocksAPI::Client.new("username", "password", "http://example.com") } it "should look for the case type id" do stub_request(:post, "http://example.com/tokens?auth_token=some_token") CaseblocksAPI::Client.stub(:get).and_return({"case_types" => [ {"id" => 1, "name" => 'some_case'} ]}) stub = stub_request(:post, "example.com/case_blocks/cases?auth_token=") .with({body: { 'case' => {'my' => 'params', 'case_type_id' => 1}}.to_json }) caseblocks_client.create_case({'my' => 'params'}, 'some_case') stub.should have_been_made.times(1) end end end
Version data entries
7 entries across 7 versions & 1 rubygems