Sha256: afb3ed18760ebf920bca43e911dc0e18dd9ff410891b0102b3732e1b5689cb3b

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

describe ChatWork::File do
  describe ".get", type: :api do
    subject { ChatWork::File.get(room_id: room_id, account_id: account_id, &block) }

    before do
      stub_chatwork_request(:get, "/rooms/#{room_id}/files", "/rooms/{room_id}/files")
    end

    let(:room_id)    { 123 }
    let(:account_id) { 101 }

    it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/files"
  end

  describe ".find", type: :api do
    subject { ChatWork::File.find(room_id: room_id, file_id: file_id, create_download_url: create_download_url, &block) }

    before do
      stub_chatwork_request(:get, "/rooms/#{room_id}/files/#{file_id}", "/rooms/{room_id}/files/{file_id}")
    end

    let(:room_id) { 123 }
    let(:file_id) { 101 }

    context "when force is Integer" do
      let(:create_download_url) { 1 }

      it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/files/{file_id}"
    end

    context "when force is boolean" do
      let(:create_download_url) { true }

      it_behaves_like :a_chatwork_api, :get, "/rooms/{room_id}/files/{file_id}"
    end
  end

  describe ".create", type: :api do
    subject { ChatWork::File.create(room_id: room_id, file: file, message: message, &block) }

    before do
      stub_chatwork_request(:post, "/rooms/#{room_id}/files", "/rooms/{room_id}/files")
    end

    let(:room_id) { 123 }
    let(:file)    { Faraday::UploadIO.new("#{spec_dir}/data/upload.txt", "text/plain") }
    let(:message) { "I attached comment to chat." }

    it_behaves_like :a_chatwork_api, :post, "/rooms/{room_id}/files"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
chatwork-1.0.1 spec/lib/chatwork/file_spec.rb
chatwork-1.0.0 spec/lib/chatwork/file_spec.rb
chatwork-0.12.3 spec/lib/chatwork/file_spec.rb
chatwork-0.12.2 spec/lib/chatwork/file_spec.rb
chatwork-0.12.1 spec/lib/chatwork/file_spec.rb
chatwork-0.12.0 spec/lib/chatwork/file_spec.rb
chatwork-0.11.0 spec/lib/chatwork/file_spec.rb
chatwork-0.10.0 spec/lib/chatwork/file_spec.rb