How do I write an RSpec test to unit-test this interesting metaprogramming code?
- by Kyle Kaitan
Here's some simple code that, for each argument specified, will add specific get/set methods named after that argument. If you write attr_option :foo, :bar, then you will see #foo/foo= and #bar/bar= instance methods on Config:
module Configurator
class Config
def initialize()
@options = {}
end
def self.attr_option(*args)
…