Navigation Menu

Skip to content

Commit

Permalink
run tests agains rails 3 and rails 2
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Mar 11, 2011
1 parent 56dd83c commit 27a709c
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -3,8 +3,8 @@ source :rubygems
group :dev do group :dev do
gem 'rake' gem 'rake'
gem 'sqlite3' gem 'sqlite3'
gem 'activerecord' gem 'activerecord', '~>3'
gem 'actionpack' gem 'actionpack', '~>3'
gem 'rspec', '~>2' gem 'rspec', '~>2'
gem 'jeweler' gem 'jeweler'
end end
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -54,8 +54,8 @@ PLATFORMS
ruby ruby


DEPENDENCIES DEPENDENCIES
actionpack actionpack (~> 3)
activerecord activerecord (~> 3)
jeweler jeweler
rake rake
rspec (~> 2) rspec (~> 2)
Expand Down
16 changes: 11 additions & 5 deletions Rakefile
@@ -1,7 +1,13 @@
task :default => :spec task :spec do
require "rspec/core/rake_task" sh "bundle exec rspec spec"
RSpec::Core::RakeTask.new(:spec) do |t| end
t.rspec_opts = '--backtrace --color'
task :rails2 do
sh "cd spec/rails2 && bundle exec rspec ../../spec"
end

task :default do
sh "rake spec && rake rails2"
end end


begin begin
Expand All @@ -17,4 +23,4 @@ begin
Jeweler::GemcutterTasks.new Jeweler::GemcutterTasks.new
rescue LoadError rescue LoadError
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler" puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
end end
10 changes: 10 additions & 0 deletions 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
37 changes: 37 additions & 0 deletions 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
19 changes: 9 additions & 10 deletions spec/simple_autocomplete_spec.rb
@@ -1,5 +1,4 @@

require File.join(File.dirname(__FILE__), 'spec_helper')
require "spec/spec_helper"


describe SimpleAutocomplete do describe SimpleAutocomplete do
it "has a version" do it "has a version" do
Expand All @@ -19,7 +18,7 @@ def a_instance_method
@c.stub!(:params).and_return Hash.new @c.stub!(:params).and_return Hash.new
@c.stub!(:render) @c.stub!(:render)
end end

describe 'regression' do describe 'regression' do
it "can use long method/class names" do it "can use long method/class names" do
class UserAddress < ActiveRecord::Base class UserAddress < ActiveRecord::Base
Expand All @@ -31,22 +30,22 @@ class UserAddress < ActiveRecord::Base
@c.autocomplete_for_user_address_full_name @c.autocomplete_for_user_address_full_name
end end
end end

describe 'simple autocomplete' do describe 'simple autocomplete' do
before do before do
UsersController.autocomplete_for(:user,:name) UsersController.autocomplete_for(:user,:name)
end end

it "renders the items inline" do it "renders the items inline" do
@c.should_receive(:render).with {|hash| hash[:inline] =~ /@items.map \{|item| h(item.name)\}.uniq.join(\'\n\')/} @c.should_receive(:render).with {|hash| hash[:inline] =~ /@items.map \{|item| h(item.name)\}.uniq.join(\'\n\')/}
@c.autocomplete_for_user_name @c.autocomplete_for_user_name
end end

it "orders ASC by name" do it "orders ASC by name" do
User.should_receive(:scoped).with(hash_including(:order => 'name ASC')) User.should_receive(:scoped).with(hash_including(:order => 'name ASC'))
@c.autocomplete_for_user_name @c.autocomplete_for_user_name
end end

it "finds by name" do it "finds by name" do
@c.stub!(:params).and_return :q=>'Hans' @c.stub!(:params).and_return :q=>'Hans'
User.should_receive(:scoped).with(hash_including(:conditions => ['LOWER(name) LIKE ?','%hans%'])) User.should_receive(:scoped).with(hash_including(:conditions => ['LOWER(name) LIKE ?','%hans%']))
Expand Down Expand Up @@ -109,7 +108,7 @@ class UserAddress < ActiveRecord::Base
@c.autocomplete_for_user_name @c.autocomplete_for_user_name
x.should == 1 x.should == 1
end end

it "passes found items to the block" do it "passes found items to the block" do
User.delete_all User.delete_all
u1 = User.create!(:name => 'xxx') u1 = User.create!(:name => 'xxx')
Expand All @@ -123,7 +122,7 @@ class UserAddress < ActiveRecord::Base
@c.stub!(:params).and_return :q=>'xxx' @c.stub!(:params).and_return :q=>'xxx'
@c.autocomplete_for_user_name @c.autocomplete_for_user_name
end end

it "uses block output for render" do it "uses block output for render" do
UsersController.autocomplete_for(:user, :name) do |items| UsersController.autocomplete_for(:user, :name) do |items|
items + 'xx' items + 'xx'
Expand Down Expand Up @@ -201,7 +200,7 @@ class XPost < ActiveRecord::Base
Author.find_by_autocomplete_name('bob').should == nil Author.find_by_autocomplete_name('bob').should == nil
end end
end end

describe "add_by_auto_{name}_{attribute}" do describe "add_by_auto_{name}_{attribute}" do
it "is always nil when associated is not present" do it "is always nil when associated is not present" do
Post.new.add_by_auto_tag_name.should == nil Post.new.add_by_auto_tag_name.should == nil
Expand Down
8 changes: 5 additions & 3 deletions spec/spec_helper.rb
Expand Up @@ -2,7 +2,9 @@
require 'action_pack' require 'action_pack'
require 'action_controller' require 'action_controller'


$LOAD_PATH << "lib" root = File.dirname(File.dirname(__FILE__))
require "init"


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.