mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
upgrade to rspec 3.
This commit is contained in:
parent
aa7ac5c753
commit
467ab08e35
13 changed files with 76 additions and 127 deletions
2
.rspec
2
.rspec
|
@ -1,4 +1,2 @@
|
|||
--color
|
||||
--format documentation
|
||||
mtime
|
||||
--backtrace
|
||||
|
|
94
Gemfile.lock
94
Gemfile.lock
|
@ -6,17 +6,6 @@ PATH
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
abstract (1.0.0)
|
||||
actionpack (3.0.0)
|
||||
activemodel (= 3.0.0)
|
||||
activesupport (= 3.0.0)
|
||||
builder (~> 2.1.2)
|
||||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.4.1)
|
||||
rack (~> 1.2.1)
|
||||
rack-mount (~> 0.6.12)
|
||||
rack-test (~> 0.5.4)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.0)
|
||||
activesupport (= 3.0.0)
|
||||
builder (~> 2.1.2)
|
||||
|
@ -43,7 +32,6 @@ GEM
|
|||
bson_ext (1.12.5)
|
||||
bson (~> 1.12.5)
|
||||
builder (2.1.2)
|
||||
coderay (1.1.0)
|
||||
couch_potato (1.3.0)
|
||||
activemodel
|
||||
couchrest (~> 1.2.0)
|
||||
|
@ -69,7 +57,7 @@ GEM
|
|||
dm-transactions (~> 1.2.0)
|
||||
dm-types (~> 1.2.0)
|
||||
dm-validations (~> 1.2.0)
|
||||
diff-lcs (1.2.5)
|
||||
diff-lcs (1.3)
|
||||
dm-aggregates (1.2.0)
|
||||
dm-core (~> 1.2.0)
|
||||
dm-constraints (1.2.0)
|
||||
|
@ -112,29 +100,15 @@ GEM
|
|||
data_objects (= 0.10.14)
|
||||
do_jdbc (= 0.10.14)
|
||||
jdbc-sqlite3 (>= 3.5.8)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
faraday (0.9.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday_middleware (0.9.1)
|
||||
faraday (>= 0.7.4, < 0.10)
|
||||
fastercsv (1.5.5)
|
||||
ffi (1.9.6)
|
||||
ffi (1.9.6-java)
|
||||
formatador (0.2.5)
|
||||
gherkin (2.11.6)
|
||||
json (>= 1.7.6)
|
||||
gherkin (2.11.6-java)
|
||||
json (>= 1.7.6)
|
||||
guard (1.8.3)
|
||||
formatador (>= 0.2.4)
|
||||
listen (~> 1.3)
|
||||
lumberjack (>= 1.0.2)
|
||||
pry (>= 0.9.10)
|
||||
thor (>= 0.14.6)
|
||||
guard-rspec (2.5.4)
|
||||
guard (>= 1.1)
|
||||
rspec (~> 2.11)
|
||||
httparty (0.13.3)
|
||||
json (~> 1.8)
|
||||
multi_xml (>= 0.5.2)
|
||||
|
@ -144,12 +118,6 @@ GEM
|
|||
json (1.8.6)
|
||||
json (1.8.6-java)
|
||||
json_pure (1.8.1)
|
||||
listen (1.3.1)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
rb-kqueue (>= 0.2)
|
||||
lumberjack (1.0.9)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mongo (1.12.5)
|
||||
bson (= 1.12.5)
|
||||
|
@ -191,60 +159,29 @@ GEM
|
|||
pg (0.18.2)
|
||||
plucky (0.5.2)
|
||||
mongo (~> 1.5)
|
||||
pry (0.10.1)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
pry (0.10.1-java)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
spoon (~> 0.0)
|
||||
rack (1.2.8)
|
||||
rack-mount (0.6.14)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (0.5.7)
|
||||
rack (>= 1.0)
|
||||
railties (3.0.0)
|
||||
actionpack (= 3.0.0)
|
||||
activesupport (= 3.0.0)
|
||||
rake (>= 0.8.4)
|
||||
thor (~> 0.14.0)
|
||||
rake (11.1.2)
|
||||
rb-fsevent (0.9.4)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
rb-kqueue (0.2.3)
|
||||
ffi (>= 0.5.0)
|
||||
rdoc (4.1.2)
|
||||
json (~> 1.4)
|
||||
redis (3.1.0)
|
||||
rest-client (1.6.8)
|
||||
mime-types (~> 1.16)
|
||||
rdoc (>= 2.4.2)
|
||||
rspec (2.14.1)
|
||||
rspec-core (~> 2.14.0)
|
||||
rspec-expectations (~> 2.14.0)
|
||||
rspec-mocks (~> 2.14.0)
|
||||
rspec-core (2.14.8)
|
||||
rspec-expectations (2.14.5)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.14.6)
|
||||
rspec-rails (2.14.2)
|
||||
actionpack (>= 3.0)
|
||||
activemodel (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 2.14.0)
|
||||
rspec-expectations (~> 2.14.0)
|
||||
rspec-mocks (~> 2.14.0)
|
||||
rspec (3.7.0)
|
||||
rspec-core (~> 3.7.0)
|
||||
rspec-expectations (~> 3.7.0)
|
||||
rspec-mocks (~> 3.7.0)
|
||||
rspec-core (3.7.1)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-expectations (3.7.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-mocks (3.7.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.1)
|
||||
sequel (3.21.0)
|
||||
slop (3.6.0)
|
||||
spoon (0.0.4)
|
||||
ffi
|
||||
sqlite3 (1.3.10)
|
||||
stringex (1.5.1)
|
||||
thor (0.14.6)
|
||||
tzinfo (0.3.48)
|
||||
uuidtools (2.1.5)
|
||||
zip (2.0.2)
|
||||
|
@ -264,7 +201,6 @@ DEPENDENCIES
|
|||
datamapper
|
||||
dm-migrations
|
||||
dm-sqlite-adapter
|
||||
guard-rspec
|
||||
json_pure
|
||||
mongo (~> 1.12.0)
|
||||
mongo_ext
|
||||
|
@ -278,7 +214,7 @@ DEPENDENCIES
|
|||
ohm (~> 0.1.3)
|
||||
pg
|
||||
rake
|
||||
rspec-rails (~> 2.14.2)
|
||||
rspec
|
||||
sequel (~> 3.21.0)
|
||||
sqlite3
|
||||
tzinfo
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# A sample Guardfile
|
||||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
guard 'rspec', :version => 2 do
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||
watch('spec/spec_helper.rb') { "spec" }
|
||||
end
|
||||
|
|
@ -51,8 +51,7 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency "couch_potato"
|
||||
s.add_development_dependency "sequel", "~> 3.21.0"
|
||||
s.add_development_dependency 'ohm', '~> 0.1.3'
|
||||
s.add_development_dependency 'guard-rspec'
|
||||
s.add_development_dependency "rspec-rails", "~> 2.14.2"
|
||||
s.add_development_dependency "rspec"
|
||||
s.add_development_dependency "cucumber"
|
||||
|
||||
unless RUBY_PLATFORM =~ /java/
|
||||
|
|
|
@ -172,8 +172,7 @@ my_db:
|
|||
end
|
||||
|
||||
context "when connection_hash is set" do
|
||||
let(:hash) { double("hash") }
|
||||
before { ::ActiveRecord::Base.stub(:respond_to?).and_return(false) }
|
||||
let(:hash) { {} }
|
||||
before { subject.stub(:connection_hash).and_return(hash) }
|
||||
|
||||
it "establish a connection using ActiveRecord::Base" do
|
||||
|
|
|
@ -163,11 +163,11 @@ module DatabaseCleaner
|
|||
describe "#connection_maintains_transaction_count?" do
|
||||
it "should return true if the major active record version is < 4" do
|
||||
stub_const("ActiveRecord::VERSION::MAJOR", 3)
|
||||
Transaction.new.connection_maintains_transaction_count?.should be_true
|
||||
Transaction.new.connection_maintains_transaction_count?.should be_truthy
|
||||
end
|
||||
it "should return false if the major active record version is > 3" do
|
||||
stub_const("ActiveRecord::VERSION::MAJOR", 4)
|
||||
Transaction.new.connection_maintains_transaction_count?.should be_false
|
||||
Transaction.new.connection_maintains_transaction_count?.should be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -142,7 +142,10 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
subject { Truncation.new }
|
||||
its(:pre_count?) { should eq false }
|
||||
|
||||
it 'should return false initially' do
|
||||
subject.send(:pre_count?).should eq false
|
||||
end
|
||||
|
||||
it 'should return true if @reset_id is set and non false or nil' do
|
||||
subject.instance_variable_set(:"@pre_count", true)
|
||||
|
@ -163,9 +166,12 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
subject { Truncation.new }
|
||||
its(:reset_ids?) { should eq true }
|
||||
|
||||
it 'should return true if @reset_id is set and non false or nil' do
|
||||
it 'should return true initially' do
|
||||
subject.send(:reset_ids?).should eq true
|
||||
end
|
||||
|
||||
it 'should return true if @reset_id is set and non falsey' do
|
||||
subject.instance_variable_set(:"@reset_ids", 'Something')
|
||||
subject.send(:reset_ids?).should eq true
|
||||
end
|
||||
|
|
|
@ -508,12 +508,12 @@ module DatabaseCleaner
|
|||
describe "auto_detected?" do
|
||||
it "should return true unless @autodetected is nil" do
|
||||
subject.instance_variable_set("@autodetected","not nil")
|
||||
subject.auto_detected?.should be_true
|
||||
subject.auto_detected?.should be_truthy
|
||||
end
|
||||
|
||||
it "should return false if @autodetect is nil" do
|
||||
subject.instance_variable_set("@autodetected",nil)
|
||||
subject.auto_detected?.should be_false
|
||||
subject.auto_detected?.should be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ module ::DatabaseCleaner
|
|||
end
|
||||
|
||||
it { should_not respond_to(:migration_storage_names) }
|
||||
its(:migration_storage_names) { should be_empty }
|
||||
end
|
||||
|
||||
describe "initialize" do
|
||||
|
@ -67,40 +66,40 @@ module ::DatabaseCleaner
|
|||
|
||||
context "" do
|
||||
subject { TruncationExample.new( { :only => ["something"] } ) }
|
||||
its(:only) { should eq ["something"] }
|
||||
its(:except) { should eq [] }
|
||||
it { subject.only.should eq ["something"] }
|
||||
it { subject.except.should eq [] }
|
||||
end
|
||||
|
||||
context "" do
|
||||
subject { TruncationExample.new( { :except => ["something"] } ) }
|
||||
its(:only) { should eq nil }
|
||||
its(:except) { should include("something") }
|
||||
it { subject.only.should eq nil }
|
||||
it { subject.except.should include("something") }
|
||||
end
|
||||
|
||||
context "" do
|
||||
subject { TruncationExample.new( { :reset_ids => ["something"] } ) }
|
||||
its(:reset_ids?) { should eq true }
|
||||
it { subject.reset_ids?.should eq true }
|
||||
end
|
||||
|
||||
context "" do
|
||||
subject { TruncationExample.new( { :reset_ids => nil } ) }
|
||||
its(:reset_ids?) { should eq false }
|
||||
it { subject.reset_ids?.should eq false }
|
||||
end
|
||||
|
||||
context "" do
|
||||
subject { TruncationExample.new( { :pre_count => ["something"] } ) }
|
||||
its(:pre_count?) { should eq true }
|
||||
it { subject.pre_count?.should eq true }
|
||||
end
|
||||
|
||||
context "" do
|
||||
subject { TruncationExample.new( { :pre_count => nil } ) }
|
||||
its(:pre_count?) { should eq false }
|
||||
it { subject.pre_count?.should eq false }
|
||||
end
|
||||
|
||||
context "" do
|
||||
subject { MigrationExample.new }
|
||||
its(:only) { should eq nil }
|
||||
its(:except) { should eq %w[migration_storage_name] }
|
||||
it { subject.only.should eq nil }
|
||||
it { subject.except.should eq %w[migration_storage_name] }
|
||||
end
|
||||
|
||||
context "" do
|
||||
|
|
|
@ -24,9 +24,10 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
it "should default to :default" do
|
||||
pending "I figure out how to use Sequel and write some real tests for it..."
|
||||
subject.db.should eq :default
|
||||
end
|
||||
|
||||
pending "I figure out how to use Sequel and write some real tests for it..."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,9 +34,9 @@ module DatabaseCleaner
|
|||
d.db = db
|
||||
d.clean
|
||||
|
||||
expect(db[:replaceable_trifles]).to have(0).rows
|
||||
expect(db[:worthless_junk]).to have(0).rows
|
||||
expect(db[:precious_stones]).to have(0).rows
|
||||
expect(db[:replaceable_trifles]).to be_empty
|
||||
expect(db[:worthless_junk]).to be_empty
|
||||
expect(db[:precious_stones]).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,9 +38,9 @@ module DatabaseCleaner
|
|||
t.db = db
|
||||
t.clean
|
||||
|
||||
expect(db[:replaceable_trifles]).to have(0).rows
|
||||
expect(db[:worthless_junk]).to have(0).rows
|
||||
expect(db[:precious_stones]).to have(0).rows
|
||||
expect(db[:replaceable_trifles]).to be_empty
|
||||
expect(db[:worthless_junk]).to be_empty
|
||||
expect(db[:precious_stones]).to be_empty
|
||||
end
|
||||
end
|
||||
context 'when the Truncation is restricted to "only: [...]" some tables' do
|
||||
|
@ -49,9 +49,9 @@ module DatabaseCleaner
|
|||
t.db = db
|
||||
t.clean
|
||||
|
||||
expect(db[:replaceable_trifles]).to have(0).rows
|
||||
expect(db[:worthless_junk]).to have(0).rows
|
||||
expect(db[:precious_stones]).to have(1).rows
|
||||
expect(db[:replaceable_trifles]).to be_empty
|
||||
expect(db[:worthless_junk]).to be_empty
|
||||
expect(db[:precious_stones].count).to eq(1)
|
||||
end
|
||||
end
|
||||
context 'when the Truncation is restricted to "except: [...]" some tables' do
|
||||
|
@ -62,7 +62,7 @@ module DatabaseCleaner
|
|||
|
||||
expect(db[:replaceable_trifles]).to be_empty
|
||||
expect(db[:worthless_junk]).to be_empty
|
||||
expect(db[:precious_stones]).to have(1).item
|
||||
expect(db[:precious_stones].count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -70,6 +70,7 @@ module DatabaseCleaner
|
|||
|
||||
shared_examples_for 'a truncation strategy without autoincrement resets' do
|
||||
it "leaves AUTO_INCREMENT index alone by default (BUG: it should be reset instead)" do
|
||||
pending
|
||||
# Jordan Hollinger made everything reset auto increment IDs
|
||||
# in commit 6a0104382647e5c06578aeac586c0333c8944492 so I'm pretty sure
|
||||
# everything is meant to reset by default.
|
||||
|
@ -84,9 +85,7 @@ module DatabaseCleaner
|
|||
truncation.clean
|
||||
|
||||
id_after_clean = table.insert
|
||||
pending('the bug being fixed') do
|
||||
expect(id_after_clean).to eq 1
|
||||
end
|
||||
expect(id_after_clean).to eq 1
|
||||
end
|
||||
# XXX: it'd be really nice if Truncation accepted db: constructor parameter
|
||||
let(:truncation) do
|
||||
|
@ -134,7 +133,9 @@ module DatabaseCleaner
|
|||
describe '#pre_count?' do
|
||||
subject { Truncation.new.tap { |t| t.db = db } }
|
||||
|
||||
its(:pre_count?) { should eq false }
|
||||
it 'should return false initially' do
|
||||
subject.send(:pre_count?).should eq false
|
||||
end
|
||||
|
||||
it 'should return true if @reset_id is set and non false or nil' do
|
||||
subject.instance_variable_set(:"@pre_count", true)
|
||||
|
|
|
@ -15,7 +15,26 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
|
|||
require 'database_cleaner'
|
||||
|
||||
RSpec.configure do |config|
|
||||
# These two settings work together to allow you to limit a spec run
|
||||
# to individual examples or groups you care about by tagging them with
|
||||
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
||||
# get run.
|
||||
config.filter_run :focus
|
||||
config.run_all_when_everything_filtered = true
|
||||
|
||||
config.expect_with :rspec do |expectations|
|
||||
# Enable only the newer, non-monkey-patching expect syntax.
|
||||
# For more details, see:
|
||||
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
||||
expectations.syntax = [:should, :expect]
|
||||
end
|
||||
|
||||
config.mock_with :rspec do |mocks|
|
||||
# Enable only the newer, non-monkey-patching expect syntax.
|
||||
# For more details, see:
|
||||
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
||||
mocks.syntax = [:should, :expect]
|
||||
end
|
||||
end
|
||||
|
||||
alias running lambda
|
||||
|
|
Loading…
Reference in a new issue