Skip to content

Commit

Permalink
Add should and should_not to CollectionProxy
Browse files Browse the repository at this point in the history
- Fixes rspec#588.
- Fixes rspec#445.
  • Loading branch information
dchelimsky committed Aug 3, 2012
1 parent f8ab2ba commit abfd0fc
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
1 change: 1 addition & 0 deletions lib/rspec/rails/extensions.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
require 'rspec/rails/extensions/active_record/base'
require 'rspec/rails/extensions/active_record/collection_proxy'
5 changes: 5 additions & 0 deletions lib/rspec/rails/extensions/active_record/collection_proxy.rb
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions spec/rspec/rails/matchers/has_spec.rb
Original file line number Diff line number Diff line change
@@ -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.