Sha256: ccaa6b5ed36937f8e6cabc75e58cbb2830b536dbf91ebf8b25174bf37c86e740

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'
require 'kintone/command/form'
require 'kintone/api'

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

  describe '#get' do
    before(:each) do
      stub_request(
        :get,
        'https://example.cybozu.com/k/v1/form.json'
      )
        .with(body: request_body.to_json)
        .to_return(
          body: '{"result":"ok"}',
          status: 200,
          headers: { 'Content-type' => 'application/json' }
        )
    end

    subject { target.get(app) }

    let(:app) { 4 }
    let(:request_body) { { app: app } }

    it { expect(subject).to eq 'result' => 'ok' }

    context 'fail to request' do
      before(:each) do
        stub_request(
          :get,
          'https://example.cybozu.com/k/v1/form.json'
        )
          .with(body: request_body.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

4 entries across 4 versions & 2 rubygems

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