Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)
http://hobocentral.net
103 stars 39 forks source link

Compatibility to Rspec #179

Closed haslinger closed 8 years ago

haslinger commented 8 years ago

I am using rspec 3.4.0 to test my app. Whenever I call a crud method in a controller spec, e.g. get :index I get the error message: ArgumentError: path already is a Resolver class

I typical stack trace would look like this:

Failure/Error: get :index

     ArgumentError:
       path already is a Resolver class
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:309:in `initialize'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/dryml-2.2.4/lib/dryml/extensions/action_controller/dryml_methods.rb:4:in `block (2 levels) in <top (required)>'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:in `instance_exec'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:446:in `block in make_lambda'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:164:in `call'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:164:in `block in halting'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `call'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `block in call'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `each'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:504:in `call'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/callbacks.rb:81:in `run_callbacks'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/abstract_controller/callbacks.rb:19:in `process_action'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/metal/rescue.rb:29:in `process_action'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/notifications.rb:164:in `block in instrument'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/notifications.rb:164:in `instrument'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/searchkick-0.9.1/lib/searchkick/logging.rb:107:in `process_action'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/activerecord-4.2.5/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/abstract_controller/base.rb:137:in `process'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionview-4.2.5/lib/action_view/rendering.rb:30:in `process'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/test_case.rb:639:in `process'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/test_case.rb:67:in `process'
     # /home/stefan/.rvm/gems/ruby-2.1.5/gems/actionpack-4.2.5/lib/action_controller/test_case.rb:514:in `get'
     # ./spec/controllers/sales/front_controller_spec.rb:13:in `block (3 levels) in <top (required)>'

Currently, I have no idea how to fix this.

Update: I was concerned, that the searchkick call in the stacktrace could be a reason, so I removed searchkick from my app, same issue.

haslinger commented 8 years ago

OK, I found a workaround: Fixing Rspec to 3.3.0. I'm not sure, if somebody wants to look into this, I would be fine with closing the issue.

iox commented 8 years ago

I have reproduced this issue. The problem was introduced by this change in rspec-rails: https://github.com/rspec/rspec-rails/commit/80637fc9ff26a4ae7b80ce96a3aa8fcc744faea2

So you can actually use rspec 3.4.0, but you need rspec-rails 3.4.0, instead of 3.4.2:

gem 'rspec-rails', '= 3.4.0'
gem 'rspec', '= 3.4.0'

The origin of this issue is that Rspec hacks the template rendering system in order to run controller tests faster, without rendering the views. After a Rails upgrade, their hack broke and they rewrote it. But that new hack is not working with Hobo.

I'm sure we could fix in our side with enough time, but I think we can live for now by avoiding that hack. We can use render_views with the latest rspec versions and it seems to work perfectly fine:

gem 'rspec-rails', '= 3.4.2'
gem 'rspec', '= 3.4.0'
require 'rails_helper'

RSpec.describe TodosController, :type => :controller do
  render_views

  describe "GET index" do
    it "assigns @example" do
      get :index
      expect(assigns(:example)).to eq([1,2,3])
    end
  end
end