File: null_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 (33 lines) | stat: -rw-r--r-- 966 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'spec_helper'

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

  specify 'given no input, returns a null object' do
    expect(Null().class).to be(ConvertableNull)
  end

  specify 'given nil, returns a null object' do
    expect(Null(nil).class).to be(ConvertableNull)
  end

  specify 'given a null object, returns the same null object' do
    null = ConvertableNull.get
    expect(Null(null)).to be(null)
  end

  specify 'given anything in null_equivalents, returns a null object' do
    expect(Null('').class).to be(ConvertableNull)
  end

  specify 'given anything else, raises an ArgumentError' do
    expect { Null(false) }.to raise_error(ArgumentError)
    expect { Null('hello') }.to raise_error(ArgumentError)
  end

  it 'generates null objects with useful trace info' do
    null, line = Null(), __LINE__ # rubocop:disable ParallelAssignment
    expect(null.__file__).to eq(__FILE__)
    expect(null.__line__).to eq(line)
  end
end