Sha256: 543552c81ae1dcdcb005d4215af715369826bee3a0c007d15dc11bee974404a5

Contents?: true

Size: 1.88 KB

Versions: 53

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'

describe S3Website::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 = []
      S3Website::Keyboard.if_user_confirms_delete(
        s3_object_keys,
        config = {},
        standard_input
      ) { |key|
        deleted_keys << key
      }
      deleted_keys
    end
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
s3_website-1.8.2 spec/lib/keyboard_spec.rb
s3_website-1.8.1 spec/lib/keyboard_spec.rb
s3_website-1.8.0 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.15 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.14 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.13 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.12 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.11 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.9 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.8 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.7 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.6 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.5 spec/lib/keyboard_spec.rb
s3_website-1.7.6 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.4 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.3 spec/lib/keyboard_spec.rb
s3_website-1.7.5 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.2 spec/lib/keyboard_spec.rb
s3_website_monadic-0.0.1 spec/lib/keyboard_spec.rb
s3_website-1.7.4 spec/lib/keyboard_spec.rb