test/lib/vedeu/dsl/interface_test.rb in vedeu-0.4.13 vs test/lib/vedeu/dsl/interface_test.rb in vedeu-0.4.14

- old
+ new

@@ -33,17 +33,35 @@ instance.border do # ... end } - it { subject.must_be_instance_of(Vedeu::Border) } - context 'when the block is not given' do subject { instance.border } it { proc { subject }.must_raise(InvalidSyntax) } end + + context 'when the block is given' do + subject { instance.border { } } + + it { subject.must_be_instance_of(Vedeu::Border) } + + context 'when the name is not given' do + it 'uses the interface name for storing the border' do + subject.name.must_equal('actinium') + end + end + + context 'when the name is given' do + subject { instance.border('magnesium') { } } + + it 'uses the name for storing the border' do + subject.name.must_equal('magnesium') + end + end + end end describe '#border!' do subject { instance.border! } @@ -57,65 +75,65 @@ subject { instance.cursor(value) } it { subject - Vedeu.cursors.find('actinium').state.visible?.must_equal(false) + Vedeu.cursors.find('actinium').visible?.must_equal(false) } context 'when the value is false' do let(:value) { false } it { subject - Vedeu.cursors.find('actinium').state.visible?.must_equal(false) + Vedeu.cursors.find('actinium').visible?.must_equal(false) } end - context 'when the value is :hide' do - let(:value) { :hide } + context 'when the value is nil' do + let(:value) {} it { subject - Vedeu.cursors.find('actinium').state.visible?.must_equal(false) + Vedeu.cursors.find('actinium').visible?.must_equal(false) } end context 'when the value is :show' do let(:value) { :show } it { subject - Vedeu.cursors.find('actinium').state.visible?.must_equal(true) + Vedeu.cursors.find('actinium').visible?.must_equal(true) } end context 'when the value is true' do let(:value) { true } it { subject - Vedeu.cursors.find('actinium').state.visible?.must_equal(true) + Vedeu.cursors.find('actinium').visible?.must_equal(true) } end context 'when the value is :yes' do let(:value) { :yes } it { subject - Vedeu.cursors.find('actinium').state.visible?.must_equal(true) + Vedeu.cursors.find('actinium').visible?.must_equal(true) } end end describe '#cursor!' do subject { instance.cursor! } it { subject - Vedeu.cursors.find('actinium').state.visible?.must_equal(true) + Vedeu.cursors.find('actinium').visible?.must_equal(true) } end describe '#delay' do it 'sets the delay attribute' do @@ -157,17 +175,35 @@ instance.geometry do # ... end } - it { subject.must_be_instance_of(Vedeu::Geometry) } - - context 'when the require block is not provided' do + context 'when the required block is not provided' do subject { instance.geometry } it { proc { subject }.must_raise(InvalidSyntax) } end + + context 'when the block is given' do + subject { instance.geometry { } } + + it { subject.must_be_instance_of(Vedeu::Geometry) } + + context 'when the name is not given' do + it 'uses the interface name for storing the geometry' do + subject.name.must_equal('actinium') + end + end + + context 'when the name is given' do + subject { instance.geometry('magnesium') { } } + + it 'uses the name for storing the geometry' do + subject.name.must_equal('magnesium') + end + end + end end describe '#group' do let(:value) { 'elements' } @@ -182,17 +218,19 @@ it { subject.must_equal(false) } end context 'when the named group exists' do + let(:members) { Set['actinium', 'lanthanum'] } + before do - Vedeu::Group.new({ name: 'elements', members: ['lanthanum'] }).store + Vedeu::Group.new(name: 'elements', members: ['lanthanum']).store end it { subject - Vedeu.groups.find('elements').members.must_equal(Set['actinium', 'lanthanum']) + Vedeu.groups.find('elements').members.must_equal(members) } end context 'when the named group does not exist' do it { @@ -234,9 +272,36 @@ name 'nickel' end Vedeu.use('nickel').name.must_equal('nickel') end + end + + describe '#show!' do + subject { + Vedeu.interface 'xenon' do + show! + end + } + + it { subject.visible.must_equal(true) } + end + + describe '#hide!' do + subject { + Vedeu.interface 'xenon' do + hide! + end + } + + it { subject.visible.must_equal(false) } + end + + describe '#visible' do + it { instance.visible(false).must_equal(false) } + it { instance.visible(true).must_equal(true) } + it { instance.visible(nil).must_equal(false) } + it { instance.visible(:show).must_equal(true) } end end # Interface end # DSL