Browse files

run tests agains rails 3 and rails 2

  • Loading branch information...
1 parent 56dd83c commit 27a709c6b39f24f8236acd140bbc415e229470cf @grosser committed Mar 11, 2011
Showing with 76 additions and 22 deletions.
  1. +2 −2 Gemfile
  2. +2 −2 Gemfile.lock
  3. +11 −5 Rakefile
  4. +10 −0 spec/rails2/Gemfile
  5. +37 −0 spec/rails2/Gemfile.lock
  6. +9 −10 spec/simple_autocomplete_spec.rb
  7. +5 −3 spec/spec_helper.rb
View
4 Gemfile
@@ -3,8 +3,8 @@ source :rubygems
group :dev do
gem 'rake'
gem 'sqlite3'
- gem 'activerecord'
- gem 'actionpack'
+ gem 'activerecord', '~>3'
+ gem 'actionpack', '~>3'
gem 'rspec', '~>2'
gem 'jeweler'
end
View
4 Gemfile.lock
@@ -54,8 +54,8 @@ PLATFORMS
ruby
DEPENDENCIES
- actionpack
- activerecord
+ actionpack (~> 3)
+ activerecord (~> 3)
jeweler
rake
rspec (~> 2)
View
16 Rakefile
@@ -1,7 +1,13 @@
-task :default => :spec
-require "rspec/core/rake_task"
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.rspec_opts = '--backtrace --color'
+task :spec do
+ sh "bundle exec rspec spec"
+end
+
+task :rails2 do
+ sh "cd spec/rails2 && bundle exec rspec ../../spec"
+end
+
+task :default do
+ sh "rake spec && rake rails2"
end
begin
@@ -17,4 +23,4 @@ begin
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
-end
+end
View
10 spec/rails2/Gemfile
@@ -0,0 +1,10 @@
+source :rubygems
+
+group :dev do
+ gem 'rake'
+ gem 'sqlite3'
+ gem 'activerecord', '~>2'
+ gem 'actionpack', '~>2'
+ gem 'rspec', '~>2'
+ gem 'jeweler'
+end
View
37 spec/rails2/Gemfile.lock
@@ -0,0 +1,37 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionpack (2.3.11)
+ activesupport (= 2.3.11)
+ rack (~> 1.1.0)
+ activerecord (2.3.11)
+ activesupport (= 2.3.11)
+ activesupport (2.3.11)
+ diff-lcs (1.1.2)
+ git (1.2.5)
+ jeweler (1.5.2)
+ bundler (~> 1.0.0)
+ git (>= 1.2.5)
+ rake
+ rack (1.1.1)
+ rake (0.8.7)
+ rspec (2.5.0)
+ rspec-core (~> 2.5.0)
+ rspec-expectations (~> 2.5.0)
+ rspec-mocks (~> 2.5.0)
+ rspec-core (2.5.1)
+ rspec-expectations (2.5.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.5.0)
+ sqlite3 (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ actionpack (~> 2)
+ activerecord (~> 2)
+ jeweler
+ rake
+ rspec (~> 2)
+ sqlite3
View
19 spec/simple_autocomplete_spec.rb
@@ -1,5 +1,4 @@
-
-require "spec/spec_helper"
+require File.join(File.dirname(__FILE__), 'spec_helper')
describe SimpleAutocomplete do
it "has a version" do
@@ -19,7 +18,7 @@ def a_instance_method
@c.stub!(:params).and_return Hash.new
@c.stub!(:render)
end
-
+
describe 'regression' do
it "can use long method/class names" do
class UserAddress < ActiveRecord::Base
@@ -31,22 +30,22 @@ class UserAddress < ActiveRecord::Base
@c.autocomplete_for_user_address_full_name
end
end
-
+
describe 'simple autocomplete' do
before do
UsersController.autocomplete_for(:user,:name)
end
-
+
it "renders the items inline" do
@c.should_receive(:render).with {|hash| hash[:inline] =~ /@items.map \{|item| h(item.name)\}.uniq.join(\'\n\')/}
@c.autocomplete_for_user_name
end
-
+
it "orders ASC by name" do
User.should_receive(:scoped).with(hash_including(:order => 'name ASC'))
@c.autocomplete_for_user_name
end
-
+
it "finds by name" do
@c.stub!(:params).and_return :q=>'Hans'
User.should_receive(:scoped).with(hash_including(:conditions => ['LOWER(name) LIKE ?','%hans%']))
@@ -109,7 +108,7 @@ class UserAddress < ActiveRecord::Base
@c.autocomplete_for_user_name
x.should == 1
end
-
+
it "passes found items to the block" do
User.delete_all
u1 = User.create!(:name => 'xxx')
@@ -123,7 +122,7 @@ class UserAddress < ActiveRecord::Base
@c.stub!(:params).and_return :q=>'xxx'
@c.autocomplete_for_user_name
end
-
+
it "uses block output for render" do
UsersController.autocomplete_for(:user, :name) do |items|
items + 'xx'
@@ -201,7 +200,7 @@ class XPost < ActiveRecord::Base
Author.find_by_autocomplete_name('bob').should == nil
end
end
-
+
describe "add_by_auto_{name}_{attribute}" do
it "is always nil when associated is not present" do
Post.new.add_by_auto_tag_name.should == nil
View
8 spec/spec_helper.rb
@@ -2,7 +2,9 @@
require 'action_pack'
require 'action_controller'
-$LOAD_PATH << "lib"
-require "init"
+root = File.dirname(File.dirname(__FILE__))
-require "spec/setup_test_model.rb"
+$LOAD_PATH << "#{root}/lib"
+require "#{root}/init"
+
+require "#{root}/spec/setup_test_model.rb"

0 comments on commit 27a709c

Please sign in to comment.