File: just_spec.rb

package info (click to toggle)
ruby-naught 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 276 kB
  • sloc: ruby: 1,091; makefile: 6
file content (22 lines) | stat: -rw-r--r-- 600 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'spec_helper'

describe 'Just()' do
  include ConvertableNull::Conversions

  specify 'passes non-nullish values through' do
    expect(Just(false)).to be(false)
    str = 'hello'
    expect(Just(str)).to be(str)
  end

  specify 'rejects nullish values' do
    expect { Just(nil) }.to raise_error(ArgumentError)
    expect { Just('') }.to raise_error(ArgumentError)
    expect { Just(ConvertableNull.get) }.to raise_error(ArgumentError)
  end

  it 'also works with blocks' do
    expect { Just { nil }.class }.to raise_error(ArgumentError)
    expect(Just { 'foo' }).to eq('foo')
  end
end