Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support RSpec 2, keeping backwards compatibility with RSpec 1
This updates the Rakefile and specs to use the new
class names and methods for RSpec 2, and removes the
use of context in favor of describe.  Future updates
to the specs should only use describe and should work
correctly under both RSpec 1 and RSpec 2.
  • Loading branch information
jeremyevans committed Feb 9, 2011
1 parent face6c4 commit c5b45d7
Show file tree
Hide file tree
Showing 30 changed files with 304 additions and 292 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,5 +1,7 @@
=== HEAD

* Make specs support both RSpec 1 and RSpec 2 (jeremyevans)

* Work with ruby-informix versions >= 0.7.3 in the informix adapter (jeremyevans) (#326)

=== 3.20.0 (2011-02-01)
Expand Down
16 changes: 13 additions & 3 deletions Rakefile
Expand Up @@ -87,14 +87,24 @@ end
### Specs

begin
require "spec/rake/spectask"
begin
# RSpec 1
require "spec/rake/spectask"
spec_class = Spec::Rake::SpecTask
spec_files_meth = :spec_files=
rescue LoadError
# RSpec 2
require "rspec/core/rake_task"
spec_class = RSpec::Core::RakeTask
spec_files_meth = :pattern=
end

spec = lambda do |name, files, d|
lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib')
ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir)
desc d
Spec::Rake::SpecTask.new(name) do |t|
t.spec_files = files
spec_class.new(name) do |t|
t.send spec_files_meth, files
t.spec_opts = ENV['SEQUEL_SPEC_OPTS'].split if ENV['SEQUEL_SPEC_OPTS']
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/adapters/firebird_spec.rb
Expand Up @@ -43,7 +43,7 @@ def logger.method_missing(m, msg)
String :val4, :text=>true
end

context "A Firebird database" do
describe "A Firebird database" do
before do
@db = FIREBIRD_DB
end
Expand All @@ -60,7 +60,7 @@ def logger.method_missing(m, msg)
end
end

context "A Firebird dataset" do
describe "A Firebird dataset" do
before do
@d = FIREBIRD_DB[:test]
@d.delete # remove all records
Expand Down Expand Up @@ -230,7 +230,7 @@ def FIREBIRD_DB.ret_commit
end
end

context "A Firebird dataset with a timestamp field" do
describe "A Firebird dataset with a timestamp field" do
before do
@d = FIREBIRD_DB[:test3]
@d.delete
Expand All @@ -244,7 +244,7 @@ def FIREBIRD_DB.ret_commit
end
end

context "A Firebird database" do
describe "A Firebird database" do
before do
@db = FIREBIRD_DB
@db.drop_table(:posts) rescue nil
Expand Down Expand Up @@ -353,7 +353,7 @@ def FIREBIRD_DB.ret_commit
end
end

context "Postgres::Dataset#insert" do
describe "Postgres::Dataset#insert" do
before do
@ds = FIREBIRD_DB[:test5]
@ds.delete
Expand Down Expand Up @@ -387,7 +387,7 @@ def FIREBIRD_DB.ret_commit
end
end

context "Postgres::Dataset#insert" do
describe "Postgres::Dataset#insert" do
before do
@ds = FIREBIRD_DB[:test6]
@ds.delete
Expand Down
4 changes: 2 additions & 2 deletions spec/adapters/informix_spec.rb
Expand Up @@ -15,7 +15,7 @@
index :value
end

context "A Informix database" do
describe "A Informix database" do
specify "should provide disconnect functionality" do
INFORMIX_DB.execute("select user from dual")
INFORMIX_DB.pool.size.should == 1
Expand All @@ -24,7 +24,7 @@
end
end

context "A Informix dataset" do
describe "A Informix dataset" do
before do
@d = INFORMIX_DB[:test]
@d.delete # remove all records
Expand Down
26 changes: 13 additions & 13 deletions spec/adapters/mssql_spec.rb
Expand Up @@ -34,7 +34,7 @@ def logger.method_missing(m, msg)
varbinary :value
end

context "A MSSQL database" do
describe "A MSSQL database" do
before do
@db = MSSQL_DB
end
Expand All @@ -59,7 +59,7 @@ def logger.method_missing(m, msg)
end
end

context "MSSQL Dataset#join_table" do
describe "MSSQL Dataset#join_table" do
specify "should emulate the USING clause with ON" do
MSSQL_DB[:items].join(:categories, [:id]).sql.should ==
'SELECT * FROM ITEMS INNER JOIN CATEGORIES ON (CATEGORIES.ID = ITEMS.ID)'
Expand All @@ -71,7 +71,7 @@ def logger.method_missing(m, msg)
end
end

context "MSSQL Dataset#output" do
describe "MSSQL Dataset#output" do
before do
@db = MSSQL_DB
@db.create_table!(:items){String :name; Integer :value}
Expand Down Expand Up @@ -150,13 +150,13 @@ def logger.method_missing(m, msg)
end
end

context "MSSQL dataset" do
describe "MSSQL dataset" do
before do
@db = MSSQL_DB
@ds = MSSQL_DB[:t]
end

context "using #with and #with_recursive" do
describe "using #with and #with_recursive" do
before do
@ds1 = @ds.with(:t, @db[:x])
@ds2 = @ds.with_recursive(:t, @db[:x], @db[:t])
Expand All @@ -177,7 +177,7 @@ def logger.method_missing(m, msg)
@ds2.insert_sql(@db[:t]).should == 'WITH T AS (SELECT * FROM X UNION ALL SELECT * FROM T) INSERT INTO T SELECT * FROM T'
end

context "on #import" do
describe "on #import" do
before do
@db = @db.clone
class << @db
Expand Down Expand Up @@ -213,7 +213,7 @@ def transaction(opts={})
end
end

context "MSSQL joined datasets" do
describe "MSSQL joined datasets" do
before do
@db = MSSQL_DB
end
Expand Down Expand Up @@ -325,7 +325,7 @@ def transaction(opts={})
end
end

context "MSSSQL::Dataset#insert" do
describe "MSSSQL::Dataset#insert" do
before do
@db = MSSQL_DB
@db.create_table!(:test5){primary_key :xid; Integer :value}
Expand All @@ -352,13 +352,13 @@ def transaction(opts={})
end
end

context "MSSSQL::Dataset#disable_insert_output" do
describe "MSSSQL::Dataset#disable_insert_output" do
specify "should play nicely with simple_select_all?" do
MSSQL_DB[:test].disable_insert_output.send(:simple_select_all?).should == true
end
end

context "MSSSQL::Dataset#into" do
describe "MSSSQL::Dataset#into" do
before do
@db = MSSQL_DB
end
Expand All @@ -377,7 +377,7 @@ def transaction(opts={})
end
end

context "A MSSQL database" do
describe "A MSSQL database" do
before do
@db = MSSQL_DB
end
Expand All @@ -403,7 +403,7 @@ def transaction(opts={})
end
end

context "MSSQL::Database#rename_table" do
describe "MSSQL::Database#rename_table" do
specify "should work on non-schema bound tables which need escaping" do
MSSQL_DB.quote_identifiers = true
MSSQL_DB.create_table! :'foo bar' do
Expand All @@ -426,7 +426,7 @@ def transaction(opts={})
end
end

context "MSSQL::Dataset#count" do
describe "MSSQL::Dataset#count" do
specify "should work with a distinct query with an order clause" do
MSSQL_DB.create_table!(:items){String :name; Integer :value}
MSSQL_DB[:items].insert(:name => "name", :value => 1)
Expand Down

0 comments on commit c5b45d7

Please sign in to comment.