Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'rspec3'
Browse files Browse the repository at this point in the history
  • Loading branch information
dickeyxxx committed Aug 14, 2014
2 parents 8aadb36 + 19a8a1b commit 6b417c5
Show file tree
Hide file tree
Showing 43 changed files with 958 additions and 953 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ rvm:
- 2.0.0
- 2.1.2

script: bundle exec rspec -bfs spec
script: bundle exec rspec spec --color --format documentation
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ group :test do
gem "fakefs"
gem "jruby-openssl", :platform => :jruby
gem "json"
gem "rspec", ">= 2.0"
gem "rspec"
gem "sqlite3"
gem "webmock"
gem "coveralls", :require => false
Expand Down
36 changes: 21 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.2)
addressable (2.3.6)
arr-pm (0.0.7)
cabin (> 0)
aws-s3 (0.6.3)
Expand All @@ -29,8 +29,9 @@ GEM
simplecov (>= 0.7)
term-ansicolor
thor
crack (0.3.2)
diff-lcs (1.1.3)
crack (0.4.2)
safe_yaml (~> 1.0.0)
diff-lcs (1.2.5)
docile (1.1.5)
excon (0.39.4)
fakefs (0.4.2)
Expand All @@ -53,15 +54,20 @@ GEM
rest-client (1.6.7)
mime-types (>= 1.16)
rr (1.0.4)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.2)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.4)
rspec-support (~> 3.0.0)
rspec-support (3.0.4)
rubyzip (0.9.9)
safe_yaml (1.0.3)
simplecov (0.9.0)
docile (~> 1.1.0)
multi_json
Expand All @@ -73,9 +79,9 @@ GEM
tins (~> 1.0)
thor (0.19.1)
tins (1.3.1)
webmock (1.9.0)
addressable (>= 2.2.7)
crack (>= 0.1.7)
webmock (1.18.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
xml-simple (1.1.2)

PLATFORMS
Expand All @@ -92,7 +98,7 @@ DEPENDENCIES
json
rake (>= 0.8.7)
rr (~> 1.0.2)
rspec (>= 2.0)
rspec
rubyzip
sqlite3
webmock
34 changes: 17 additions & 17 deletions spec/helper/pg_dump_restore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@
end

it 'requires uris for from and to arguments' do
expect { PgDumpRestore.new(nil , @localdb, mock) }.to raise_error
expect { PgDumpRestore.new(@remotedb, nil , mock) }.to raise_error
expect { PgDumpRestore.new(@remotedb, @localdb, mock) }.to_not raise_error
expect { PgDumpRestore.new(nil , @localdb, double) }.to raise_error
expect { PgDumpRestore.new(@remotedb, nil , double) }.to raise_error
expect { PgDumpRestore.new(@remotedb, @localdb, double) }.to_not raise_error
end

it 'uses PGPORT from ENV to set local port' do
ENV['PGPORT'] = '15432'
expect(PgDumpRestore.new(@remotedb, @localdb, mock).instance_variable_get('@target').port).to eq 15432
expect(PgDumpRestore.new(@remotedb, @localdb, double).instance_variable_get('@target').port).to eq 15432
end

it 'on pulls, prepare requires the local database to not exist' do
mock_command = mock
mock_command.should_receive(:error).once
mock_command = double
expect(mock_command).to receive(:error).once
pgdr = PgDumpRestore.new(@remotedb, @localdb, mock_command)
pgdr.should_receive(:`).once.and_return(`false`)
expect(pgdr).to receive(:`).once.and_return(`false`)

pgdr.prepare
end

it 'on pushes, prepare requires the remote database to be empty' do
mock_command = mock
mock_command.should_receive(:error).once
mock_command = double
expect(mock_command).to receive(:error).once
pgdr = PgDumpRestore.new(@localdb, @remotedb, mock_command)
mock_command.should_receive(:exec_sql_on_uri).once.and_return("something that isn't a true")
expect(mock_command).to receive(:exec_sql_on_uri).once.and_return("something that isn't a true")
pgdr.prepare
end

it 'executes a proper dump/restore command' do
pgdr = PgDumpRestore.new(@remotedb, @localdb, mock)
pgdr = PgDumpRestore.new(@remotedb, @localdb, double)
expect(pgdr.dump_restore_cmd).to match(/
pg_dump .*
remotehost .*
Expand All @@ -49,18 +49,18 @@

describe 'verification' do
it 'errors when the extensions do not match' do
mock_command = mock
mock_command.should_receive(:error).once
mock_command = double
expect(mock_command).to receive(:error).once
pgdr = PgDumpRestore.new(@localdb, @remotedb, mock_command)
mock_command.should_receive(:exec_sql_on_uri).twice.and_return("these", "don't match")
expect(mock_command).to receive(:exec_sql_on_uri).twice.and_return("these", "don't match")
pgdr.verify
end

it 'is fine when the extensions match' do
mock_command = mock
mock_command.should_not_receive(:error)
mock_command = double
expect(mock_command).not_to receive(:error)
pgdr = PgDumpRestore.new(@localdb, @remotedb, mock_command)
mock_command.should_receive(:exec_sql_on_uri).twice.and_return("these match", "these match")
expect(mock_command).to receive(:exec_sql_on_uri).twice.and_return("these match", "these match")
pgdr.verify
end
end
Expand Down
Loading

0 comments on commit 6b417c5

Please sign in to comment.