forked from rspec/rspec-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add should and should_not to CollectionProxy
- Loading branch information
1 parent
f8ab2ba
commit abfd0fc
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |