Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b3933d5a87
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (48 sloc) 2.181 kb
require File.dirname(__FILE__) + "/spec_helper"
describe "have_many_to_one_matcher" do
before :all do
define_model(:Item)
define_model(:Comment){
many_to_one :item
}
end
subject{ Comment }
describe "messages" do
describe "without option" do
it "should contain a description" do
@matcher = have_many_to_one :item
@matcher.description.should == "have a many_to_one association :item"
end
it "should set failure messages" do
@matcher = have_many_to_one :item
@matcher.matches? subject
@matcher.failure_message.should == "expected Comment to have a many_to_one association :item"
@matcher.negative_failure_message.should == @matcher.failure_message.gsub("to have", "to not have")
end
end
describe "with options" do
it "should contain a description" do
@matcher = have_many_to_one :item, :class_name => "Item"
@matcher.description.should == 'have a many_to_one association :item with :class_name => "Item"'
end
it "should set failure messages" do
@matcher = have_many_to_one :item, :class_name => "Item"
@matcher.matches? subject
@matcher.failure_message.should == 'expected Comment to have a many_to_one association :item with :class_name => "Item"'
@matcher.negative_failure_message.should == @matcher.failure_message.gsub("to have", "to not have")
end
it "should explicit used options if different than expected" do
@matcher = have_many_to_one :item, :class_name => "Price"
@matcher.matches? subject
@matcher.failure_message.should == 'expected Comment to have a many_to_one association :item with :class_name => "Price" expected :class_name == "Price" but found "Item" instead'
@matcher.negative_failure_message.should == @matcher.failure_message.gsub("to have", "to not have")
end
end
end
describe "matchers" do
it{ should have_many_to_one(:item) }
it{ should have_many_to_one(:item, :class_name => "Item") }
it{ should_not have_many_to_one(:price) }
it{ should_not have_many_to_one(:item, :class_name => "Price") }
end
end
Jump to Line
Something went wrong with that request. Please try again.