Permalink
Browse files

Test against Rails 3.2.

  • Loading branch information...
1 parent 5baa056 commit aff28245e798ac07fe96a89f84efbfcc1ba5b4d3 Gabe Berke-Williams committed Mar 9, 2012
View
@@ -7,3 +7,9 @@ appraise '3.1' do
gem 'jquery-rails'
gem 'sass-rails'
end
+
+appraise '3.2' do
+ gem 'rails', '3.2.3'
+ gem 'jquery-rails'
+ gem 'sass-rails'
+end
View
@@ -0,0 +1,16 @@
+# This file was generated by Appraisal
+
+source "http://rubygems.org"
+
+gem "shoulda-context", "~> 1.0.0"
+gem "sqlite3", :platform=>:ruby
+gem "activerecord-jdbc-adapter", :platform=>:jruby
+gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
+gem "jdbc-sqlite3", :platform=>:jruby
+gem "jruby-openssl", :platform=>:jruby
+gem "therubyrhino", :platform=>:jruby
+gem "rails", "3.2.3"
+gem "jquery-rails"
+gem "sass-rails"
+
+gemspec :path=>"../"
View
@@ -0,0 +1,157 @@
+PATH
+ remote: /Users/gabe/thoughtbot/shoulda-matchers
+ specs:
+ shoulda-matchers (1.1.0)
+ activesupport (>= 3.0.0)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.2.3)
+ actionpack (= 3.2.3)
+ mail (~> 2.4.4)
+ actionpack (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
+ builder (~> 3.0.0)
+ activerecord (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ activesupport (3.2.3)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ appraisal (0.4.1)
+ bundler
+ rake
+ arel (3.0.2)
+ aruba (0.4.11)
+ childprocess (>= 0.2.3)
+ cucumber (>= 1.1.1)
+ ffi (>= 1.0.11)
+ rspec (>= 2.7.0)
+ bourne (1.1.2)
+ mocha (= 0.10.5)
+ builder (3.0.0)
+ childprocess (0.3.2)
+ ffi (~> 1.0.6)
+ cucumber (1.1.9)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.9.0)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ ffi (1.0.11)
+ gherkin (2.9.3)
+ json (>= 1.4.6)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.3)
+ jquery-rails (2.0.2)
+ railties (>= 3.2.0, < 5.0)
+ thor (~> 0.14)
+ json (1.6.6)
+ mail (2.4.4)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ metaclass (0.0.1)
+ mime-types (1.18)
+ mocha (0.10.5)
+ metaclass (~> 0.0.1)
+ multi_json (1.3.2)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.3)
+ actionmailer (= 3.2.3)
+ actionpack (= 3.2.3)
+ activerecord (= 3.2.3)
+ activeresource (= 3.2.3)
+ activesupport (= 3.2.3)
+ bundler (~> 1.0)
+ railties (= 3.2.3)
+ railties (3.2.3)
+ actionpack (= 3.2.3)
+ activesupport (= 3.2.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
+ sass (3.1.15)
+ sass-rails (3.2.5)
+ railties (~> 3.2.0)
+ sass (>= 3.1.10)
+ tilt (~> 1.3)
+ shoulda-context (1.0.0)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.6)
+ term-ansicolor (1.0.7)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.33)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ activerecord-jdbc-adapter
+ activerecord-jdbcsqlite3-adapter
+ appraisal (~> 0.4.0)
+ aruba
+ bourne (~> 1.1.2)
+ bundler (~> 1.1.0)
+ cucumber (~> 1.1.9)
+ jdbc-sqlite3
+ jquery-rails
+ jruby-openssl
+ rails (= 3.2.3)
+ rake (~> 0.9.2)
+ rspec-rails (~> 2.8.1)
+ sass-rails
+ shoulda-context (~> 1.0.0)
+ shoulda-matchers!
+ sqlite3
+ therubyrhino
@@ -91,14 +91,14 @@ def friendly_queries
end
def filter_query(query)
- query[:name] == 'SCHEMA' || looks_like_schema(query[:sql])
+ query[:name] == 'SCHEMA' || looks_like_schema?(query[:sql])
end
def schema_terms
- ['FROM sqlite_master', 'PRAGMA', 'SHOW TABLES', 'SHOW KEYS FROM', 'SHOW FIELDS FROM']
+ ['FROM sqlite_master', 'PRAGMA', 'SHOW TABLES', 'SHOW KEYS FROM', 'SHOW FIELDS FROM', 'begin transaction', 'commit transaction']
end
- def looks_like_schema(sql)
+ def looks_like_schema?(sql)
schema_terms.any? { |term| sql.include?(term) }
end
end
@@ -49,17 +49,19 @@
end
end
- context "an attribute on a class with no protected attributes" do
- let(:model) { define_model(:example, :attr => :string).new }
+ unless active_model_3_2?
+ context "an attribute on a class with no protected attributes" do
+ let(:model) { define_model(:example, :attr => :string).new }
- it "should accept being mass-assignable" do
- model.should allow_mass_assignment_of(:attr)
- end
+ it "should accept being mass-assignable" do
+ model.should allow_mass_assignment_of(:attr)
+ end
- it "should assign a negative failure message" do
- matcher = allow_mass_assignment_of(:attr)
- matcher.matches?(model).should == true
- matcher.negative_failure_message.should_not be_nil
+ it "should assign a negative failure message" do
+ matcher = allow_mass_assignment_of(:attr)
+ matcher.matches?(model).should == true
+ matcher.negative_failure_message.should_not be_nil
+ end
end
end
@@ -75,7 +77,7 @@
end
end
- if ::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 1
+ if active_model_3_1?
context "an attribute included in the mass-assignment whitelist for admin role only" do
let(:model) do
define_model(:example, :attr => :string) do
@@ -5,6 +5,7 @@
before do
@model = define_model(:example, :attr => :string,
:other => :integer) do
+ attr_accessible :attr, :other
validates_uniqueness_of :attr
end.new
end
@@ -47,6 +48,7 @@
context "a unique attribute with a custom error and an existing value" do
before do
@model = define_model(:example, :attr => :string) do
+ attr_accessible :attr
validates_uniqueness_of :attr, :message => 'Bad value'
end.new
Example.create!(:attr => 'value')
@@ -70,6 +72,7 @@
@model = define_model(:example, :attr => :string,
:scope1 => :integer,
:scope2 => :integer) do
+ attr_accessible :attr, :scope1, :scope2
validates_uniqueness_of :attr, :scope => [:scope1, :scope2]
end.new
@existing = Example.create!(:attr => 'value', :scope1 => 1, :scope2 => 2)
@@ -98,7 +101,9 @@
context "a non-unique attribute with an existing value" do
before do
- @model = define_model(:example, :attr => :string).new
+ @model = define_model(:example, :attr => :string) do
+ attr_accessible :attr
+ end.new
Example.create!(:attr => 'value')
end
@@ -110,6 +115,7 @@
context "a case sensitive unique attribute with an existing value" do
before do
@model = define_model(:example, :attr => :string) do
+ attr_accessible :attr
validates_uniqueness_of :attr, :case_sensitive => true
end.new
Example.create!(:attr => 'value')
@@ -127,6 +133,7 @@
context "a case sensitive unique integer attribute with an existing value" do
before do
@model = define_model(:example, :attr => :integer) do
+ attr_accessible :attr
validates_uniqueness_of :attr, :case_sensitive => true
end.new
Example.create!(:attr => 'value')
@@ -0,0 +1,9 @@
+RSpec.configure do |c|
+ def active_model_3_1?
+ ::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 1
+ end
+
+ def active_model_3_2?
+ ::ActiveModel::VERSION::MAJOR == 3 && ::ActiveModel::VERSION::MINOR >= 2
+ end
+end

0 comments on commit aff2824

Please sign in to comment.