In my code, I put a begin
-rescue
block to capture errors when Array(decorated)
throws an error during a spec run. Note: @current_site
is the one in this example, but it also happens with other objects from here on, if I let the specs run.
2.0.0 (#<Admin::Site::SitesController:0x007fb2dd58d6e8>):0 > @current_site.class
=> SiteDecorator < ApplicationDecorator
2.0.0 (#<Admin::Site::SitesController:0x007fb2dd58d6e8>):0 > Array(@current_site)
NoMethodError: undefined method `to_a' for #<Site:0x007fb2dd5dbf50>
from /Users/ramon/.rvm/gems/ruby-2.0.0-p353/gems/activemodel-4.0.2/lib/active_model/attribute_methods.rb:439:in `method_missing'
Based on the error and its backtrace, it seems that the decorator responds_to
to_a
but when it finally reaches the object
, it blows up. If I open a separate Rails console, and I try to replicate this issue, I am unable to do so. I have a feeling that something is making all future decorated objects respond_to
to_a
and it breaks the tests from there and onwards.