I'm running into an issue when trying to create an open struct with an attribute that has the same name as one of the OpenStruct instance methods. Specifically, i'd like to create an open struct that has an attribute capture
. I'm using this as a stub in an rspec test, so i can't change the name of the method (it must be capture
)
#=> OpenStruct.new(capture: true).capture
#=> ArgumentError: wrong number of arguments (0 for 1)
looking at the OpenStruct methods, it has a method capture
and it is this method that is getting called. Is there a way to instantiate an open struct with an attribute of the same name as one of its methods?
for clarity, i specifically need the method capture, which i've confirmed breaks on rails 4.0.x but not rails 5, but this situation holds true for any method openstruct might have.
#=> OpenStruct.new(class: true).class
#=> OpenStruct