title: Draper - NoMethodError with RSpec testing for decorator
body: <p>I'm receiving the following error when trying to test with <a href="https://github.com/jcasimir/draper" rel="nofollow">Draper</a>:</p>
  
  <pre><code>NoMethodError: undefined method 'with_unit' for nil:NilClass
  </code></pre>
  
  <p>Here's my test code:</p>
  
  <pre><code># spec/decorators/food_decorator_spec.rb
  require 'spec_helper'
  
  describe FoodDecorator do
    before { ApplicationController.new.set_current_view_context }
    FactoryGirl.create(:food)
    @food = FoodDecorator.first
  
    specify { @food.with_unit('water').should == "85.56 g" }
  end
  </code></pre>
  
  <p>And here's my decorator code:</p>
  
  <pre><code>class FoodDecorator &lt; ApplicationDecorator
    decorates :food
  
    def with_unit(nutrient)
      model.send(nutrient.to_sym).to_s + " g"
    end
  end
  </code></pre>
  
  <p>My research suggests that the line <code>ApplicationController.new.set_current_view_context</code> should fix this, but it hasn't. Any thoughts?</p>