2013-07-09 21:40:21 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Snapshot do
|
|
|
|
|
2013-09-10 19:29:17 +00:00
|
|
|
let(:snapshot) { described_class.build(data) }
|
|
|
|
let(:data) { [
|
2013-09-16 14:24:13 +00:00
|
|
|
[['a', fg: 1], ['b', fg: 2]],
|
|
|
|
[['ab', fg: 3] ],
|
|
|
|
[['a', fg: 5], ['b', fg: 6]],
|
|
|
|
[[' ', {}] , ['' , {}]]
|
2013-09-10 19:29:17 +00:00
|
|
|
] }
|
2013-07-09 21:40:21 +00:00
|
|
|
|
2013-08-25 18:49:23 +00:00
|
|
|
describe '#thumbnail' do
|
2013-09-10 19:29:17 +00:00
|
|
|
let(:thumbnail) { snapshot.thumbnail(1, 2) }
|
2013-07-09 21:40:21 +00:00
|
|
|
|
2013-08-27 18:02:40 +00:00
|
|
|
it 'returns a thumbnail of requested width' do
|
2013-09-10 19:29:17 +00:00
|
|
|
expect(thumbnail.width).to eq(1)
|
2013-08-25 18:49:23 +00:00
|
|
|
end
|
2013-07-25 16:02:58 +00:00
|
|
|
|
2013-08-27 18:02:40 +00:00
|
|
|
it 'returns a thumbnail of requested height' do
|
2013-09-10 19:29:17 +00:00
|
|
|
expect(thumbnail.height).to eq(2)
|
2013-07-25 16:02:58 +00:00
|
|
|
end
|
|
|
|
|
2013-08-27 18:02:40 +00:00
|
|
|
it 'crops the grid at the bottom left corner' do
|
2013-09-10 19:29:17 +00:00
|
|
|
expect(thumbnail.as_json).to eq([
|
|
|
|
[['a', fg: 3]],
|
|
|
|
[['a', fg: 5]]
|
|
|
|
])
|
2013-07-25 17:39:27 +00:00
|
|
|
end
|
2013-07-25 16:02:58 +00:00
|
|
|
end
|
2013-08-25 18:49:23 +00:00
|
|
|
|
2013-07-09 21:40:21 +00:00
|
|
|
end
|