Skip to content

Instantly share code, notes, and snippets.

@jeffdeville
Created November 1, 2012 03:14
Show Gist options
  • Select an option

  • Save jeffdeville/3991411 to your computer and use it in GitHub Desktop.

Select an option

Save jeffdeville/3991411 to your computer and use it in GitHub Desktop.
describe FactoryGirl::EvaluatorClassDefiner do
let(:simple_attribute) {
stub("simple attribute", name: :simple, to_proc: -> { 1 })
}
let(:relative_attribute) {
stub("relative attribute", name: :relative, to_proc: -> { simple + 1 })
}
let(:evaluator) {
class_definer = FactoryGirl::EvaluatorClassDefiner.new(
[simple_attribute, relative_attribute],
FactoryGirl::Evaluator
)
class_definer.evaluator_class.new(
# is the line below needed?
stub("build strategy", add_observer: true)
)
}
it "adds each attribute to the evaluator" do
evaluator.simple.should eq 1
end
it "evaluates the block in the context of the evaluator" do
evaluator.relative.should eq 2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment