Sha256: 7b57a1a9bd13fee78b8ea10927cea900e26303159cd099ee5326ebcdfd92c6e1

Contents?: true

Size: 1.16 KB

Versions: 67

Compression:

Stored size: 1.16 KB

Contents

require "spec_helper"
require "shelly/backup"

describe Shelly::Backup do
  before do
    @client = mock
    Shelly::Client.stub(:new).and_return(@client)
    @client.stub(:download_backup_url).and_return("https://backups.example.com")
  end

  it "should assign attributes" do
    backup = Shelly::Backup.new(attributes)

    backup.code_name.should == "foo"
    backup.filename.should == "backup.tar.gz"
    backup.human_size.should == "2KB"
    backup.size.should == 2048
    backup.state.should == "completed"
  end

  describe "#download" do
    it "should download given backup via API file with filename to which backup will be downloaded" do
      callback = lambda {}
      @client.should_receive(:download_backup_url).with("foo", "backup.tar.gz")
      @client.should_receive(:download_file).with("foo", "backup.tar.gz",
                                                  "https://backups.example.com", callback)
      backup = Shelly::Backup.new(attributes)
      backup.download(callback)
    end
  end

  def attributes
    {"code_name" => "foo",
    "filename"   => "backup.tar.gz",
    "human_size" => "2KB",
    "size"       => 2048,
    "state"      => "completed"}
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
shelly-0.5.7 spec/shelly/backup_spec.rb
shelly-0.5.6 spec/shelly/backup_spec.rb
shelly-0.5.5 spec/shelly/backup_spec.rb
shelly-0.5.4 spec/shelly/backup_spec.rb
shelly-0.5.3 spec/shelly/backup_spec.rb
shelly-0.5.2 spec/shelly/backup_spec.rb
shelly-0.5.1 spec/shelly/backup_spec.rb
shelly-0.5.0 spec/shelly/backup_spec.rb
shelly-0.4.42 spec/shelly/backup_spec.rb
shelly-0.4.41 spec/shelly/backup_spec.rb
shelly-0.4.40 spec/shelly/backup_spec.rb
shelly-0.4.39 spec/shelly/backup_spec.rb
shelly-0.4.38 spec/shelly/backup_spec.rb
shelly-0.4.37 spec/shelly/backup_spec.rb
shelly-0.4.36 spec/shelly/backup_spec.rb
shelly-0.4.35 spec/shelly/backup_spec.rb
shelly-0.4.34 spec/shelly/backup_spec.rb
shelly-0.4.33 spec/shelly/backup_spec.rb
shelly-0.4.32 spec/shelly/backup_spec.rb
shelly-0.4.31 spec/shelly/backup_spec.rb