Skip to content
Browse files

upgraded specs to RSpec 2

  • Loading branch information...
1 parent c18219b commit 30e651be3e9f596352df4243743a32dad497c5a8 @rsim committed Jan 5, 2011
View
2 .rspec
@@ -0,0 +1,2 @@
+--color
+--backtrace
View
10 Gemfile
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
group :development do
gem 'jeweler', '~> 1.5.1'
- gem 'rspec', '~> 1.3.0'
+ gem 'rspec', '~> 2.4'
if ENV['RAILS_GEM_VERSION']
gem 'activerecord', "=#{ENV['RAILS_GEM_VERSION']}"
@@ -33,10 +33,10 @@ group :development do
gem 'rack', :git => 'git://github.com/rack/rack.git'
end
- if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
- gem 'ruby-oci8', '>=2.0.4'
- end
-
gem 'ruby-plsql', '>=0.4.4'
end
+
+platforms :ruby do
+ gem 'ruby-oci8', '~> 2.0.4'
+end
View
14 Rakefile
@@ -26,16 +26,12 @@ EOS
end
Jeweler::RubygemsDotOrgTasks.new
-require 'spec/rake/spectask'
-Spec::Rake::SpecTask.new(:spec) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.spec_files = FileList['spec/**/*_spec.rb']
-end
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec)
-Spec::Rake::SpecTask.new(:rcov) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.pattern = 'spec/**/*_spec.rb'
- spec.rcov = true
+RSpec::Core::RakeTask.new(:rcov) do |t|
+ t.rcov = true
+ t.rcov_opts = ['--exclude', '/Library,spec/']
end
task :default => :spec
View
2 spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter establish connection" do
View
39 spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb
@@ -1,19 +1,14 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedConnection" do
- before(:all) do
- @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS)
- end
-
describe "create connection" do
-
- before(:each) do
- @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS) unless @conn.active?
+ before(:all) do
+ @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS)
end
- after(:all) do
- @conn.logoff if @conn.active?
+ before(:each) do
+ @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS) unless @conn.active?
end
it "should create new connection" do
@@ -41,10 +36,6 @@
end
describe "create connection with NLS parameters" do
- before do
- @conn.logoff if @conn.active?
- end
-
after do
ENV['NLS_DATE_FORMAT'] = nil
end
@@ -72,9 +63,6 @@
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
describe "OracleEnhancedConnection create JDBC connection" do
- after(:each) do
- @conn.logoff if @conn.active?
- end
it "should create new connection using :url" do
params = CONNECTION_PARAMS.dup
@@ -144,6 +132,9 @@ def lookup(path)
end
describe "SQL execution" do
+ before(:all) do
+ @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS)
+ end
it "should execute SQL statement" do
@conn.exec("SELECT * FROM dual").should_not be_nil
@@ -160,6 +151,9 @@ def lookup(path)
end
describe "SQL with bind parameters" do
+ before(:all) do
+ @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS)
+ end
it "should execute SQL statement with bind parameter" do
cursor = @conn.prepare("SELECT * FROM dual WHERE :1 = 1")
@@ -184,7 +178,6 @@ def lookup(path)
end
describe "auto reconnection" do
-
before(:all) do
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
@conn = ActiveRecord::Base.connection.instance_variable_get("@connection")
@@ -195,10 +188,6 @@ def lookup(path)
ActiveRecord::Base.connection.reconnect! unless @conn.active?
end
- after(:all) do
- ActiveRecord::Base.connection.disconnect! if @conn.active?
- end
-
def kill_current_session
audsid = @conn.select("SELECT userenv('sessionid') audsid FROM dual").first['audsid']
sid_serial = @sys_conn.select("SELECT s.sid||','||s.serial# sid_serial
@@ -238,14 +227,10 @@ def kill_current_session
end
describe "describe table" do
-
before(:all) do
+ @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS)
@owner = CONNECTION_PARAMS[:username].upcase
end
-
- after(:all) do
- @conn.logoff if @conn.active?
- end
it "should describe existing table" do
@conn.exec "CREATE TABLE test_employees (first_name VARCHAR2(20))" rescue nil
View
3 spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter context index" do
include SchemaSpecHelper
View
3 spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter to_d method" do
it "BigDecimal#to_d returns the same decimal number" do
View
2 spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
unless defined?(NO_COMPOSITE_PRIMARY_KEYS)
View
3 spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
@@ -1,6 +1,5 @@
# encoding: utf-8
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter date type detection based on column names" do
before(:all) do
View
2 spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter logging dbms_output from plsql" do
include LoggerSpecHelper
View
2 spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
if ActiveRecord::Base.instance_methods.include?('changed?')
View
2 spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter emulate OracleAdapter" do
View
2 spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
require 'ruby-plsql'
View
2 spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter schema dump" do
include SchemaSpecHelper
View
20 spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter schema definition" do
include SchemaSpecHelper
@@ -137,7 +137,7 @@ def create_table_and_separately_trigger(options = {})
end
end
- after(:all) do
+ def drop_table_with_trigger
seq_name = @sequence_name
schema_define do
drop_table :test_employees, (seq_name ? {:sequence_name => seq_name} : {})
@@ -153,6 +153,10 @@ class ::TestEmployee < ActiveRecord::Base
end
end
+ after(:all) do
+ drop_table_with_trigger
+ end
+
it "should populate primary key using trigger" do
lambda do
@conn.execute "INSERT INTO test_employees (first_name) VALUES ('Raimonds')"
@@ -177,6 +181,10 @@ class ::TestEmployee < ActiveRecord::Base
end
end
+ after(:all) do
+ drop_table_with_trigger
+ end
+
it "should populate primary key using trigger" do
lambda do
@conn.execute "INSERT INTO test_employees (first_name) VALUES ('Raimonds')"
@@ -204,6 +212,10 @@ class ::TestEmployee < ActiveRecord::Base
end
end
+ after(:all) do
+ drop_table_with_trigger
+ end
+
it "should populate primary key using trigger" do
lambda do
@conn.execute "INSERT INTO test_employees (first_name) VALUES ('Raimonds')"
@@ -230,6 +242,10 @@ class ::TestEmployee < ActiveRecord::Base
end
end
+ after(:all) do
+ drop_table_with_trigger
+ end
+
it "should populate primary key using trigger" do
lambda do
@conn.execute "INSERT INTO test_employees (first_name) VALUES ('Raimonds')"
View
2 spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require 'spec_helper'
describe "OracleEnhancedAdapter structure dump" do
include LoggerSpecHelper
View
6 spec/spec.opts
@@ -1,6 +0,0 @@
---colour
---format
-progress
---loadby
-mtime
---reverse
View
22 spec/spec_helper.rb
@@ -1,20 +1,10 @@
require 'rubygems'
+require "bundler"
+Bundler.setup(:default, :development)
-# Set up gems listed in the Gemfile.
-gemfile = File.expand_path('../../Gemfile', __FILE__)
-begin
- ENV['BUNDLE_GEMFILE'] = gemfile
- require 'bundler'
- Bundler.setup
-rescue Bundler::GemNotFound => e
- STDERR.puts e.message
- STDERR.puts "Try running `bundle install`."
- exit!
-end if File.exist?(gemfile)
+$:.unshift(File.expand_path('../../lib', __FILE__))
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-
-require 'spec'
+require 'rspec'
if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
puts "==> Running specs with MRI version #{RUBY_VERSION}"
@@ -194,8 +184,8 @@ def schema_define(&block)
:password => DATABASE_SYS_PASSWORD
}
-# For JRuby Set default $KCODE to UTF8
-$KCODE = "UTF8" if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
+# Set default $KCODE to UTF8
+$KCODE = "UTF8"
# set default time zone in TZ environment variable
# which will be used to set session time zone

0 comments on commit 30e651b

Please sign in to comment.
Something went wrong with that request. Please try again.