Created
August 15, 2011 06:55
-
-
Save elcontrastador/1145821 to your computer and use it in GitHub Desktop.
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
Feature: The Backup Extension | |
When a backup runs, files that require backing up are copied from the working | |
share to a 'retain' share with a new unique extension appended. It is | |
necessary for the file to be renamed during the copy to ensure the file is: | |
* unique so it will not overwrite the existing files or prior version of self | |
* easily associated with the original and prior backup files | |
* not dependant on the filesystem mtime/ctime for determining its creation | |
date and time | |
* capable of being subsequently parsed back into a ruby Time obj with same | |
precision as the respective extension (1 min) | |
Scenario Outline: Determine file extension from date | |
Given a date and time of "<datetime>" | |
Then the extension should be "<extension>" | |
Examples: | |
| datetime | extension | | |
| 2011-08-14 16:30:57 -0700 | .bak_2011_08_14_1630 | | |
| 2011-08-12 08:15:01 -0700 | .bak_2011_08_12_0815 | | |
| 2011-08-12 00:00:01 -0700 | .bak_2011_08_12_0000 | | |
Scenario Outline: Determine a creation time from the special extension | |
Given a backup file "<extension>" | |
Then we should return a ruby Time object | |
And its "<time>" should be accurate to the same minute of the extension | |
Examples: | |
| extension | time | | |
| .bak_2011_08_14_1630 | 2011-08-14 16:30:00 -0700 | | |
Scenario Outline: Determine if an extension is older than a given Time obj | |
Given a backup file <extension> | |
When compared against the "<comparetime>" of a Time object | |
Then we should determine whether we are "<older>" | |
But return nil if exactly the same age | |
Examples: | |
| extension | comparetime | older | | |
| .bak_2011_08_14_1630 | 2011-08-14 16:30:00 -0700 | nil | | |
| .bak_2011_08_14_1630 | 2011-08-12 12:30:00 -0700 | false | | |
| .bak_2011_08_14_1630 | 2011-08-15 12:30:00 -0700 | true | | |
#### BEGIN STEP DEFS ##### | |
Given /^a date and time of "([^\"]*)"$/ do |time_string| | |
@time = Time.parse(time_string) | |
end | |
Then /^the extension should be "([^\"]*)"$/ do |extension| | |
bext = Backup::Extension.new(@time) | |
bext.extension.should == extension | |
end | |
Given /^a backup file "([^\"]*)"$/ do |ext| | |
@bext = Backup::Extension.new(ext) | |
end | |
Then /^we should return a ruby Time object$/ do | |
@bext.time.should be_an_instance_of Time | |
end | |
Then /^its "([^\"]*)" should be accurate to the same minute of the extension$/ do |time| | |
@bext.time.to_s.should == time.sub(/:\d\d\s/,':00 ').to_s | |
end | |
Given /^a backup file (\.\w+)$/ do |extension| | |
@bext = Backup::Extension.new(extension) | |
end | |
When /^compared against the "([^\"]*)" of a Time object$/ do |comparetime| | |
@older = @bext.older_than_this?(Time.parse(comparetime)) | |
end | |
Then /^we should determine whether we are "(\w+)"$/ do |answer| | |
bool = case answer | |
when "true" then true | |
when "false" then false | |
when "nil" then nil | |
end | |
@older.should == bool | |
end | |
Then /^return nil if exactly the same age$/ do | |
true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment