jcasimir/draper — pull request #138 by markburns (2012-03-04 05:32:36+00:00)
Title: So I got this pending spec passing, but not sure if it's doing the right thing.

I've been reading the source of draper to try and understand how it works and enroute it's natural for me to refactor code as I go along.

Anyway, I was curious about the pending spec and decided to try to get it to pass.
It is passing, but I'm not sure of what 'context' in the options means and so not sure if the tests are unclear, if my code is doing the right thing, or if it's doing the wrong thing but we need more tests.

The wording of the comment:
"Pass in an optional context inside the options hash is stored for later use." is slightly confusing.

```ruby
it "uses the options hash in the decorator instantiation" do
Product.should_receive(:find_by_name_and_count_and_size).
with("apples", 7, "large", {:role => :admin}).and_return Product.first

pd = ProductDecorator.find_by_name_and_count_and_size("apples", 7, "large", {:role => :admin})
pd.context[:role].should == :admin
end
```

```
def self.method_missing(method, *args, &block)
instance = model_class.send method, *args, &block

@options ||= {}
@options.merge!({:context => args.last }) if args.last.is_a? Hash

instance = self.decorate(instance, @options) if method.to_s.match(/^find_by.*/)

instance
end

```