You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.
I'm trying to use Fabricator and have come across another collision (similar to the klass one in #92). Inspecting self.methods while in a Fabricator yields a whole slew of possible collisions (see below).
For me, I had a column called "display" and since there is a "display" method below, method_missing is never invoked. Perhaps the instance_eval needs to be done on a much more naked object?
I think the strategy would be to instance_eval against a blank slate object, proxying your DSL methods, and leaving at least one method usable for escaping other reserved words:
Fabricator(:store) do
uuid "foo"
display "bar"
__attr :attributes "my attrs"
end
I'm trying to use Fabricator and have come across another collision (similar to the klass one in #92). Inspecting self.methods while in a Fabricator yields a whole slew of possible collisions (see below).
For me, I had a column called "display" and since there is a "display" method below, method_missing is never invoked. Perhaps the instance_eval needs to be done on a much more naked object?
https://github.com/masover/blankslate
% cat fabrication_collision_test.rb
require 'fabrication'
require 'faker'
class Store
attr_accessor :uuid, :display
end
Fabricator(:store) do
uuid { Faker::Lorem.characters(32) }
puts methods.inspect
display { "bar" }
end
% bundle exec ruby fabrication_collision_test.rb
[:klass, :klass=, :after_build, :after_create, :attribute, :append_or_update_attribute, :attributes=, :attributes, :callbacks=, :callbacks, :generator, :build, :fabricate, :to_attributes, :init_with, :merge, :method_missing, :on_init, :initialize_with, :parse_method_name, :transient, :sequence, :psych_to_yaml, :to_yaml_properties, :to_yaml, :nil?, :===, :=
, :!, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :initialize_dup, :initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend, :display, :method, :public_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :gem, :suppress_warnings, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :send, :id]The text was updated successfully, but these errors were encountered: