twitter-status-bot/.gems/gems/naught-1.0.0/spec/base_object_spec.rb

48 lines
1.0 KiB
Ruby
Raw Normal View History

2014-09-03 08:49:59 +00:00
require 'spec_helper'
describe 'null object with a custom base class' do
subject(:null) { custom_base_null_class.new }
let(:custom_base_null_class) do
Naught.build do |b|
b.base_class = Object
end
end
it 'respond to base class methods' do
expect(null.methods).to be_an Array
end
it 'respond to unknown methods' do
expect(null.foo).to be_nil
end
it 'exposes the default base class choice, for the curious' do
default_base_class = :not_set
Naught.build do |b|
default_base_class = b.base_class
end
expect(default_base_class).to eq(Naught::BasicObject)
end
describe 'singleton null object' do
subject(:null_instance) { custom_base_singleton_null_class.instance }
let(:custom_base_singleton_null_class) do
Naught.build do |b|
b.singleton
b.base_class = Object
end
end
it 'can be cloned' do
expect(null_instance.clone).to be(null_instance)
end
it 'can be duplicated' do
expect(null_instance.dup).to be(null_instance)
end
end
end