Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
71 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,78 @@ | ||
require 'gibbler' | ||
require 'gibbler/history' | ||
|
||
# "Setup Hash class", Hash do | ||
class ::Hash | ||
include Gibbler::History | ||
end | ||
end | ||
|
||
# "doesn't reveal self.__gibbler_history instance variable", false do | ||
a = {} | ||
a.gibbler # We need to gibbler first so it sets a value to the instance var | ||
val = Tryouts.sysinfo.ruby[1] == 9 ? :'self.__gibbler_history' : 'self.__gibbler_history' | ||
a.instance_variables.member? val | ||
end | ||
|
||
# "can take a Hash snapshot", 'd7049916ddb25e6cc438b1028fb957e5139f9910' do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
end | ||
|
||
#=> :class, Array | ||
#=> :size, 2 | ||
#=> ['d7049916ddb25e6cc438b1028fb957e5139f9910', 'b668098e16d08898532bf3aa33ce2253a3a4150e'] | ||
# "return a Hash history" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_commit | ||
a.gibbler_history | ||
end | ||
|
||
library :gibbler, File.dirname(__FILE__), '..', 'lib' | ||
library 'gibbler/history', File.dirname(__FILE__), '..', 'lib' | ||
# "can revert Hash" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_revert! | ||
#=> 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
|
||
group "History" | ||
# "knows a valid gibble", true do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a.gibbler_valid? 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
#=> true | ||
|
||
Gibbler.enable_debug if Tryouts.verbose > 3 | ||
# "knows an invalid gibble", false do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a.gibbler_valid? '2222222222222222222222222222222222222222' | ||
#=> false | ||
|
||
# "can revert to any valid gibble" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_commit | ||
a[:magic] = :changed | ||
a.gibbler_commit | ||
a.gibbler_revert! 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
a | ||
#=> Hash[:magic => :original] | ||
|
||
tryouts "Hash History" do | ||
|
||
drill "Setup Hash class", Hash do | ||
class ::Hash | ||
include Gibbler::History | ||
end | ||
end | ||
|
||
drill "doesn't reveal self.__gibbler_history instance variable", false do | ||
a = {} | ||
a.gibbler # We need to gibbler first so it sets a value to the instance var | ||
val = Tryouts.sysinfo.ruby[1] == 9 ? :'self.__gibbler_history' : 'self.__gibbler_history' | ||
a.instance_variables.member? val | ||
end | ||
|
||
drill "can take a Hash snapshot", 'd7049916ddb25e6cc438b1028fb957e5139f9910' do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
end | ||
|
||
dream :class, Array | ||
dream :size, 2 | ||
dream ['d7049916ddb25e6cc438b1028fb957e5139f9910', 'b668098e16d08898532bf3aa33ce2253a3a4150e'] | ||
drill "return a Hash history" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_commit | ||
a.gibbler_history | ||
end | ||
|
||
dream 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
drill "can revert Hash" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_revert! | ||
end | ||
|
||
drill "knows a valid gibble", true do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a.gibbler_valid? 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
end | ||
|
||
drill "knows an invalid gibble", false do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a.gibbler_valid? '2222222222222222222222222222222222222222' | ||
end | ||
|
||
dream Hash[:magic => :original] | ||
drill "can revert to any valid gibble" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_commit | ||
a[:magic] = :changed | ||
a.gibbler_commit | ||
a.gibbler_revert! 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
a | ||
end | ||
|
||
dream Hash[:magic => :original] | ||
dream :gibbler, 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
drill "revert does nothing if digest is the same as current one" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a.gibbler_revert! | ||
a | ||
end | ||
|
||
dream 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
drill "can revert using short gibble" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_revert! 'd7049916' | ||
end | ||
|
||
#=> Hash[:magic => :original] | ||
#=> :gibbler, 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
# "revert does nothing if digest is the same as current one" do | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a.gibbler_revert! | ||
a | ||
end | ||
|
||
# "can revert using short gibble | ||
a = { :magic => :original } | ||
a.gibbler_commit | ||
a[:magic] = :updated | ||
a.gibbler_revert! 'd7049916' | ||
#=> 'd7049916ddb25e6cc438b1028fb957e5139f9910' | ||
|