Sha256: 6f81a9a2d71973224bfb137b7f2948385c0972aa64a82541bf67ef54b646439c

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Menagerie::Artifact do
  before(:each) do
    FileUtils.rm_rf 'spec/examples/scratch'
    FileUtils.cp_r 'spec/examples/existing', 'spec/examples/scratch'
  end

  let(:base_path) { 'spec/examples/scratch' }
  let(:paths) do
    {
      artifacts: "#{base_path}/artifacts",
      releases: "#{base_path}/releases",
      latest: "#{base_path}/latest"
    }
  end
  let(:new_artifact) do
    { name: 'a', version: '2.0.0', url: 'https://goo.gl/pWew5I' }
  end
  let(:produce_output) do
    output(/Downloading artifact/).to_stdout_from_any_process
  end
  let(:artifact) { Menagerie.new(paths: paths).releases.first.artifacts.first }

  it 'has a name attribute' do
    expect(artifact.name).to eql 'a'
  end

  it 'has a version attribute' do
    expect(artifact.version).to eql '0.0.3'
  end

  it 'has a path attribute' do
    expect(artifact.path).to eql "#{base_path}/artifacts/a/0.0.3"
  end

  it 'is created if it does not exist' do
    expect(File.exist? "#{base_path}/artifacts/a/2.0.0").to be_falsey
    params = { paths: paths, artifact: new_artifact }
    expect { Menagerie::Artifact.new params }.to produce_output
    expect(File.exist? "#{base_path}/artifacts/a/2.0.0").to be_truthy
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
menagerie-1.0.0 spec/menagerie/artifact_spec.rb