title: Rails 4: Undefined method on module
body: <p>I have a module in <code>app/misc/dsl/builder.rb</code> that has this code</p>
  
  <pre><code>module Dsl
    class Builder
      def initialize(context, &amp;block)
        return if not block_given?
  
        parent_context = block.binding.eval "self"
        parent_context.extend Proxy
        parent_context.object = context 
  
        parent_context.instance_eval &amp;block
      end
    end
  
    def self.set_context(context, &amp;block)
      Dsl::Builder.new(context, &amp;block)
    end
  end
  </code></pre>
  
  <p>Note: this directory <code>misc</code> is preloaded in <code>application.rb</code></p>
  
  <pre><code>config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**/}'), 
    Rails.root.join('app', 'misc', '{**/}')
  ]
  </code></pre>
  
  <p>Then, somewhere in the text (lets say at <code>foo.rb</code>) I have this code:</p>
  
  <pre><code>Dsl.set_context(obj) do
    #some code with obj receiving messages
  end
  </code></pre>
  
  <p>The test stack we are using consists on Zeus+Guard+Rspec. Now, lets say I rewrite the code to something not working</p>
  
  <pre><code>Dsl.set_context(obj) do
    asdqwe #this message does not exists
  end
  </code></pre>
  
  <p>From times to times, I receive this baffling message</p>
  
  <pre><code>  1) SomeOtherClass search_hash receiving keywords params should query for those keywords
       Failure/Error: subject.search_hash
       NoMethodError:
         undefined method `set_context' for Dsl:Module
       # ./app/misc/product_query.rb:116:in `base_search_hash'
       # ./app/misc/product_query.rb:25:in `search_hash'
       # ./spec/misc/product_query_spec.rb:78:in `block (4 levels) in &lt;top (required)&gt;'
       # -e:1:in `&lt;main&gt;'
  </code></pre>
  
  <p>instead of the correct message that should be regarding <code>undefined method asdqwe</code></p>
  
  <p>Any clue about this?</p>