Sha256: 2bb276e6dcba636f9c4569bcc8c8f1338be6374487653340158be7925213ab90
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/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 "when i'm authorised with caseblocks" do before 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") end it "should return me the requested case type" do @caseblocks.stub(:get_casetype_id).and_return(2) case_type = @caseblocks.get_casetype_id("Some Case type") case_type.should eql 2 end it "should let me create a case" do CaseblocksAPI::Client.stub(:post).and_return({"token" => "some_token"}) params = {"title" => "This is a Case!", "due_at" => Time.now + 1000, "owned_by_id" => 1, "owned_by_type" => "CaseBlocks::User"} @caseblocks.stub(:create_case).and_return({"case" => {}}) response = @caseblocks.create_case(params, "Tyre Shopper Order") response.should include("case") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
caseblocks_api-0.1.2 | spec/caseblocks_api_spec.rb |
caseblocks_api-0.1.1 | spec/caseblocks_api_spec.rb |