An ERB/bundler behaviour I don't understand

I have this code in a file that’s used to … render templates.

require 'erb'
require 'ostruct'

MISSING_CONFIG_MARKER = :config_key_and_value_missing

def render(template, configuration_data)
  config_object = OpenStruct.new(configuration_data)
  config_object.table.default = MISSING_CONFIG_MARKER
  ERB.new(template).result(config_object.instance_eval { binding })
end

I also have some tests for this, that show a behaviour I don’t understand:
When running the tests in the context of Bundler, one these fails (one that expects to find the MISSING_CONFIG_MARKER. However, when not running in bundler context, all tests pass.

I’d like to understand why that is, and ideally learn what I need to do to have the set default being used in the context of Bundler as well.

To illustrate all this I’ve set up a repository with a minimal (I think) project, showing the behaviour. See https://github.com/s2k/erb-templating

2 Likes