Skip to content
Browse files

Specs now running (still failing though) with RSpec2 on Rails3

  • Loading branch information...
1 parent af777bb commit 90dce9c8b72ba462618cfde48cd085da73bb6704 @benedikt committed Sep 6, 2010
View
3 .gitignore
@@ -3,4 +3,5 @@
coverage
rdoc
pkg
-spec/debug.log
+spec/db/debug.log
+tmp
View
2 .rspec
@@ -0,0 +1,2 @@
+--colour
+--format progress
View
2 Gemfile
@@ -1,3 +1,5 @@
source :rubygems
gemspec
+
+gem 'sqlite3-ruby', :require => 'sqlite3'
View
2 Gemfile.lock
@@ -83,6 +83,7 @@ GEM
rspec-mocks (2.0.0.beta.20)
rspec-rails (2.0.0.beta.20)
rspec (= 2.0.0.beta.20)
+ sqlite3-ruby (1.3.1)
thor (0.14.0)
treetop (1.4.8)
polyglot (>= 0.3.1)
@@ -98,3 +99,4 @@ DEPENDENCIES
rails (~> 3.0.0)
rspec (>= 2.0.0.beta.18)
rspec-rails (>= 2.0.0.beta.18)
+ sqlite3-ruby
View
23 spec/active_record_spec.rb
@@ -1,13 +1,12 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-require File.expand_path(File.dirname(__FILE__) + '/fixtures/employee')
+require 'spec_helper'
describe FilterFu::ActiveRecord do
it "should add a filter_fu class method to ActiveRecord::Base" do
ActiveRecord::Base.should respond_to(:filter_fu)
end
- describe "filter_fu" do
+ describe "-filter_fu" do
it "should accept an options hash" do
lambda { ActiveRecord::Base.filter_fu({}) }.should_not raise_error(ArgumentError)
@@ -37,7 +36,7 @@
end
- describe "filtered_by" do
+ describe "-filtered_by" do
before(:each) do
@plain_class = Class.new(Employee)
@@ -118,8 +117,8 @@
it "should not filter by scopes defined in :except option" do
klass = @plain_class.clone
klass.filter_fu :except => :dont_access_me
- klass.named_scope :dont_access_me, {}
- klass.named_scope :access_me, {}
+ klass.scope :dont_access_me, {}
+ klass.scope :access_me, {}
klass.should_not_receive(:dont_access_me)
klass.filtered_by(:dont_access_me => '')
@@ -128,8 +127,8 @@
it "should filter by scopes not defined in :except option" do
klass = @plain_class.clone
klass.filter_fu :except => :dont_access_me
- klass.named_scope :dont_access_me, {}
- klass.named_scope :access_me, {}
+ klass.scope :dont_access_me, {}
+ klass.scope :access_me, {}
klass.should_receive(:access_me)
klass.filtered_by(:access_me => '')
@@ -138,8 +137,8 @@
it "should only filter by scopes define in :only option" do
klass = @plain_class.clone
klass.filter_fu :only => :only_access_me
- klass.named_scope :only_access_me, {}
- klass.named_scope :dont_access_me, {}
+ klass.scope :only_access_me, {}
+ klass.scope :dont_access_me, {}
klass.should_receive(:only_access_me)
klass.filtered_by(:only_access_me => '')
@@ -148,8 +147,8 @@
it "should not filter by scopes not defined in :only option" do
klass = @plain_class.clone
klass.filter_fu :only => :only_access_me
- klass.named_scope :only_access_me, {}
- klass.named_scope :dont_access_me, {}
+ klass.scope :only_access_me, {}
+ klass.scope :dont_access_me, {}
klass.should_not_receive(:dont_access_me)
klass.filtered_by(:dont_access_me => '')
View
2 spec/db/database.yml
@@ -1,3 +1,3 @@
sqlite3:
database: ":memory:"
- adapter: sqlite3
+ adapter: sqlite3
View
2 spec/filter_fu_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+require 'spec_helper'
describe FilterFu do
View
4 spec/spec.opts
@@ -1,4 +0,0 @@
---colour
---format progress
---loadby mtime
---reverse
View
39 spec/spec_helper.rb
@@ -1,25 +1,40 @@
-$LOAD_PATH.unshift(File.dirname(__FILE__))
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-
-begin
- require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
-rescue LoadError
- puts "You need to install rspec in your base app"
- exit
-end
+# This file is copied to ~/spec when you run 'ruby script/generate rspec'
+# from the project root directory.
+ENV["RAILS_ENV"] ||= 'test'
+require 'rubygems'
+require 'rails/all'
require 'filter_fu'
-Spec::Runner.configure do |config|
+require File.dirname(__FILE__) + "/../tmp/sandbox/config/environment"
-end
+require 'rspec/rails'
-ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'debug.log'))
+ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'db', 'debug.log'))
configuration = YAML.load_file(File.join(File.dirname(__FILE__), 'db', 'database.yml'))
ActiveRecord::Base.establish_connection(configuration[ENV["DB"] || "sqlite3"])
ActiveRecord::Base.silence do
ActiveRecord::Migration.verbose = false
load(File.join(File.dirname(__FILE__), "db", "schema.rb"))
+end
+
+# Requires supporting files with custom matchers and macros, etc,
+# in ./support/ and its subdirectories.
+Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
+
+Rspec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # If you'd prefer not to run each of your examples within a transaction,
+ # uncomment the following line.
+ # config.use_transactional_examples false
end
View
0 spec/dummies.rb → spec/support/dummies.rb
File renamed without changes.
View
6 spec/fixtures/employee.rb → spec/support/employee.rb
@@ -1,7 +1,7 @@
class Employee < ActiveRecord::Base
- named_scope :boss, :conditions => "position = 'Boss'"
- named_scope :country, lambda { |country| { :conditions => ["country = ?", country] } }
+ scope :boss, :conditions => "position = 'Boss'"
+ scope :country, lambda { |country| { :conditions => ["country = ?", country] } }
end
@@ -10,5 +10,3 @@ class Employee < ActiveRecord::Base
salary = (n == 0) ? 100000 : (((n+1) % 5) * 10000)
Employee.create(:name => "Employee #{n}", :country => "Country #{(n % 10) + 1}", :position => position, :salary => salary)
end
-
-#puts Employee.all.inspect
View
3 spec/view_helper_spec.rb
@@ -1,5 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-require 'dummies'
+require 'spec_helper'
describe FilterFu::ViewHelper, :type => :helper do

0 comments on commit 90dce9c

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