Sha256: b8e9576e724e58aa15a9ec6fc05abf3914bff12173c945dd311039058defec33

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

require "spec_helper"

describe Hive::Representers::ArtifactRepresenter do

  class TestArtifact
    include Virtus.model

    attribute :artifact_id
    attribute :job_id
    attribute :asset_file_name
    attribute :asset_content_type
    attribute :asset_file_size
  end

  let(:upstream_artifact) do
    artifact = TestArtifact.new(artifact_attributes)
    artifact.extend(Hive::Representers::ArtifactRepresenter)
    artifact
  end

  let(:artifact_attributes) do
    {
        artifact_id:        321,
        job_id:             123,
        asset_file_name:    "screenshot1.png",
        asset_content_type: "image/png",
        asset_file_size:    2300
    }
  end

  describe "serialization " do

    let(:downstream_artifact) do
      artifact = TestArtifact.new
      artifact.extend(Hive::Representers::ArtifactRepresenter)
      artifact.from_json(upstream_artifact.to_json)
      artifact
    end


    subject { downstream_artifact }

    its(:artifact_id)              { should eq artifact_attributes[:artifact_id] }
    its(:job_id)              { should eq artifact_attributes[:job_id] }
    its(:asset_file_name)     { should eq artifact_attributes[:asset_file_name] }
    its(:asset_content_type)  { should eq artifact_attributes[:asset_content_type] }
    its(:asset_file_size)     { should eq artifact_attributes[:asset_file_size] }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hive-messages-1.0.7 spec/lib/hive/representers/artifact_representer_spec.rb
hive-messages-1.0.6 spec/lib/hive/representers/artifact_representer_spec.rb
hive-messages-1.0.5 spec/lib/hive/representers/artifact_representer_spec.rb
hive-messages-1.0.4 spec/lib/hive/representers/artifact_representer_spec.rb
hive-messages-1.0.3 spec/lib/hive/representers/artifact_representer_spec.rb
hive-messages-1.0.2 spec/lib/hive/representers/artifact_representer_spec.rb
hive-messages-1.0.1 spec/lib/hive/representers/artifact_representer_spec.rb