upgrade to rspec 3.

This commit is contained in:
Micah Geisel 2018-04-26 09:29:13 -07:00
parent aa7ac5c753
commit 467ab08e35
13 changed files with 76 additions and 127 deletions

2
.rspec
View file

@ -1,4 +1,2 @@
--color --color
--format documentation --format documentation
mtime
--backtrace

View file

@ -6,17 +6,6 @@ PATH
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: 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) activemodel (3.0.0)
activesupport (= 3.0.0) activesupport (= 3.0.0)
builder (~> 2.1.2) builder (~> 2.1.2)
@ -43,7 +32,6 @@ GEM
bson_ext (1.12.5) bson_ext (1.12.5)
bson (~> 1.12.5) bson (~> 1.12.5)
builder (2.1.2) builder (2.1.2)
coderay (1.1.0)
couch_potato (1.3.0) couch_potato (1.3.0)
activemodel activemodel
couchrest (~> 1.2.0) couchrest (~> 1.2.0)
@ -69,7 +57,7 @@ GEM
dm-transactions (~> 1.2.0) dm-transactions (~> 1.2.0)
dm-types (~> 1.2.0) dm-types (~> 1.2.0)
dm-validations (~> 1.2.0) dm-validations (~> 1.2.0)
diff-lcs (1.2.5) diff-lcs (1.3)
dm-aggregates (1.2.0) dm-aggregates (1.2.0)
dm-core (~> 1.2.0) dm-core (~> 1.2.0)
dm-constraints (1.2.0) dm-constraints (1.2.0)
@ -112,29 +100,15 @@ GEM
data_objects (= 0.10.14) data_objects (= 0.10.14)
do_jdbc (= 0.10.14) do_jdbc (= 0.10.14)
jdbc-sqlite3 (>= 3.5.8) jdbc-sqlite3 (>= 3.5.8)
erubis (2.6.6)
abstract (>= 1.0.0)
faraday (0.9.0) faraday (0.9.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1) faraday_middleware (0.9.1)
faraday (>= 0.7.4, < 0.10) faraday (>= 0.7.4, < 0.10)
fastercsv (1.5.5) fastercsv (1.5.5)
ffi (1.9.6)
ffi (1.9.6-java)
formatador (0.2.5)
gherkin (2.11.6) gherkin (2.11.6)
json (>= 1.7.6) json (>= 1.7.6)
gherkin (2.11.6-java) gherkin (2.11.6-java)
json (>= 1.7.6) 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) httparty (0.13.3)
json (~> 1.8) json (~> 1.8)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
@ -144,12 +118,6 @@ GEM
json (1.8.6) json (1.8.6)
json (1.8.6-java) json (1.8.6-java)
json_pure (1.8.1) 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) mime-types (1.25.1)
mongo (1.12.5) mongo (1.12.5)
bson (= 1.12.5) bson (= 1.12.5)
@ -191,60 +159,29 @@ GEM
pg (0.18.2) pg (0.18.2)
plucky (0.5.2) plucky (0.5.2)
mongo (~> 1.5) 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) 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) rdoc (4.1.2)
json (~> 1.4) json (~> 1.4)
redis (3.1.0) redis (3.1.0)
rest-client (1.6.8) rest-client (1.6.8)
mime-types (~> 1.16) mime-types (~> 1.16)
rdoc (>= 2.4.2) rdoc (>= 2.4.2)
rspec (2.14.1) rspec (3.7.0)
rspec-core (~> 2.14.0) rspec-core (~> 3.7.0)
rspec-expectations (~> 2.14.0) rspec-expectations (~> 3.7.0)
rspec-mocks (~> 2.14.0) rspec-mocks (~> 3.7.0)
rspec-core (2.14.8) rspec-core (3.7.1)
rspec-expectations (2.14.5) rspec-support (~> 3.7.0)
diff-lcs (>= 1.1.3, < 2.0) rspec-expectations (3.7.0)
rspec-mocks (2.14.6) diff-lcs (>= 1.2.0, < 2.0)
rspec-rails (2.14.2) rspec-support (~> 3.7.0)
actionpack (>= 3.0) rspec-mocks (3.7.0)
activemodel (>= 3.0) diff-lcs (>= 1.2.0, < 2.0)
activesupport (>= 3.0) rspec-support (~> 3.7.0)
railties (>= 3.0) rspec-support (3.7.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sequel (3.21.0) sequel (3.21.0)
slop (3.6.0)
spoon (0.0.4)
ffi
sqlite3 (1.3.10) sqlite3 (1.3.10)
stringex (1.5.1) stringex (1.5.1)
thor (0.14.6)
tzinfo (0.3.48) tzinfo (0.3.48)
uuidtools (2.1.5) uuidtools (2.1.5)
zip (2.0.2) zip (2.0.2)
@ -264,7 +201,6 @@ DEPENDENCIES
datamapper datamapper
dm-migrations dm-migrations
dm-sqlite-adapter dm-sqlite-adapter
guard-rspec
json_pure json_pure
mongo (~> 1.12.0) mongo (~> 1.12.0)
mongo_ext mongo_ext
@ -278,7 +214,7 @@ DEPENDENCIES
ohm (~> 0.1.3) ohm (~> 0.1.3)
pg pg
rake rake
rspec-rails (~> 2.14.2) rspec
sequel (~> 3.21.0) sequel (~> 3.21.0)
sqlite3 sqlite3
tzinfo tzinfo

View file

@ -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

View file

@ -51,8 +51,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "couch_potato" s.add_development_dependency "couch_potato"
s.add_development_dependency "sequel", "~> 3.21.0" s.add_development_dependency "sequel", "~> 3.21.0"
s.add_development_dependency 'ohm', '~> 0.1.3' s.add_development_dependency 'ohm', '~> 0.1.3'
s.add_development_dependency 'guard-rspec' s.add_development_dependency "rspec"
s.add_development_dependency "rspec-rails", "~> 2.14.2"
s.add_development_dependency "cucumber" s.add_development_dependency "cucumber"
unless RUBY_PLATFORM =~ /java/ unless RUBY_PLATFORM =~ /java/

View file

@ -172,8 +172,7 @@ my_db:
end end
context "when connection_hash is set" do context "when connection_hash is set" do
let(:hash) { double("hash") } let(:hash) { {} }
before { ::ActiveRecord::Base.stub(:respond_to?).and_return(false) }
before { subject.stub(:connection_hash).and_return(hash) } before { subject.stub(:connection_hash).and_return(hash) }
it "establish a connection using ActiveRecord::Base" do it "establish a connection using ActiveRecord::Base" do

View file

@ -163,11 +163,11 @@ module DatabaseCleaner
describe "#connection_maintains_transaction_count?" do describe "#connection_maintains_transaction_count?" do
it "should return true if the major active record version is < 4" do it "should return true if the major active record version is < 4" do
stub_const("ActiveRecord::VERSION::MAJOR", 3) 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 end
it "should return false if the major active record version is > 3" do it "should return false if the major active record version is > 3" do
stub_const("ActiveRecord::VERSION::MAJOR", 4) 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
end end

View file

@ -142,7 +142,10 @@ module DatabaseCleaner
end end
subject { Truncation.new } 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 it 'should return true if @reset_id is set and non false or nil' do
subject.instance_variable_set(:"@pre_count", true) subject.instance_variable_set(:"@pre_count", true)
@ -163,9 +166,12 @@ module DatabaseCleaner
end end
subject { Truncation.new } 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.instance_variable_set(:"@reset_ids", 'Something')
subject.send(:reset_ids?).should eq true subject.send(:reset_ids?).should eq true
end end

View file

@ -508,12 +508,12 @@ module DatabaseCleaner
describe "auto_detected?" do describe "auto_detected?" do
it "should return true unless @autodetected is nil" do it "should return true unless @autodetected is nil" do
subject.instance_variable_set("@autodetected","not nil") subject.instance_variable_set("@autodetected","not nil")
subject.auto_detected?.should be_true subject.auto_detected?.should be_truthy
end end
it "should return false if @autodetect is nil" do it "should return false if @autodetect is nil" do
subject.instance_variable_set("@autodetected",nil) subject.instance_variable_set("@autodetected",nil)
subject.auto_detected?.should be_false subject.auto_detected?.should be_falsey
end end
end end

View file

@ -48,7 +48,6 @@ module ::DatabaseCleaner
end end
it { should_not respond_to(:migration_storage_names) } it { should_not respond_to(:migration_storage_names) }
its(:migration_storage_names) { should be_empty }
end end
describe "initialize" do describe "initialize" do
@ -67,40 +66,40 @@ module ::DatabaseCleaner
context "" do context "" do
subject { TruncationExample.new( { :only => ["something"] } ) } subject { TruncationExample.new( { :only => ["something"] } ) }
its(:only) { should eq ["something"] } it { subject.only.should eq ["something"] }
its(:except) { should eq [] } it { subject.except.should eq [] }
end end
context "" do context "" do
subject { TruncationExample.new( { :except => ["something"] } ) } subject { TruncationExample.new( { :except => ["something"] } ) }
its(:only) { should eq nil } it { subject.only.should eq nil }
its(:except) { should include("something") } it { subject.except.should include("something") }
end end
context "" do context "" do
subject { TruncationExample.new( { :reset_ids => ["something"] } ) } subject { TruncationExample.new( { :reset_ids => ["something"] } ) }
its(:reset_ids?) { should eq true } it { subject.reset_ids?.should eq true }
end end
context "" do context "" do
subject { TruncationExample.new( { :reset_ids => nil } ) } subject { TruncationExample.new( { :reset_ids => nil } ) }
its(:reset_ids?) { should eq false } it { subject.reset_ids?.should eq false }
end end
context "" do context "" do
subject { TruncationExample.new( { :pre_count => ["something"] } ) } subject { TruncationExample.new( { :pre_count => ["something"] } ) }
its(:pre_count?) { should eq true } it { subject.pre_count?.should eq true }
end end
context "" do context "" do
subject { TruncationExample.new( { :pre_count => nil } ) } subject { TruncationExample.new( { :pre_count => nil } ) }
its(:pre_count?) { should eq false } it { subject.pre_count?.should eq false }
end end
context "" do context "" do
subject { MigrationExample.new } subject { MigrationExample.new }
its(:only) { should eq nil } it { subject.only.should eq nil }
its(:except) { should eq %w[migration_storage_name] } it { subject.except.should eq %w[migration_storage_name] }
end end
context "" do context "" do

View file

@ -24,9 +24,10 @@ module DatabaseCleaner
end end
it "should default to :default" do 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 subject.db.should eq :default
end end
pending "I figure out how to use Sequel and write some real tests for it..."
end end
end end
end end

View file

@ -34,9 +34,9 @@ module DatabaseCleaner
d.db = db d.db = db
d.clean d.clean
expect(db[:replaceable_trifles]).to have(0).rows expect(db[:replaceable_trifles]).to be_empty
expect(db[:worthless_junk]).to have(0).rows expect(db[:worthless_junk]).to be_empty
expect(db[:precious_stones]).to have(0).rows expect(db[:precious_stones]).to be_empty
end end
end end
end end

View file

@ -38,9 +38,9 @@ module DatabaseCleaner
t.db = db t.db = db
t.clean t.clean
expect(db[:replaceable_trifles]).to have(0).rows expect(db[:replaceable_trifles]).to be_empty
expect(db[:worthless_junk]).to have(0).rows expect(db[:worthless_junk]).to be_empty
expect(db[:precious_stones]).to have(0).rows expect(db[:precious_stones]).to be_empty
end end
end end
context 'when the Truncation is restricted to "only: [...]" some tables' do context 'when the Truncation is restricted to "only: [...]" some tables' do
@ -49,9 +49,9 @@ module DatabaseCleaner
t.db = db t.db = db
t.clean t.clean
expect(db[:replaceable_trifles]).to have(0).rows expect(db[:replaceable_trifles]).to be_empty
expect(db[:worthless_junk]).to have(0).rows expect(db[:worthless_junk]).to be_empty
expect(db[:precious_stones]).to have(1).rows expect(db[:precious_stones].count).to eq(1)
end end
end end
context 'when the Truncation is restricted to "except: [...]" some tables' do 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[:replaceable_trifles]).to be_empty
expect(db[:worthless_junk]).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 end
end end
@ -70,6 +70,7 @@ module DatabaseCleaner
shared_examples_for 'a truncation strategy without autoincrement resets' do 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 it "leaves AUTO_INCREMENT index alone by default (BUG: it should be reset instead)" do
pending
# Jordan Hollinger made everything reset auto increment IDs # Jordan Hollinger made everything reset auto increment IDs
# in commit 6a0104382647e5c06578aeac586c0333c8944492 so I'm pretty sure # in commit 6a0104382647e5c06578aeac586c0333c8944492 so I'm pretty sure
# everything is meant to reset by default. # everything is meant to reset by default.
@ -84,9 +85,7 @@ module DatabaseCleaner
truncation.clean truncation.clean
id_after_clean = table.insert id_after_clean = table.insert
pending('the bug being fixed') do expect(id_after_clean).to eq 1
expect(id_after_clean).to eq 1
end
end end
# XXX: it'd be really nice if Truncation accepted db: constructor parameter # XXX: it'd be really nice if Truncation accepted db: constructor parameter
let(:truncation) do let(:truncation) do
@ -134,7 +133,9 @@ module DatabaseCleaner
describe '#pre_count?' do describe '#pre_count?' do
subject { Truncation.new.tap { |t| t.db = db } } 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 it 'should return true if @reset_id is set and non false or nil' do
subject.instance_variable_set(:"@pre_count", true) subject.instance_variable_set(:"@pre_count", true)

View file

@ -15,7 +15,26 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
require 'database_cleaner' require 'database_cleaner'
RSpec.configure do |config| 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 end
alias running lambda alias running lambda