Sha256: 348e233a6064cdd1c2738be68202ea14c712e6c1fb0c364857ceea5530e5ae6e
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 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" => [ {'some_case' => {"id" => 1}} ]}) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
caseblocks_api-0.2.4 | spec/caseblocks_api_spec.rb |