Sha256: 05e6ebda8ad0138d8d8d7d765654febb5c389df51699b6cf0aecc2761ab519ac
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' require 'kintone/command/file' require 'kintone/api' describe Kintone::Command::File do let(:target) { Kintone::Command::File.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/file.json?fileKey=file-key-string' ) .to_return(body: attachment, status: 200, headers: { 'Content-type' => 'image/gif' }) end subject { target.get(fileKey) } let(:attachment) do Base64.decode64('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==') end let(:fileKey) { 'file-key-string' } it { expect(subject).to eq attachment } end describe '#register' do before(:each) do expect(api).to receive(:post_file) .with( target.instance_variable_get('@url'), path, content_type, original_filename) .and_return('c15b3870-7505-4ab6-9d8d-b9bdbc74f5d6') end subject { target.register(path, content_type, original_filename) } let(:path) { '/path/to/file.txt' } let(:content_type) { 'text/plain' } let(:original_filename) { 'fileName.txt' } it { is_expected.to eq 'c15b3870-7505-4ab6-9d8d-b9bdbc74f5d6' } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kintone-0.1.4 | spec/kintone/command/file_spec.rb |
kintone-0.1.3 | spec/kintone/command/file_spec.rb |