Sha256: 8a151ff50ceb4ce49ea968995423dcf35f9727f02214029b22a5864cfb418f92

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

RSpec.describe Ribose::SpaceFile do
  describe ".all" do
    it "retrieve files uploaded to a spce" do
      space_id = 123_456_789
      stub_ribose_space_file_list(space_id)

      files = Ribose::SpaceFile.all(space_id)

      expect(files.first.id).not_to be_nil
      expect(files.first.name).to eq("sample-file.png")
      expect(files.first.versions.first.version).to eq(1)
    end
  end

  describe ".create" do
    it "creates a new file with provided details" do
      space_id = 123_456_789

      stub_ribose_space_file_upload_api(space_id, file_attributes)
      file = Ribose::SpaceFile.create(space_id, file_attributes)

      expect(file.id).not_to be_nil
      expect(file.author).to eq("John Doe")
      expect(file.content_type).to eq("image/png")
    end
  end

  def file_attributes
    {
      file: sample_fixture_file,
      description: "This is a sample file",
      tag_list: "Details tag for the file",
    }
  end

  def sample_fixture_file
    @sample_file ||= File.join(Ribose.root, "spec/fixtures/sample.png")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ribose-0.2.0 spec/ribose/space_file_spec.rb