test/lib/vedeu/terminal/terminal_test.rb in vedeu-0.6.12 vs test/lib/vedeu/terminal/terminal_test.rb in vedeu-0.6.13
- old
+ new
@@ -6,18 +6,18 @@
let(:described) { Vedeu::Terminal }
let(:console) { IO.console }
before do
- console.stubs(:winsize).returns([25, 80])
+ console.stubs(:winsize).returns([25, 40])
console.stubs(:print)
end
describe '.open' do
context 'when a block was not given' do
it {
- proc { Vedeu::Terminal.open }.must_raise(Vedeu::Error::InvalidSyntax)
+ proc { Vedeu::Terminal.open }.must_raise(Vedeu::Error::RequiresBlock)
}
end
it 'opens a new terminal console in raw mode' do
Vedeu::Configuration.stub(:terminal_mode, :raw) do
@@ -93,12 +93,24 @@
'even more...']) }
end
end
describe '.resize' do
+ before { Vedeu.stubs(:trigger) }
+
subject { described.resize }
+ it {
+ Vedeu.expects(:trigger).with(:_clear_)
+ subject
+ }
+
+ it {
+ Vedeu.expects(:trigger).with(:_refresh_)
+ subject
+ }
+
it { subject.must_be_instance_of(TrueClass) }
end
describe '.clear' do
subject { described.clear }
@@ -134,11 +146,11 @@
subject { described.centre }
it { subject.must_be_instance_of(Array) }
it 'returns the centre point on the terminal' do
- subject.must_equal([12, 40])
+ subject.must_equal([12, 20])
end
end
describe '.centre_y' do
subject { described.centre_y }
@@ -154,11 +166,11 @@
subject { described.centre_x }
it { subject.must_be_instance_of(Fixnum) }
it 'returns the centre `x` point on the terminal' do
- subject.must_equal(40)
+ subject.must_equal(20)
end
end
describe '.origin' do
subject { Vedeu::Terminal.origin }
@@ -176,49 +188,40 @@
it { subject.must_be_instance_of(Fixnum) }
it { described.must_respond_to(:xn) }
it { described.must_respond_to(:txn) }
- context 'via method' do
+ context 'when the terminal is an odd number of characters in width' do
it 'returns the width' do
- subject.must_equal(80)
+ subject.must_equal(40)
end
end
-
- context 'via API' do
- it 'returns the width' do
- Vedeu.width.must_equal(80)
- end
- end
end
describe '.height' do
subject { Vedeu::Terminal.height }
it { subject.must_be_instance_of(Fixnum) }
it { described.must_respond_to(:yn) }
it { described.must_respond_to(:tyn) }
- context 'via method' do
+ context 'when the terminal is an odd number of characters in height' do
it 'returns the height' do
subject.must_equal(24)
end
end
-
- context 'via API' do
- it 'returns the height' do
- Vedeu.height.must_equal(24)
- end
- end
end
describe '.size' do
subject { Vedeu::Terminal.size }
it { subject.must_be_instance_of(Array) }
- it 'returns the width and height' do
- subject.must_equal([24, 80])
+ context 'when the terminal is an odd number of characters in height or ' \
+ 'width' do
+ it 'returns the width and height' do
+ subject.must_equal([24, 40])
+ end
end
end
describe '.console' do
it 'returns the console' do