Permalink
Browse files

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...
1 parent face6c4 commit c5b45d72fffeeca064a81b7fa9a8a754c2fff24e @jeremyevans committed Feb 9, 2011
View
@@ -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)
View
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)'
@@ -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}
@@ -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])
@@ -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
@@ -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
@@ -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}
@@ -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
@@ -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
@@ -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
@@ -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)
Oops, something went wrong.

0 comments on commit c5b45d7

Please sign in to comment.