Sha256: 0c8fc7481d289b0ac65e370754801c316d5d2af2dd11a60e568e281ac6b486e3
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Relation::Keys, '.new' do subject { object.new(argument) } let(:object) { described_class } let(:id) { Attribute::Integer.new(:id) } let(:name) { Attribute::String.new(:name) } context 'with no arguments' do subject { object.new } it { should be_instance_of(object) } it { should be_empty } end context 'with an argument that responds to #to_ary and contains irreducible keys' do let(:argument) { [Relation::Header.new([id])] } it { should be_instance_of(object) } it { should == argument } it 'does not freeze the argument' do argument.should_not be_frozen expect { subject }.to_not change(argument, :frozen?) end end context 'with an argument that responds to #to_ary and contains reducible keys' do let(:argument) { [reducible_key, irreducible_key] } let(:reducible_key) { Relation::Header.new([id, name]) } let(:irreducible_key) { Relation::Header.new([id]) } specify { expect { subject }.to raise_error(ReducibleKeyError, "reducible keys: #{[reducible_key.to_set].inspect}") } end context 'when the argument is not a Keys and does not respond to #to_ary' do let(:argument) { Object.new } specify { expect { subject }.to raise_error(NoMethodError) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
axiom-0.1.1 | spec/unit/axiom/relation/keys/class_methods/new_spec.rb |