Sha256: e412548bd28be8e0653446491e47423bdccb3566d4eea6fd1105272272023fca
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
require File.expand_path('spec/spec_helper') describe Ruco::History do let(:history){ Ruco::History.new(:state => {:x => 1}, :track => [:x], :entries => 3) } it "knows its state" do history.state.should == {:x => 1} end it "can add a state" do history.add :x => 2 history.state.should == {:x => 2} end it "can undo a state" do history.add :x => 2 history.undo history.state.should == {:x => 1} end it "can undo-redo-undo a state" do history.add :x => 2 history.undo history.redo history.state.should == {:x => 2} end it "cannot redo a modified stack" do history.add :x => 2 history.undo history.add :x => 3 history.redo history.state.should == {:x => 3} history.redo history.state.should == {:x => 3} end it "cannot undo into nirvana" do history.add :x => 2 history.undo history.undo history.state.should == {:x => 1} end it "cannot redo into nirvana" do history.add :x => 2 history.redo history.state.should == {:x => 2} end it "cannot undo unimportant changes" do history.add(:x => 1, :y => 1) history.undo history.state.should == {:x => 1} end it "tracks unimportant fields when an important one changes" do history.add(:x => 2, :y => 1) history.add(:x => 3) history.undo history.state.should == {:x => 2, :y => 1} history.undo history.state.should == {:x => 1} end it "does not track more than x states" do history.add(:x => 2) history.add(:x => 3) history.add(:x => 4) history.add(:x => 5) history.undo history.undo history.undo history.undo history.state.should == {:x => 3} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.34 | spec/ruco/history_spec.rb |
ruco-0.0.33 | spec/ruco/history_spec.rb |