Sha256: 05693ad0787227b0f3f162b9cc7210f86adbd4a15f080ec519b43e475e4f99ce

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'
require 'kintone/command/template_space'
require 'kintone/api'

describe Kintone::Command::TemplateSpace do
  let(:target) { Kintone::Command::TemplateSpace.new(api) }
  let(:api) { Kintone::Api.new('example.cybozu.com', 'Administrator', 'cybozu') }

  describe '#create' do
    before(:each) do
      stub_request(
        :post,
        'https://example.cybozu.com/k/v1/template/space.json'
      )
        .with(body: request_data.to_json)
        .to_return(
          body: '{"id":"1"}',
          status: 200,
          headers: { 'Content-type' => 'application/json' }
        )
    end

    subject { target.create(id, name, members, is_guest: is_guest, fixed_member: fixed_member) }

    let(:id) { 1 }
    let(:name) { 'sample space' }
    let(:members) { [] }
    let(:is_guest) { false }
    let(:fixed_member) { false }
    let(:request_data) do
      {
        id: id,
        name: name,
        members: members,
        isGuest: is_guest,
        fixedMember: fixed_member
      }
    end

    it { expect(subject).to eq 'id' => '1' }

    context 'fail to request' do
      before(:each) do
        stub_request(
          :post,
          'https://example.cybozu.com/k/v1/template/space.json'
        )
          .with(body: request_data.to_json)
          .to_return(
            body: '{"message":"不正なJSON文字列です。","id":"1505999166-897850006","code":"CB_IJ01"}',
            status: 500,
            headers: { 'Content-Type' => 'application/json' }
          )
      end

      it { expect { subject }.to raise_error Kintone::KintoneError }
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
kintone_rb-1.0.1 spec/kintone/command/template_space_spec.rb
kintone_rb-1.0.0 spec/kintone/command/template_space_spec.rb
kintone-oauth-extension-0.2.2 spec/kintone/command/template_space_spec.rb
kintone-oauth-extension-0.2.1 spec/kintone/command/template_space_spec.rb
kintone-0.1.5 spec/kintone/command/template_space_spec.rb