Sha256: 3446a7af165b057f22b9b12a3f0088f1fea94c50bba1441d57fc5e12d4aa02b6

Contents?: true

Size: 1.89 KB

Versions: 11

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe Jekyll::S3::Keyboard do
  describe '.keep_or_delete' do
    let(:s3_object_keys) { ['a', 'b', 'c'] }
    let(:standard_input) { stub('std_in') }

    it 'can delete only the first item' do
      standard_input.stub(:gets).and_return("d", "K")
      deleted_keys = call_keyboard(s3_object_keys, standard_input)
      deleted_keys.should eq(['a'])
    end

    it 'can delete only the second item' do
      standard_input.stub(:gets).and_return("k", "d", "k")
      deleted_keys = call_keyboard(s3_object_keys, standard_input)
      deleted_keys.should eq(['b'])
    end

    it 'can delete all but the first item' do
      standard_input.stub(:gets).and_return("k", "D")
      deleted_keys = call_keyboard(s3_object_keys, standard_input)
      deleted_keys.should eq(['b', 'c'])
    end

    it 'can delete all s3 objects' do
      standard_input.stub(:gets).and_return("D")
      deleted_keys = call_keyboard(s3_object_keys, standard_input)
      deleted_keys.should eq(['a', 'b', 'c'])
    end

    it 'can keep one s3 object' do
      standard_input.stub(:gets).and_return("k", "d", "d")
      deleted_keys = call_keyboard(s3_object_keys, standard_input)
      deleted_keys.should eq(['b', 'c'])
    end

    it 'can keep all s3 objects' do
      standard_input.stub(:gets).and_return("k", "k", "k")
      deleted_keys = call_keyboard(s3_object_keys, standard_input)
      deleted_keys.should eq([])
    end

    it 'can keep all s3 objects' do
      standard_input.stub(:gets).and_return("K")
      deleted_keys = call_keyboard(s3_object_keys, standard_input)
      deleted_keys.should eq([])
    end

    def call_keyboard(s3_object_keys, standard_input)
      deleted_keys = []
      Jekyll::S3::Keyboard.if_user_confirms_delete(s3_object_keys, 
                                                   standard_input) { |key|
        deleted_keys << key
      }
      deleted_keys
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
jekyll-s3-3.2.0 spec/lib/keyboard_spec.rb
jekyll-s3-3.1.2 spec/lib/keyboard_spec.rb
jekyll-s3-3.1.1 spec/lib/keyboard_spec.rb
jekyll-s3-3.1.0 spec/lib/keyboard_spec.rb
jekyll-s3-3.0.0 spec/lib/keyboard_spec.rb
jekyll-s3-2.8.0 spec/lib/keyboard_spec.rb
jekyll-s3-2.7.0 spec/lib/keyboard_spec.rb
jekyll-s3-2.6.0 spec/lib/keyboard_spec.rb
jekyll-s3-2.5.1 spec/lib/keyboard_spec.rb
jekyll-s3-2.5.0 spec/lib/keyboard_spec.rb
jekyll-s3-2.4.3 spec/lib/keyboard_spec.rb