Sha256: ddc5e1c62bf53ec0d0b88347b51a3cfa7debcdd348bca44bb4a01c49bf5a31b0

Contents?: true

Size: 874 Bytes

Versions: 10

Compression:

Stored size: 874 Bytes

Contents

# encoding: utf-8

RSpec.describe TTY::Prompt::Choice, '#from' do
  it "skips Choice instance" do
    choice = described_class.new(:large, 1)
    expect(described_class.from(choice)).to eq(choice)
  end

  it "creates choice from string" do
    choice = described_class.new('large', 'large')
    expect(described_class.from('large')).to eq(choice)
  end

  it "creates choice from array" do
    choice = described_class.new('large', 1)
    expect(described_class.from([:large, 1])).to eq(choice)
  end

  it "creates choice from hash value" do
    choice = described_class.new('large', 1)
    expect(described_class.from({large: 1})).to eq(choice)
  end

  it "create choice from hash with key property" do
    default = {key: 'h', name: 'Help', value: :help}
    choice = described_class.new('Help', :help)
    expect(described_class.from(default)).to eq(choice)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tty-prompt-0.12.0 spec/unit/choice/from_spec.rb
tty-prompt-0.11.0 spec/unit/choice/from_spec.rb
tty-prompt-0.10.1 spec/unit/choice/from_spec.rb
tty-prompt-0.10.0 spec/unit/choice/from_spec.rb
tty-prompt-0.9.0 spec/unit/choice/from_spec.rb
tty-prompt-0.8.0 spec/unit/choice/from_spec.rb
tty-prompt-0.7.1 spec/unit/choice/from_spec.rb
tty-prompt-0.7.0 spec/unit/choice/from_spec.rb
tty-prompt-0.6.0 spec/unit/choice/from_spec.rb
tty-prompt-0.5.0 spec/unit/choice/from_spec.rb