Browse files

moving to rspec 2

  • Loading branch information...
1 parent 8ffae18 commit bec9ecfa1c69fa510de9d8ed326fa4e495feff85 @ludicast ludicast committed Apr 19, 2011
View
10 Rakefile
@@ -1,5 +1,5 @@
require 'rake'
-require 'spec/rake/spectask'
+require "rspec/core/rake_task"
begin
require 'jeweler'
@@ -20,10 +20,10 @@ rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end
-require 'spec/rake/spectask'
-Spec::Rake::SpecTask.new(:spec) do |spec|
- spec.libs << 'lib' << 'spec'
- spec.spec_files = FileList['spec/*_spec.rb']
+
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = 'spec/*_spec.rb'
+ spec.rspec_opts = ['--backtrace']
end
task :default => :spec
View
1 lib/yaml_db.rb
@@ -3,6 +3,7 @@
require 'active_record'
require 'serialization_helper'
require 'active_support/core_ext/kernel/reporting'
+require 'rails/railtie'
module YamlDb
module Helper
View
7 spec/base.rb
@@ -1,9 +1,4 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'spec'
-require 'spec/autorun'
+require 'rspec'
require 'yaml_db'
-
-Spec::Runner.configure do |config|
-
-end
View
11 spec/serialization_helper_base_spec.rb
@@ -1,13 +1,16 @@
require File.dirname(__FILE__) + '/base'
describe SerializationHelper::Base do
+ def prestub_active_record
+
+ end
before do
- @io = StringIO.new
- silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
- ActiveRecord::Base.connection = mock('connection')
+ @io = StringIO.new
+ silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
+ ActiveRecord::Base.stub(:connection).and_return(mock('connection'))
ActiveRecord::Base.connection.stub!(:tables).and_return([ 'mytable', 'schema_info', 'schema_migrations' ])
- end
+ end
def stub_helper!
@helper = mock("MyHelper")
View
4 spec/serialization_helper_dump_spec.rb
@@ -4,9 +4,9 @@
before do
silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
- ActiveRecord::Base.connection = mock('connection')
+ ActiveRecord::Base.stub(:connection).and_return(stub('connection').as_null_object)
ActiveRecord::Base.connection.stub!(:tables).and_return([ 'mytable', 'schema_info', 'schema_migrations' ])
- ActiveRecord::Base.connection.stub!(:columns).with('mytable').and_return([ mock('a',:name => 'a'), mock('b', :name => 'b') ])
+ ActiveRecord::Base.connection.stub!(:columns).with('mytable').and_return([ mock('a', :name => 'a', :type => :string), mock('b', :name => 'b', :type => :string) ])
ActiveRecord::Base.connection.stub!(:select_one).and_return({"count"=>"2"})
ActiveRecord::Base.connection.stub!(:select_all).and_return([ { 'a' => 1, 'b' => 2 }, { 'a' => 3, 'b' => 4 } ])
SerializationHelper::Utils.stub!(:quote_table).with('mytable').and_return('mytable')
View
2 spec/serialization_helper_load_spec.rb
@@ -5,7 +5,7 @@
SerializationHelper::Utils.stub!(:quote_table).with('mytable').and_return('mytable')
silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
- ActiveRecord::Base.connection = mock('connection')
+ ActiveRecord::Base.stub(:connection).and_return(stub('connection').as_null_object)
ActiveRecord::Base.connection.stub!(:transaction).and_yield
@io = StringIO.new
end
View
2 spec/serialization_utils_spec.rb
@@ -3,7 +3,7 @@
describe SerializationHelper::Utils, " convert records utility method" do
before do
silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
- ActiveRecord::Base.connection = mock('connection')
+ ActiveRecord::Base.stub(:connection).and_return(stub('connection').as_null_object)
end
it "returns an array of hash values using an array of ordered keys" do
View
4 spec/yaml_dump_spec.rb
@@ -4,9 +4,9 @@
before do
silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
- ActiveRecord::Base.connection = mock('connection')
+ ActiveRecord::Base.stub(:connection).and_return(stub('connection').as_null_object)
ActiveRecord::Base.connection.stub!(:tables).and_return([ 'mytable', 'schema_info', 'schema_migrations' ])
- ActiveRecord::Base.connection.stub!(:columns).with('mytable').and_return([ mock('a',:name => 'a'), mock('b', :name => 'b') ])
+ ActiveRecord::Base.connection.stub!(:columns).with('mytable').and_return([ mock('a',:name => 'a', :type => :string), mock('b', :name => 'b', :type => :string) ])
ActiveRecord::Base.connection.stub!(:select_one).and_return({"count"=>"2"})
ActiveRecord::Base.connection.stub!(:select_all).and_return([ { 'a' => 1, 'b' => 2 }, { 'a' => 3, 'b' => 4 } ])
YamlDb::Utils.stub!(:quote_table).with('mytable').and_return('mytable')
View
2 spec/yaml_load_spec.rb
@@ -6,7 +6,7 @@
SerializationHelper::Utils.stub!(:quote_table).with('mytable').and_return('mytable')
silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
- ActiveRecord::Base.connection = mock('connection')
+ ActiveRecord::Base.stub(:connection).and_return(stub('connection').as_null_object)
ActiveRecord::Base.connection.stub!(:transaction).and_yield
end

0 comments on commit bec9ecf

Please sign in to comment.