Machinist + RSpec and reserved words
I have a blueprint:
Model.blueprint(:something) do
name "Some name"
context "some context"
end
"context" is an attribute of Model, but it is also a reserved word of RSpec. When I try to make and开发者_如何转开发 object I get ArgumentError on "context" line.
Any ideas how to overcome this situation?
Unable to replicate this with Machinist 2.0.0.beta2.
Machinist works by overriding method_missing?
and then assigning attributes based on those arguments. If rspec is somehow assigning a context
method to Machinist's Lathe's objects, then that method will be called before method_missing?
. If you're still experiencing this problem, you could try using remove_method :context
before evaluating attributes:
Model.blueprint(:something) do
remove_method :context
name "Some name"
context "some context"
alias_method :context, :describe
end
I can't tell if that would work, as I can't replicate it locally, but I would give it a shot.
精彩评论