Add a simple model representing a terminal snapshot

openid
Marcin Kulik 11 years ago
parent 8daf2d0f7f
commit e947524533

@ -0,0 +1,21 @@
class Snapshot
attr_reader :lines
def initialize(lines = [])
@lines = lines
end
def ==(other)
other.lines == lines
end
class Serializer
def dump(snapshot)
YAML.dump(snapshot.lines)
end
def load(value)
value.present? ? Snapshot.new(YAML.load(value)) : Snapshot.new
end
end
end

@ -0,0 +1,23 @@
require 'spec_helper'
describe Snapshot do
describe '#==' do
let(:snapshot) { Snapshot.new([:foo]) }
subject { snapshot == other }
context "when the other has the same lines" do
let(:other) { Snapshot.new([:foo]) }
it { should be(true) }
end
context "when the other has a different lines" do
let(:other) { Snapshot.new([:foo, :bar]) }
it { should be(false) }
end
end
end
Loading…
Cancel
Save