Permalink
Browse files

Add should and should_not to CollectionProxy

- Fixes #588.
- Fixes #445.
  • Loading branch information...
1 parent f8ab2ba commit abfd0fc6a7e4a8b0bf916151be5096f22943d77f @dchelimsky dchelimsky committed Aug 3, 2012
View
@@ -1,3 +1,10 @@
+### dev
+[full changelog](http://github.com/rspec/rspec-rails/compare/v2.11.0...master)
+
+Bug fixes
+
+* Add `should` and `should_not` to `CollectionProxy` (David Chelimsky)
+
### 2.11.0 / 2012-07-07
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.10.1...v2.11.0)
@@ -1 +1,2 @@
require 'rspec/rails/extensions/active_record/base'
+require 'rspec/rails/extensions/active_record/collection_proxy'
@@ -0,0 +1,5 @@
+RSpec.configure do |config|
+ config.expect_with :rspec do |c|
+ c.add_should_and_should_not_to ActiveRecord::Associations::CollectionProxy
+ end
+end
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+class CollectionOwner < ActiveRecord::Base
+ connection.execute <<-SQL
+ CREATE TABLE collection_owners (
+ id integer PRIMARY KEY AUTOINCREMENT
+ )
+SQL
+ has_many :associated_items do
+ def has_some_quality?; true end
+ end
+end
+
+class AssociatedItem < ActiveRecord::Base
+ connection.execute <<-SQL
+ CREATE TABLE associated_items (
+ id integer PRIMARY KEY AUTOINCREMENT,
+ collection_owner_id integer
+ )
+SQL
+ belongs_to :collection_owner
+end
+
+describe "should have_xxx" do
+ it "works with ActiveRecord::Associations::CollectionProxy" do
+ owner = CollectionOwner.new
+ owner.associated_items.should have_some_quality
+ end
+end

0 comments on commit abfd0fc

Please sign in to comment.