engineyard-backup 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -7,8 +7,7 @@ A library to keep the latest X number of a file as backups
7
7
 
8
8
  == FEATURES/PROBLEMS:
9
9
 
10
- FIXME: The spec for checking it backs up the latest X files, passes no matter what
11
- FIXME: Make releases an instance variable, not a constant
10
+ None as yet.
12
11
 
13
12
  == SYNOPSIS:
14
13
 
@@ -19,7 +18,7 @@ FIXME: Make releases an instance variable, not a constant
19
18
 
20
19
  == REQUIREMENTS:
21
20
 
22
- None
21
+ mocha
23
22
 
24
23
  == INSTALL:
25
24
 
data/lib/backup/backup.rb CHANGED
@@ -5,7 +5,7 @@ module EngineYard
5
5
  attr_reader :filename, :backups
6
6
  attr_accessor :releases
7
7
 
8
- VERSION = "0.0.1"
8
+ VERSION = "0.0.2"
9
9
  TIMESTAMP = "%Y%m%d%H%M%S"
10
10
 
11
11
  # Pass in a filename, Backup will set the directory it works in from this file
@@ -14,34 +14,36 @@ describe Backup do
14
14
  it "should take 1 argument of a filename" do
15
15
  lambda { Backup.new }.should raise_error(ArgumentError)
16
16
  lambda { Backup.new("something") }.should raise_error("No such file found")
17
- File.should_receive(:file?).any_number_of_times.and_return(true)
17
+ File.expects(:file?).returns(true)
18
18
  lambda { Backup.new("something") }.should_not raise_error
19
19
  end
20
20
 
21
21
  describe "and passed a valid filename" do
22
22
  before(:each) do
23
- File.should_receive(:file?).any_number_of_times.and_return(true)
24
- Dir.stub!(:glob).and_return( valid_backups )
23
+ File.expects(:file?).at_least_once.returns(true)
24
+ Dir.stubs(:glob).returns( valid_backups )
25
25
  @backup = Backup.new("my.cnf")
26
26
  end
27
27
 
28
28
  it "should save a new file and delete all backups out of the threshold" do
29
- FileUtils.should_receive(:mv).exactly(1).times
30
- File.should_receive(:delete).with(/^my.cnf./).exactly(4).times.and_return(1)
29
+ FileUtils.expects(:mv).times(1)
30
+ valid_backups(9, :chronological).last(4).each do |backup|
31
+ File.expects(:delete).with(backup).returns(1)
32
+ end
31
33
  @backup.run
32
34
  end
33
35
 
34
36
  it "should not raise errors with zero current backups" do
35
- Dir.stub!(:glob).and_return( [] )
36
- FileUtils.should_receive(:mv).exactly(1).times
37
- File.should_receive(:delete).with(/^my.cnf./).exactly(0).times.and_return(1)
37
+ Dir.stubs(:glob).returns( [] )
38
+ FileUtils.expects(:mv)
39
+ File.expects(:delete).times(0).returns(1)
38
40
  @backup.run
39
41
  end
40
42
 
41
43
  describe "which returns a valid glob of files" do
42
44
 
43
45
  before(:each) do
44
- Dir.stub!(:glob).and_return( valid_backups )
46
+ Dir.stubs(:glob).returns( valid_backups )
45
47
  @backup = Backup.new("my.cnf")
46
48
  @backup.find_all_releases
47
49
  end
@@ -69,11 +71,8 @@ describe Backup do
69
71
 
70
72
  describe "which returns an invalid glob of files" do
71
73
 
72
- before(:each) do
73
- Dir.stub!(:glob).and_return( invalid_backups(3) )
74
- end
75
-
76
74
  it "should handle incorrectly named files gracefully" do
75
+ Dir.stubs(:glob).returns( invalid_backups(3) )
77
76
  lambda { Backup.new("my.cnf") }.should_not raise_error(ArgumentError)
78
77
  end
79
78
 
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,10 @@
1
- # $Id$
2
-
3
1
  Spec::Runner.configure do |config|
4
2
  # == Mock Framework
5
3
  #
6
4
  # RSpec uses it's own mocking framework by default. If you prefer to
7
5
  # use mocha, flexmock or RR, uncomment the appropriate line:
8
6
  #
9
- # config.mock_with :mocha
7
+ config.mock_with :mocha
10
8
  # config.mock_with :flexmock
11
9
  # config.mock_with :rr
12
- end
13
-
14
- # EOF
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie van Dyke
@@ -9,10 +9,18 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-01 00:00:00 -07:00
12
+ date: 2008-05-06 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mocha
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.5.6
23
+ version:
16
24
  description: Backup is a Ruby library to ease the backup of files, keeping the latest X releases. Just require it and go.
17
25
  email: jvandyke@engineyard.com
18
26
  executables: []
@@ -72,6 +80,6 @@ rubyforge_project:
72
80
  rubygems_version: 1.0.1
73
81
  signing_key:
74
82
  specification_version: 2
75
- summary: A library to keep the latest X number of a file as backups
83
+ summary: A library that allows you to backup a file from within your own code.
76
84
  test_files:
77
85
  - spec/backup/backup_spec.rb