Class: Spec::FactoryGirl::Matchers::BeCreatedByFactory
- Inherits:
-
Base
- Object
- Base
- Spec::FactoryGirl::Matchers::BeCreatedByFactory
show all
- Defined in:
- lib/spec/factory_girl/matchers/be_created_by_factory.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#description ⇒ Object
5
6
7
|
# File 'lib/spec/factory_girl/matchers/be_created_by_factory.rb', line 5
def description
"create instance of '#{@target}' by factory '#{@factory}'"
end
|
#failure_message_for_should ⇒ Object
22
23
24
|
# File 'lib/spec/factory_girl/matchers/be_created_by_factory.rb', line 22
def failure_message_for_should
"expected #{@target.inspect} to be created by factory '#{@factory}'\n" + @errors.join("\n")
end
|
#failure_message_for_should_not ⇒ Object
26
27
28
|
# File 'lib/spec/factory_girl/matchers/be_created_by_factory.rb', line 26
def failure_message_for_should_not
"expected #{@target.inspect} not to be created by factory '#{@factory}'"
end
|
#matches?(target) ⇒ Boolean
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/spec/factory_girl/matchers/be_created_by_factory.rb', line 9
def matches?(target)
prepare_matches(target)
begin
@result = Factory.create(@factory)
rescue ActiveRecord::RecordInvalid => e
@errors << e.to_s
return false
end
super
end
|