pat / combustion

Simple, elegant testing for Rails Engines
MIT License
708 stars 51 forks source link

uninitialized constant ActionController::Base #52

Closed terenceponce closed 10 years ago

terenceponce commented 11 years ago

I'm new to Rails engines and this gem and I'm having this problem when I'm trying to access the dummy app in localhost:9292:

NameError: uninitialized constant ActionController::Base
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:33:in `ext'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:17:in `match?'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:58:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:511:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:97:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:49:in `_call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:37:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/showexceptions.rb:24:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/chunked.rb:43:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
    /Users/terence/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

Here's my config.ru:

require 'rubygems'
require 'bundler'

Bundler.require :default, :test

Combustion.initialize!
run Combustion::Application

and here's the gemspec file:

$:.push File.expand_path("../lib", __FILE__)

# Maintain your gem's version:
require "saasify/version"

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
  s.name        = "saasify"
  s.version     = Saasify::VERSION
  s.authors     = ["Eumir Gaspar and Terence Ponce"]
  s.email       = ["dev+eumir+terence@aelogica.com"]
  s.homepage    = "http://example.com"
  s.description = "Saasify"

  s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
  s.test_files = Dir["test/**/*"]

  s.add_dependency "rails", "~> 4.0.0"
  s.add_dependency 'devise', '~> 3.0.0'
  s.add_dependency 'rails_admin', '~> 0.5.0'
  s.add_dependency 'rocket_pants', '~> 1.0'
  s.add_dependency 'money-rails', '~> 0.8.1'

  s.add_development_dependency 'rspec-rails', '~> 2.0'
  s.add_development_dependency 'combustion', '~> 0.5.1'
  s.add_development_dependency 'mysql2'
  s.add_development_dependency 'factory_girl_rails'
  s.add_development_dependency 'database_cleaner'
  s.add_development_dependency 'vcr'
  s.add_development_dependency 'webmock', '~> 1.11.0'
end

Here's my spec_helper.rb:

# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../dummy/config/environment", __FILE__)
require 'bundler/setup'
require 'combustion'

Combustion.path = 'spec/dummy'
Combustion.initialize! :active_record, :action_controller, :action_view, :sprockets

require 'rspec/rails'
require 'rspec/autorun'

ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

RSpec.configure do |config|
  # ## Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  config.fixture_path = "#{Rails.root}/spec/fixtures"

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = true

  # If true, the base class of anonymous controllers will be inferred
  # automatically. This will be the default behavior in future versions of
  # rspec-rails.
  config.infer_base_class_for_anonymous_controllers = false

  # Run specs in random order to surface order dependencies. If you find an
  # order dependency and want to debug it, you can fix the order by providing
  # the seed, which is printed after each run.
  #     --seed 1234
  config.order = "random"
end

I followed the README as well as #27 and I still can't make it work on the browser. Did I miss anything here?

severinraez commented 10 years ago

I encountered the same issue here.

Fixed it by changing the

Combustion.initialize!

to

Combustion.initialize! :active_record, :action_controller, :action_view, :sprockets

in config.ru. As you did, I additionally followed #27, which is still neccessary.

pat commented 10 years ago

Thanks for picking that up @taetschgring - I've just pushed a tweak for the config.ru template and README, so that'll be fixed in future releases.