Code Monkey home page Code Monkey logo

combustion's Introduction

Combustion

Combustion is a library to help you test your Rails Engines in a simple and effective manner, instead of creating a full Rails application in your spec or test folder.

It allows you to write your specs within the context of your engine, using only the parts of a Rails app you need.

Usage

Get the gem into either your gemspec or your Gemfile, depending on how you manage your engine's dependencies:

# gemspec
gem.add_development_dependency 'combustion', '~> 1.3'

# Gemfile
gem 'combustion', '~> 1.3'

In your spec_helper.rb, get Combustion to set itself up - which has to happen before you introduce rspec/rails and - if being used - capybara/rails. Here's an example within context:

require 'bundler'

Bundler.require :default, :development

# If you're using all parts of Rails:
Combustion.initialize! :all
# Or, load just what you need:
# Combustion.initialize! :active_record, :action_controller

require 'rspec/rails'
# If you're using Capybara:
# require 'capybara/rails'

RSpec.configure do |config|
  config.use_transactional_fixtures = true
end

Please note that using :all as an argument for Combustion.initialize! will load all key parts of Rails that are considered essential for that version. For example: ActiveJob is only loaded for Rails 4.2 onwards, and Sprockets is only loaded for Rails 3.1-6.1 (as it is no longer part of the default set in 7.0).

You'll also want to run the generator that creates a minimal set of files expected by Rails - run this in the directory of your engine:

combust

# or, if bundling with the git repo:
bundle exec combust

Minitest support is considered to be experimental, but it's certainly working for some. Comments on others' experiences are welcome!

What Combustion is doing is setting up a Rails application at spec/internal - but you only need to add the files within that directory that you're going to use. Read on for some detail about what that involves.

If you want to use Cucumber, I recommend starting with these notes in issue #16 from Niklas Cathor.

Configuring a different test app directory

If you want your app to be located somewhere other than spec/internal, then make sure you configure it before you call Combustion.initialize!:

Combustion.path = 'spec/dummy'
Combustion.initialize! :all

Configuring which Rails modules should be loaded.

By default, Combustion doesn't come with any of the Rails stack. You can customise this though - just pass in what you'd like loaded to the Combustion.initialize! call:

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

And then in your engine's Gemfile:

group :test do
  gem 'activerecord'
  gem 'actionpack' # action_controller, action_view
  gem 'sprockets'
end

Make sure to specify the appropriate version that you want to use.

ActiveSupport and Railties are always loaded, as they're an integral part of Rails.

Using Models and ActiveRecord

If you're using ActiveRecord, then there are two critical files within your internal Rails app at spec/internal that you'll need to modify:

  • config/database.yml
  • db/schema.rb

Both follow the same structure as in any normal Rails application - and the schema file lets you avoid migrations, as it gets run whenever the test suite starts. Here's a quick sample (note that tables are overwritten if they already exist - this is necessary):

ActiveRecord::Schema.define do
  create_table(:pages, :force => true) do |t|
    t.string :name
    t.text   :content
    t.timestamps
  end
end

Disabling Database Preparation

If you are preparing your own database manually or through different processes, you can disable different parts of the setup process by the following flags: :database_reset, :load_schema, and :database_migrate. All default to true.

Combustion.initialize! :active_record,
  :database_reset => false,
  :load_schema    => false

Configuring Combustion to initialise the test db from a .sql file instead of schema.rb

Name the file structure.sql and configure Combustion to use it before initialising:

Combustion.schema_format = :sql
Combustion.initialize! :all

Any models that aren't provided by your engine should be located at spec/internal/app/models.

Using ActionController and ActionView

You'll only need to add controllers and views to your internal Rails app for whatever you're testing that your engine doesn't provide - this may be nothing at all, so perhaps you don't even need spec/internal/app/views or spec/internal/app/controllers directories.

However, if you're doing any testing of your engine's controllers or views, then you're going to need routes set up for them - so modify spec/internal/config/routes.rb accordingly:

Rails.application.routes.draw do
  resources :pages
end

Just like in a standard Rails app, if you have a mounted engine, then its routes are accessible through whatever it has been loaded as.

Customizing Rails application settings

If you would like to specify any Rails configuration parameter, you can do it without creating any environment file, simply passing a block to Combustion.initialize! like this:

Combustion.initialize! :all do
  config.active_record.whitelist_attributes = false
end

Values given through the initialize! block will be set during Rails initialization process, exactly before the corresponding environment file inside spec/internals/config/enviroments is loaded (when that file exists), overriding Combustion's defaults.

Parameters defined in, for instance, spec/internals/config/environments/test.rb, would override Combustion's defaults and also config settings passed to initialize!.

Using other Rails-focused libraries

Be aware that other gems may require parts of Rails when they're loaded, and this could cause some issues with Combustion's own setup. You may need to manage the loading yourself by setting :require to false in your Gemfile for the gem in question, and then requiring it manually in your spec_helper. View issue #33 for an example with FactoryBot.

Environment and Logging

Your tests will execute within the test environment for the internal Rails app - and so logs are available at spec/internal/log/test.log. You should probably create that log directory so Rails doesn't complain.

Rack it up

Once you've got this set up, you can fire up your test environment quite easily with Rack - a config.ru file is provided by the generator. Just run rackup and visit http://localhost:9292.

Get your test on!

Now you're good to go - you can write specs within your engine's spec directory just like you were testing a full Rails application - models in spec/models, controllers in spec/controllers. If you bring Capybara into the mix, then the standard helpers from that will be loaded as well.

require 'spec_helper'

describe Page do
  describe '#valid' do
    it 'requires a name' do
      # This is just an example. Go write your own tests!
    end
  end
end

Compatibility

The current test matrix covers MRI 2.4 to 3.1, and Rails 3.1 to 7.0. It will possibly work on older versions and other Ruby implementations as well.

You can also use Combustion with multiple versions of Rails to test compatibility across them. Appraisal is a gem that can help with this, and a good starting reference is the Thinking Sphinx test suite, which runs against multiple versions of Rails.

Limitations and Known Issues

Combustion is currently written with the expectation it'll be used with RSpec, but others have got it working with Minitest. I'd love to make this more flexible - if you want to give it a shot before I get around to it, patches are very much welcome.

I've not tried using this with Cucumber, but it should work in theory without too much hassle. Let me know if I'm wrong!

Contributing

Please note that this project now has a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Contributions are very much welcome - but keep in mind the following:

  • Keep patches in a separate branch
  • Don't mess with the version or history file. I'll take care of that when the patch is merged in.

The tests are extremely minimal, and patches to extend the suite are especially welcome.

Credits

Copyright (c) 2011-2021, Combustion is developed and maintained by Pat Allan, and is released under the open MIT Licence. Many thanks to HyperTiny for encouraging its development, and all who have contributed patches.

combustion's People

Contributors

ankane avatar artofhuman avatar bibendi avatar bishwahang avatar bricker avatar cbeer avatar elektronaut avatar erkan-yilmaz avatar geoffroh avatar joshbuker avatar jrochkind avatar ktdreyer avatar marten avatar mikegee avatar mjankowski avatar olleolleolle avatar pabloh avatar parndt avatar pat avatar patorash avatar sergei-kucher avatar spyderdfx avatar utkarsh2102 avatar warrenseen avatar wwahammy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

combustion's Issues

Support for Zeus?

It's not clear how one would use zeus / spring and combustion at the same time, any thoughts?

Allow different database environments

In my projects I use combustion not only for RSpec specs but also to run the engine as an application via rackup and rack-console. It would be nice to have the option to run those commands in the development environment since this would allow to run the app and specs at the same time (and other things).

Currently the database is hardcoded to the test environment, maybe this could either check for Rails.env or something like:

Combustion.initialize! :all, database_reset: false, database_environment: :development

in config.ru.

If anybody is having the same issue, I currently use the following workaround (combustion v0.8):

In config.ru:

unless Rails.env.development?
  abort "Combustion should not be reopened in #{Rails.env} environment."
end

module Combustion
  module Databases
    class Base
      def reset
        drop
        create

        establish_connection :development
      end
    end
  end
end

module Combustion
  class Database
    class Reset
      def call
        configuration = ActiveRecord::Base.configurations['development']
        adapter = configuration['adapter'] || configuration['url'].split('://').first
        operator_class(adapter).new(configuration).reset
      end
    end
  end
end

In rails_helper.rb/spec_helper.rb:

require 'rails'

unless Rails.env.test?
  abort "Combustion should not be reopened in #{Rails.env} environment."
end

module Combustion
  class Database
    class Reset
      def call
        configuration = ActiveRecord::Base.configurations['test']
        adapter = configuration['adapter'] || configuration['url'].split('://').first
        operator_class(adapter).new(configuration).reset
      end
    end
  end
end

This allows me to run a rackup session and rspec at the same time.

Mounting the engine gives errors, adding manual route works.

Mounting the engine in spec/internal/config/routes.rb gives routing errors (route not found etc.):

  mount Foo::Engine, at: "/foo"

While manually adding a route to the engine works fine and all tests pass:

  post "/foo/widgets", to: "foo/widgets#create"

Any ideas why this happens? Could it be a bug or is it an oversight on my behalf?

Thank you!

uninitialized constant ActionController::Base

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       = ["[email protected]"]
  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?

Rackup has error trying to load engine gem

This is the stack trace that I get when trying to run rackup, not sure what the problem is.

/home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in     `rescue in block (2 levels) in require': There was an error while trying to load the gem 'ciqap_cd4'. (Bundler::GemRequireError)
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from /home/ericenns/ciqap_cd4/config.ru:4:in `block in <main>'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
    from /home/ericenns/ciqap_cd4/config.ru:in `new'
    from /home/ericenns/ciqap_cd4/config.ru:in `<main>'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/lib/rack/server.rb:147:in `start'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/gems/rack-1.6.4/bin/rackup:4:in `<top (required)>'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/bin/rackup:23:in `load'
    from /home/ericenns/.rvm/gems/ruby-2.2.3@ciqap_cd4/bin/rackup:23:in `<main>'

No connection pool with 'primary' found

hi guys iยดm lost,

def retrieve_connection(spec_name) #:nodoc:         
pool = retrieve_connection_pool(spec_name)         
raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found." unless pool         pool.connection       
end
-- | --

activerecord (5.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:1007:in `retrieve_connection'
activerecord (5.2.0) lib/active_record/connection_handling.rb:118:in `retrieve_connection'
activerecord (5.2.0) lib/active_record/connection_handling.rb:90:in `connection'
activerecord (5.2.0) lib/active_record/migration.rb:554:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.0) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.0) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.6.2) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.6.2) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `catch'
web-console (3.6.2) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.0) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.0) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.5) lib/rack/method_override.rb:22:in `call'
rack (2.0.5) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.5) lib/rack/sendfile.rb:111:in `call'
railties (5.2.0) lib/rails/engine.rb:524:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

Any ideas?

uninitialized constant Rails

i've created new engine using rails plugin new some --mountable -T
and followed readme for basic setup
when i try to run rackup i got following error
what do i miss?

Mac-mini:some danil$ rackup
/Users/danil/Sites/temp/some/lib/some/engine.rb:2:in `<module:Some>': uninitialized constant Rails (NameError)
    from /Users/danil/Sites/temp/some/lib/some/engine.rb:1:in `<top (required)>'
    from /Users/danil/Sites/temp/some/lib/some.rb:1:in `require'
    from /Users/danil/Sites/temp/some/lib/some.rb:1:in `<top (required)>'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
    from /Users/danil/Sites/temp/some/config.ru:5:in `block in <main>'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/danil/Sites/temp/some/config.ru:1:in `new'
    from /Users/danil/Sites/temp/some/config.ru:1:in `<main>'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/bin/rackup:19:in `load'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/bin/rackup:19:in `<main>'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/danil/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'

Compatibility with Rails 3.2

Hi,
I just stumbled upon a problem while testing an activerecord extension.
The tests pass when the bundle is locked to Rails 3.1, but when the bundle is updated to Rails 3.2 the tests start to fail. However, the extension works normal in a Rails 3.2 app, the tests just fail in the combustion app. It seems as if the extension just isn't loaded anymore.
I will push the extension to github later today, so you can take a look if you like.

Best regards,
Fabian

Rack linting failure

With this added configuration:

class Combustion::Application
  config.middleware.use 'Rack::Lint'
end

We're getting this error: (ref activeadmin/arbre#20)

session #<ActionDispatch::Request::Session:0x7fb8fc52cd00 not yet loaded> must respond to store and []=

Rails.root: /Users/seanlinsley/codez/_/gems/arbre/spec/rails/stub_app

rack (1.5.2) lib/rack/lint.rb:20:in `assert'
rack (1.5.2) lib/rack/lint.rb:141:in `check_env'
rack (1.5.2) lib/rack/lint.rb:43:in `_call'
rack (1.5.2) lib/rack/lint.rb:37:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.4) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.4) lib/rails/engine.rb:514:in `call'
railties (4.1.4) lib/rails/application.rb:144:in `call'
rack-test (0.6.2) lib/rack/mock_session.rb:30:in `request'
rack-test (0.6.2) lib/rack/test.rb:230:in `process_request'
rack-test (0.6.2) lib/rack/test.rb:123:in `request'
actionpack (4.1.4) lib/action_dispatch/testing/integration.rb:309:in `process'
actionpack (4.1.4) lib/action_dispatch/testing/integration.rb:32:in `get'
actionpack (4.1.4) lib/action_dispatch/testing/integration.rb:343:in `block (2 levels) in <module:Runner>'
/Users/seanlinsley/codez/_/gems/arbre/spec/rails/integration/rendering_spec.rb:40:in `block (2 levels) in <top (required)>'
rspec-core (3.0.3) lib/rspec/core/example.rb:148:in `instance_exec'
rspec-core (3.0.3) lib/rspec/core/example.rb:148:in `block in run'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `call'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
rspec-rails (3.0.2) lib/rspec/rails/adapters.rb:72:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
rspec-core (3.0.3) lib/rspec/core/example.rb:294:in `instance_exec'
rspec-core (3.0.3) lib/rspec/core/example.rb:294:in `instance_exec'
rspec-core (3.0.3) lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `call'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
rspec-core (3.0.3) lib/rspec/core/hooks.rb:432:in `run'
rspec-core (3.0.3) lib/rspec/core/hooks.rb:485:in `run'
rspec-core (3.0.3) lib/rspec/core/example.rb:303:in `with_around_example_hooks'
rspec-core (3.0.3) lib/rspec/core/example.rb:145:in `run'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:494:in `block in run_examples'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:490:in `map'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:490:in `run_examples'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:457:in `run'
rspec-core (3.0.3) lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
rspec-core (3.0.3) lib/rspec/core/runner.rb:112:in `map'
rspec-core (3.0.3) lib/rspec/core/runner.rb:112:in `block in run_specs'
rspec-core (3.0.3) lib/rspec/core/reporter.rb:54:in `report'
rspec-core (3.0.3) lib/rspec/core/runner.rb:108:in `run_specs'
rspec-core (3.0.3) lib/rspec/core/runner.rb:86:in `run'
rspec-core (3.0.3) lib/rspec/core/runner.rb:70:in `run'
rspec-core (3.0.3) lib/rspec/core/runner.rb:38:in `invoke'
rspec-core (3.0.3) exe/rspec:4:in `<top (required)>'

Any idea what the problem is?

uninitialized constant Rails (NameError)

I really hope this isn't a duplicate of #27 - apologies if so !

 $ ruby --version
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-darwin13.0]
 $ rails --version
Rails 4.2.5
 $ rails plugin new combustable -T --mountable
      create
      create  README.rdoc
      create  Rakefile
      create  combustable.gemspec
      create  MIT-LICENSE
      create  .gitignore
      create  Gemfile
      create  app
      create  app/controllers/combustable/application_controller.rb
      create  app/helpers/combustable/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/combustable/application.html.erb
      create  app/assets/images/combustable
      create  app/assets/images/combustable/.keep
      create  config/routes.rb
      create  lib/combustable.rb
      create  lib/tasks/combustable_tasks.rake
      create  lib/combustable/version.rb
      create  lib/combustable/engine.rb
      create  app/assets/stylesheets/combustable/application.css
      create  app/assets/javascripts/combustable/application.js
      create  bin
      create  bin/rails
         run  bundle install
 $ cd combustable
# [ edit Gemfile ]
 $ bundle install
Resolving dependencies...
Using rake 10.5.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using nokogiri 1.6.7.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using loofah 2.0.3
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.5
Using rack 1.6.4
Using rack-test 0.6.3
Using actionpack 4.2.5
Using globalid 0.3.6
Using activejob 4.2.5
Using mime-types 2.99
Using mail 2.6.3
Using actionmailer 4.2.5
Using activemodel 4.2.5
Using arel 6.0.3
Using activerecord 4.2.5
Using bundler 1.10.0.rc
Using xpath 2.0.0
Using capybara 2.5.0
Using thor 0.19.1
Using railties 4.2.5
Using concurrent-ruby 1.0.0
Using sprockets 3.5.2
Using sprockets-rails 3.0.0
Using rails 4.2.5
Using combustable 0.0.1 from source at .
Using combustion 0.5.4
Using diff-lcs 1.2.5
Using rspec-support 3.3.0
Using rspec-core 3.3.2
Using rspec-expectations 3.3.1
Using rspec-mocks 3.3.2
Using rspec-rails 3.3.3
Using sqlite3 1.3.11
 $ bin/rails g rspec:install
      create  .rspec
      create  spec
      create  spec/spec_helper.rb
      create  spec/rails_helper.rb
# [ edit spec/spec_helper.rb - see below ]

 $ combust
      create  spec/internal
      create  spec/internal/config
      create  spec/internal/db
      create  spec/internal/log
      create  spec/internal/public
      create  spec/internal/config/routes.rb
      create  spec/internal/config/database.yml
      create  spec/internal/db/schema.rb
      create  config.ru
      create  spec/internal/public/favicon.ico
      create  spec/internal/log/.gitignore
 $ rackup
/Users/bobfarrell/dev/combustable/lib/combustable/engine.rb:2:in `<module:Combustable>': uninitialized constant Rails (NameError)
    from /Users/bobfarrell/dev/combustable/lib/combustable/engine.rb:1:in `<top (required)>'
    from /Users/bobfarrell/dev/combustable/lib/combustable.rb:1:in `require'
    from /Users/bobfarrell/dev/combustable/lib/combustable.rb:1:in `<top (required)>'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.0.rc/lib/bundler/runtime.rb:76:in `require'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.0.rc/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.0.rc/lib/bundler/runtime.rb:72:in `each'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.0.rc/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.0.rc/lib/bundler/runtime.rb:61:in `each'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.0.rc/lib/bundler/runtime.rb:61:in `require'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.0.rc/lib/bundler.rb:133:in `require'
    from /Users/bobfarrell/dev/combustable/config.ru:4:in `block in <main>'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
    from /Users/bobfarrell/dev/combustable/config.ru:in `new'
    from /Users/bobfarrell/dev/combustable/config.ru:in `<main>'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:147:in `start'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/rack-1.6.4/bin/rackup:4:in `<top (required)>'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/bin/rackup:23:in `load'
    from /Users/bobfarrell/.rbenv/versions/2.1.6/bin/rackup:23:in `<main>'

Gemfile:

source 'https://rubygems.org'

# Declare your gem's dependencies in combustable.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use a debugger
# gem 'byebug', group: [:development, :test]

group :test do
  gem 'combustion', '~> 0.5.4'
  gem 'rspec-rails'
  gem 'capybara'
end

spec/spec_helper.rb (I guess this isn't relevant ?)

require 'rubygems'
require 'bundler/setup'

require 'combustion'
require 'capybara/rspec'

Combustion.initialize! :all

require 'rspec/rails'
require 'capybara/rails'
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
# a separate helper file that requires the additional dependencies and performs
# the additional setup, and require it from the spec files that actually need
# it.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
  # rspec-expectations config goes here. You can use an alternate
  # assertion/expectation library such as wrong or the stdlib/minitest
  # assertions if you prefer.
  config.expect_with :rspec do |expectations|
    # This option will default to `true` in RSpec 4. It makes the `description`
    # and `failure_message` of custom matchers include text for helper methods
    # defined using `chain`, e.g.:
    #     be_bigger_than(2).and_smaller_than(4).description
    #     # => "be bigger than 2 and smaller than 4"
    # ...rather than:
    #     # => "be bigger than 2"
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end

  # rspec-mocks config goes here. You can use an alternate test double
  # library (such as bogus or mocha) by changing the `mock_with` option here.
  config.mock_with :rspec do |mocks|
    # Prevents you from mocking or stubbing a method that does not exist on
    # a real object. This is generally recommended, and will default to
    # `true` in RSpec 4.
    mocks.verify_partial_doubles = true
  end

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
  # These two settings work together to allow you to limit a spec run
  # to individual examples or groups you care about by tagging them with
  # `:focus` metadata. When nothing is tagged with `:focus`, all examples
  # get run.
  config.filter_run :focus
  config.run_all_when_everything_filtered = true

  # Allows RSpec to persist some state between runs in order to support
  # the `--only-failures` and `--next-failure` CLI options. We recommend
  # you configure your source control system to ignore this file.
  config.example_status_persistence_file_path = "spec/examples.txt"

  # Limits the available syntax to the non-monkey patched syntax that is
  # recommended. For more details, see:
  #   - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
  #   - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
  #   - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
  config.disable_monkey_patching!

  # Many RSpec users commonly either run the entire suite or an individual
  # file, and it's useful to allow more verbose output when running an
  # individual spec file.
  if config.files_to_run.one?
    # Use the documentation formatter for detailed output,
    # unless a formatter has already been configured
    # (e.g. via a command-line flag).
    config.default_formatter = 'doc'
  end

  # Print the 10 slowest examples and example groups at the
  # end of the spec run, to help surface which specs are running
  # particularly slow.
  config.profile_examples = 10

  # 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

  # Seed global randomization in this process using the `--seed` CLI option.
  # Setting this allows you to use `--seed` to deterministically reproduce
  # test failures related to randomization by passing the same `--seed` value
  # as the one that triggered the failure.
  Kernel.srand config.seed
=end
end

Let me know if you need any more info. Thanks !

Add a generator for essential files

Or maybe there's no guaranteed set? config/routes.rb is only needed when using controllers and views, config/database.yml is only needed if using ActiveRecord.

failure on rails master

If you try running a combustion-enabled app against rails master, you get an exception at Combustion.initialize!, ending in:

# /Users/jrochkind/code/rails/activerecord/lib/active_record/database_configurations.rb:182:in `method_missing'
# /Users/jrochkind/.gem/ruby/2.5.1/gems/combustion-0.9.1/lib/combustion/database/reset.rb:56:in `resettable_db_configs'
# /Users/jrochkind/.gem/ruby/2.5.1/gems/combustion-0.9.1/lib/combustion/database/reset.rb:28:in `call'
# /Users/jrochkind/.gem/ruby/2.5.1/gems/combustion-0.9.1/lib/combustion/database/reset.rb:18:in `call'
# /Users/jrochkind/.gem/ruby/2.5.1/gems/combustion-0.9.1/lib/combustion/database.rb:17:in `setup'

resettable_environments = ActiveRecord::Base.configurations.keys -

Not sure what it means that ActiveRecord::Base.configurations doesn't have a #keys anymore in Rails 6.

Generator integration

Combustion works really well for me so far. There are some situations though where I would like to run a generator inside the dummy app and was wondering whether turning this into a Combustion feature might be helpful. For example:

  • When testing an engine that depends on another engine being installed (i.e. Active Admin).
  • When the tested engine requires custom setup that can be performed via an install generator.

In both cases, I would prefer not to commit the changes made by the generator, but rather regenerate on every Travis run to ensure the steps lead to a working setup with the current versions of the gems. In development mode, on the other hand, I'd prefer to generate once and reuse git ignored files on subsequent test runs to speed things up.

I could imagine passing a list of generators to Cumbustion.initialize!. But I'm not sure whether those should actually make changes to spec/internals or maybe some other ignored directory.

Do you think a workflow like that might make sense in the context of combustion?

"No connection pool with 'primary' found."

In the process of trying to change my existing gem over to use combution. My tests run correctly when I do Combustion.initialize! :active_record. But when I try to switch over to just Combustion.initialize!, so I can start adding integration tests that use other parts of rails, every access to the db results in a ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.

Any ideas? I'm at a bit of a loss.

Example stack trace:

       ActiveRecord::ConnectionNotEstablished:
         No connection pool with 'primary' found.
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:1007:in `retrieve_connection'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/connection_handling.rb:90:in `connection'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:466:in `load_schema!'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/attributes.rb:234:in `load_schema!'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:459:in `block in load_schema'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:456:in `load_schema'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/model_schema.rb:346:in `attribute_types'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/attribute_methods.rb:230:in `has_attribute?'
       # /Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/inheritance.rb:55:in `new'
       # ./spec/query_scopes_spec.rb:18:in `block (2 levels) in <top (required)>'
       # ./spec/query_scopes_spec.rb:22:in `block (3 levels) in <top (required)>'

Rake tasks

I like the idea of this gem and I loathe having full Rails apps in my test suite so I thought I would give it a go testing my sitemap_generator gem. I want to test that the rake tasks are working properly and am having some issues. There is no 'environment' task and for some reason my gem's rake tasks which are supposed to be loaded by Railtie, are not being loaded.

Do you have any plans to add support for running rake tasks or have any pointers?

Allow arbitrary application name

Currently the application name is 'internal', while in our project (and many other projects by convention) a test application for a plugin/engine is called a "dummy". Would it be possible to have combustion take a config option that allows an arbitrary app name, defaulting it to 'internal' unless overridden?

setting up Combustion with a Rails 3.1.1 engine - uninitialized constant ActionController::Metal (NameError)

I'm running into this error after setting up spec_helper with the Combustion config.

It also happens when I downgrade to 3.1.0.

/Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_controller/base.rb:171:in `<module:ActionController>': uninitialized constant ActionController::Metal (NameError)
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.0/lib/action_controller/base.rb:3:in `<top (required)>'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/responders-0.6.4/lib/responders.rb:1:in `require'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/responders-0.6.4/lib/responders.rb:1:in `<top (required)>'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/inherited_resources-1.3.0/lib/inherited_resources.rb:2:in `require'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/inherited_resources-1.3.0/lib/inherited_resources.rb:2:in `<top (required)>'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
    from /Users/nicholas/code/src/tfw/inkling/spec/spec_helper.rb:4:in `<top (required)>'
    from /Users/nicholas/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /Users/nicholas/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /Users/nicholas/code/src/tfw/inkling/spec/models/theme_spec.rb:1:in `<top (required)>'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `block in load_spec_files'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `map'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/configuration.rb:459:in `load_spec_files'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:69:in `run'
    from /Users/nicholas/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.7.0/lib/rspec/core/runner.rb:10:in `block in autorun'
mercury:inkling nicholas$ 

Unable to run rspec or rackup

I'm having problems creating a simple Rails engine and running it with Combustion. I've been pulling my hair out trying to get this to work so I thought I'd submit an issue.

First, I created a new engine.

rails plugin new issue_engine --mountable
cd issue_engine

I removed some of the junk and modified the readme file.

rm -rf test
rm MIT-LICENSE
rm README.rdoc
echo "# Issue Engine\n\nA Rails engine that serves and an example of a problem." >> readme.md

I modified issue_engine.gemspec.

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

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

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
  s.name        = "issue_engine"
  s.version     = IssueEngine::VERSION
  s.authors     = ["Landon Schropp"]
  s.email       = ["[email protected]"]
  s.homepage    = "https://www.github.com/LandonSchropp/issue_engine"
  s.summary     = "An example of an issue I'm having with Combustion."
  s.description = "An example of an issue I'm having with Combustion."

  s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "readme.md"]
  s.test_files = Dir["spec/**/*"]

  s.add_dependency "rails", "~> 3.2.12"
  s.add_development_dependency "sqlite3"
end

I modified the Gemfile and then ran bundle install.

source "http://rubygems.org"

gem 'activerecord'
gem 'combustion', '~> 0.3.3'
gem 'actionpack'
gem 'sprockets'
gem 'sqlite3'

group :test do
  gem 'rspec-rails', "~> 2.0"
end

gemspec

I ran rails generate rspec:install and modified the spec_helper.rb file:

require 'rubygems'
require 'bundler'

Bundler.require :default, :test

Combustion.initialize!

require 'rspec/rails'

RSpec.configure do |config|
  config.use_transactional_fixtures = true
end

Next, I ran bundle exec combust to generate the combustion files.

Finally, I created a controller by running rails g controller static index, removed the test directory and added routes:

IssueEngine::Engine.routes.draw do
  root :to => "static#index"
end

I also added a spec for it at spec/controllers/static_controller_spec.rb:

require 'spec_helper'

describe StaticController
  describe "index" do

    it "should render the index template" do
      get :index
      response.should render_template("index")
    end
  end
end

If I try and run bundle exec rspec, I get the following error:

/Users/landonschropp/Dropbox/Development/current/boilerplate/spec/spec_helper.rb:11:in `block in <top (required)>': undefined method `use_transactional_fixtures=' for #<RSpec::Core::Configuration:0x007fa6a36328f0> (NoMethodError)
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core.rb:108:in `configure'
  from /Users/landonschropp/Dropbox/Development/current/boilerplate/spec/spec_helper.rb:10:in `<top (required)>'
  from /Users/landonschropp/Dropbox/Development/current/boilerplate/spec/controllers/static_controller_spec.rb:1:in `require'
  from /Users/landonschropp/Dropbox/Development/current/boilerplate/spec/controllers/static_controller_spec.rb:1:in `<top (required)>'
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load'
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `each'
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load_spec_files'
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:22:in `run'
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:80:in `run'
  from /Users/landonschropp/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:17:in `block in autorun'

If I run rackup, the server starts. However, if I navigate to localhost:9292, I get a No route matches [GET] "/" error.

I'm sorry if this is just me being dumb, but I'm really stuck and I'd appreciate some help. I've created a Git repository containing all of the code in this issue.

Support for Rails 5

Tests are failing for Rails 5.
Please include the same.

Here are the logs:

Failures:

  1) Combustion::Database run migration from dummy engine
     Failure/Error: Combustion.initialize! :active_record

     NoMethodError:
       undefined method `migrate' for ActiveRecord::Migrator:Class
     # ./spec/database_spec.rb:8:in `block (3 levels) in <module:Combustion>'
     # ./spec/database_spec.rb:7:in `chdir'
     # ./spec/database_spec.rb:7:in `block (2 levels) in <module:Combustion>'

Finished in 0.96111 seconds (files took 0.49798 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/database_spec.rb:12 # Combustion::Database run migration from dummy engine

Failing to build on Travis with :all

Hi,

Not sure if it is a bug or a configuration error on my part.

Failing Case
With this line in my spec_helper:

Combustion.initialize! :all

The build fails on travis with the chief complaint being:

activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- action_mailer/railtie (LoadError)

Passing Case
However, with this line:

Combustion.initialize! :action_controller, :action_view

It succeeds.

In both cases, I did not experience this issue on my local machine (using RVM as well) so I am not sure what to make of it.

FactoryGirl definitions not found if FactoryGirl required before Combustion.initialize! invoked

Things started breaking for me with 'Factory not registered' errors. I tracked it down to adding the 'factory_girl_rails' gem to my Gemfile. Bundler autorequires it, which was causing FactoryGirl.definition_file_paths to already be resolved to spec/internal for it's factories.

I worked around it by disabling autorequiring in my Gemfile:

gem 'factory_girl_rails', :require => false

And then manually requiring it in my spec_helper.rb after Combustion.initialize!:

Combustion.initialize!
require 'rspec/rails'
require 'factory_girl_rails'

However, it might be nice if Combustion can somehow fix this.

Q: any way to use generators in internal app?

It would be convenient to be able to use rails generators (rails generate model ..., rails generate scaffold ... etc) in the ./spec/internal dummy app. Has anyone found a way to do that?

Cucumber support

There are a few things required to make Cucumber play nicely.
I'm using this issue to document the steps I had to take to make it work.
Maybe this will lead to a patch in the future :)

in env.rb:

Bundler.require :default, :development

$:.push(File.expand_path('../../../lib', __FILE__))
require 'my_engine'

World(Capybara::RSpecMatchers)
World(Capybara::DSL)

module RouteProxy
  # didn't find a cleaner way to get route helpers into my steps
  def method_missing(sym, *args)
    if route_helpers.respond_to?(sym)
      route_helpers.send(sym, *args)
    else
      super
    end
  end

  def route_helpers
    MyEngine::Engine.routes.url_helpers
  end
end

World(RouteProxy)

Before do
  MyEngine::Engine.routes.default_url_options[:host] = 'test.host'
end

uninitialized constant Combustion::Bundler

Hi,
Im using combusion version 0.7.0 gem and rails version 5.1. , when i try to run rspec I get error saying.
Failure/Error:
Combustion.initialize! :action_controller do
config.cache_store = :null_store
end

NameError:
uninitialized constant Combustion::Bundler

Can someone explain what the issue might be and how to resolve it.

undefined method 'assets'

Hey,

I'm trying to use combustion for testing my rails engine, but unfortunately upon running the specs I get the following error:

undefined method `assets' for #<Rails::Engine::Configuration:0x007f81708a4aa0> (NoMethodError)

When calling:

config.assets.precompile += %w( myscript.js )

I tried initialising :sprockets too and added it to the gemfile. Doesn't help, though.
Any ideas?

spec_helper.rb:

require 'rubygems'
require 'bundler/setup'

require 'rails'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
require 'jquery/rails'

require 'combustion'
require 'capybara/rspec'

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

require 'rspec/rails'
require 'capybara/rails'

RSpec.configure do |config|
  config.use_transactional_fixtures = true
end

"No such file - ["config/database.yml"]" (not a rails engine)

I have a gem which isn't actually a Rails::Engine (it has no Rails::Engine in it), which could be the root of the problem. My gem doesn't need any of the features that come with Rails::Engine, but it is meant for use with Rails (and does depend on ActiveRecord), and I want to have some integration tests in rspec to verify it works as expected in the context of Rails. So combustion seems very useful.

Not sure if not being a Rails::Engine is part of the problem or not. I have a bunch of specs that were already running fine, including many ActiveRecord. Now I want to add some integration tests.

My spec_helper.rb, trying to get the simplest thing that might work working, has:

require 'bundler'
Bundler.require :default, :development
Combustion.initialize! :active_record

From the Combustion.initialize! line, I get an exception raised:

RuntimeError: Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file - ["config/database.yml"]

full stack trace

I have run bundle exec combust, and do have the files at spec/internal, including spec/internal/config/database.yml

Any ideas or hints of what might be going on, or where I should go next? Thanks!

Compatibility with foreigner

I'm using foreigner (https://github.com/matthuhiggins/foreigner) to maintain the foreign key constraints in a postgresql database. When Combustion.initialize! is called, it eventually gets down to reading my ActiveRecord models, which triggers the railtie for foreigner. The stack gets to Foreigner::Adapter.configured_name, where it tries to do

ActiveRecord::Base.connection_pool.spec.config[:adapter]

But no connection is established at this time, so it raises a ActiveRecord::ConnectionNotEstablished error.

Is this just an error with my configuration of the spec/internal app or is foreigner just accessing the connection_pool before Combustion expects it?

Please publish a new version

The current version is almost a year old. I'm currently having to specify the master branch in my Gemfile due to bugs in 0.5.1, which makes me a bit nervous about stability. Thanks!

Facing error while running combust

Hi

While running combust command on a brand new rails 3.1 engine I am facing following error. I am using the released rails 3.1.0 and am using the combustion git master.

/Volumes/DATA/Bhavin/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find combustion (>= 0) amongst [archive-tar-minitar-0.5.2, arel-2.2.1, bcrypt-ruby-3.0.0, builder-3.0.0, bundler-1.1.pre.5, cancan-1.6.5, capistrano-2.8.0, capybara-1.1.1, childprocess-0.2.2, coffee-script-2.2.0, coffee-script-source-1.1.2, columnize-0.3.4, daemons-1.1.4, database_cleaner-0.6.7, devise-1.4.4, diff-lcs-1.1.3, erubis-2.7.0, erubis-2.7.0, eventmachine-0.12.10, execjs-1.2.4, factory_girl-2.1.0, factory_girl_generator-0.0.3, factory_girl_rails-1.2.0, ffi-1.0.9, ffi-1.0.9, growl-1.0.3, guard-0.6.3, guard-bundler-0.1.3, guard-pow-0.2.1, guard-rspec-0.4.4, guard-spork-0.2.1, haml-3.1.2, haml-rails-0.3.4, has_scope-0.5.1, highline-1.6.2, hike-1.2.1, hirb-0.5.0, hirb-0.4.5, i18n-0.6.0, i18n-0.5.0, inherited_resources-1.3.0, jquery-rails-1.0.13, json-1.5.4, json-1.5.3, json_pure-1.5.4, linecache19-0.5.12, mail-2.3.0, memcache-client-1.8.5, mime-types-1.16, mocha-0.9.12, multi_json-1.0.3, net-scp-1.0.4, net-scp-1.0.4, net-sftp-2.0.5, net-ssh-2.2.1, net-ssh-2.1.4, net-ssh-gateway-1.1.0, nokogiri-1.5.0, orm_adapter-0.0.5, pg-0.11.0, polyglot-0.3.2, powify-0.5.6, rack-1.3.2, rack-cache-1.0.3, rack-mount-0.8.3, rack-ssl-1.3.2, rack-test-0.6.1, rake-0.9.3.beta.1, rake-0.9.2, rake-0.9.2, rb-fsevent-0.4.3.1, rdoc-3.9.4, rdoc-3.9.1, responders-0.6.4, rspec-2.6.0, rspec-core-2.6.4, rspec-expectations-2.6.0, rspec-mocks-2.6.0, rspec-rails-2.6.1, ruby-debug-base19-0.11.25, ruby_core_source-0.1.5, rubyzip-0.9.4, sanitize-2.0.3, sass-3.1.7, sdoc-0.3.7, selenium-webdriver-2.5.0, shoulda-matchers-1.0.0.beta3, spork-0.9.0.rc9, sprockets-2.0.0, spruz-0.2.13, sqlite3-1.3.4, thin-1.2.11, thor-0.14.6, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, tzinfo-0.3.29, uglifier-1.0.2, vagrant-0.8.2, virtualbox-0.9.1, w3c_validators-1.1.1, warden-1.0.5, wirble-0.1.3, wirble-0.1.3, xpath-0.1.4, yajl-ruby-0.8.3] (Gem::LoadError)
    from /Volumes/DATA/Bhavin/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
    from /Volumes/DATA/Bhavin/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/rubygems.rb:1200:in `gem'
    from /Volumes/DATA/Bhavin/.rvm/gems/ruby-1.9.3-preview1@relyon/bin/combust:18:in `<main>'

Here's my GemFile.

Let me know if you need any other details. It looks to be a dependency resolution issue. But I am not sure how to resolve it.

Please release 0.3.2 with the 'path' support

Your README states that I should be able to call Combustion.path=, but this feature is not present in the current version of the gem (0.3.1)

undefined method `path=' for Combustion:Module

It's currently in the master branch though, so I would be grateful if you could bump the version and push a new gem.

Cheers!

secret_token => secret_key_base

Running Combustion under 5.2 results in:

DEPRECATION WARNING: `secrets.secret_token` is deprecated in favor of `secret_key_base` and will be removed in Rails 6.0. (called from env_config at /Users/jrochkind/.gem/ruby/2.4.2/gems/railties-5.2.0/lib/rails/application.rb:252)

Application has been already initialized issue

I am using rails 5 and ruby 2.4, when I try to run rspec for my gem works locally, I am getting runtime error in jenkins as follows below I have mentioned error and rails_helper code.

LoadError:
  cannot load such file -- rspec/rails
# /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/demo.rb:292:in `require'
# /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/demo.rb:292:in `block in require'
# /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/demo.rb:258:in `load_dependency'
# /usr/local/bundle/gems/activesupport-5.1.5/lib/active_support/demo.rb:292:in `require'
# ./spec/rails_helper.rb:14:in `<top (required)>'
# ./spec/controllers/sample/demo_controller_spec.rb:4:in `require'
# ./spec/controllers/sample/demo_controller_spec.rb:4:in `<top (required)>'

An error occurred while loading ./spec/models/demo_spec.rb.
Failure/Error: Combustion.initialize! :action_controller
 
rails_helper.rb file:

require 'spec_helper'

ENV['RAILS_ENV'] ||= 'test'
Dir[File.dirname(__FILE__) + '../internal/config/environment/*.rb'].each {|file| require file }

require 'combustion'
require 'support/shared_examples'

Combustion.initialize! :action_controller
Object.send(:remove_const, :ActiveRecord)

require 'rspec/rails'

RSpec.configure do |config|
  config.infer_base_class_for_anonymous_controllers = false
  config.include Rails.application.routes.url_helpers
  config.infer_spec_type_from_file_location!
end

Can anyone please help me to solve this issue.

README, environments, rackup

The README suggests

gem 'combustion', '~> 0.9.0', :group => :test

But the config.ru file generated has:

Bundler.require :default, :development

So if you try following README instructions to just rackup, you get uninitialized constant Combustion. You either need to include combustion in the development group, or change the line in the config.ru to Bundler.require :default, :development, :test.

I'm not sure if :development is really needed there, not sure if the line in config.ru should just be Bundler.require :default, :test? That seems to work too, not sure if when you rackup you end up with RAILS_ENV development or test by default.

Autoloading models?

Is there anything special required to autoload models in the 'app/models' directory of an engine? I've got spec/internal setup according the readme, but I'm getting uninitialized constant MyModelName when I try to run any model specs. Are there any special configs required? I've got Combustion.initialize! :all in my spec_helper.

Turn on mass assignment security by default

So apps using combustion won't have their tests show mass assignment failures by default. This hit me on http://github.com/isotope11/xrono and http://github.com/isotope11/wacky in the past two days. I did a post mortem and figured out why, I'll paste that email in at the bottom for more detail if you want it - it's very stream-of-consciousness, where I'll be more explicit here.

Combustion should add config.active_record.whitelist_attributes = true to the application.rb file so that its dummy rails app acts more like a default stock rails app in that regard. Otherwise all your tests pass, you pull the engine into a new rails app, and none of the create/update calls work.

I'd have sent a pull request in, but I know @parndt is in the middle of extracting combustion-rails, which is where this would need to go. Just wanted to keep a record of it. When you've got that gem ready I'll gladly send in a PR @parndt and @pat, k?

Thanks :) Thoughts?

----- postmortem email -----
So I ran into the exact same problems with the wiki engine I was working on yesterday. I would definitely say, first off, that adding attr_accessible to everything is not the way to go to resolve the issue since Rails4 is going to stop using that as a means of managing mass assignment by default.

I'm confused why combustion isn't bringing in the latest rails. If you look here, you can see that it's very lax with what it requests: https://github.com/pat/combustion/blob/v0.3.1/combustion.gemspec

I looked into the wiki, and it did in fact pull in rails 3.2.9. This suggests that the version of rails isn't the problem. Maybe the combustion app has assignment security turned off. Looking into that, I see this as the application.rb that combustion loads:

https://github.com/pat/combustion/blob/v0.3.1/lib/combustion/application.rb

In that, the whitelist_attributes config option isn't set at all. So now it's down to whatever the rails default is, I guess? I'd have assumed the default was to do the same thing the config set up, but it turns out it's not:

https://github.com/rails/rails/blob/v3.2.9/activerecord/lib/active_record/railtie.rb#L62-L64

If you don't set a config option for that at all, it doesn't run either attr_accessible or attr_protected on ActiveRecord::Base. This is because ActiveModel is where mass assignment security lives, and it doesn't make sense for that to be a default for normal activemodel objects - would be confusing.

So yeah, I think that combustion should add that configuration option. I'll send a pull request in. That explains why it's behaving that way.

Error while building the package

I am getting the following errors while building the package.
Please check the same.

Invalid gemspec in [combustion.gemspec]: combustion.gemspec:34: syntax error, unexpected keyword_end, expecting end-of-input
Invalid gemspec in [combustion.gemspec.gem2deb]: combustion.gemspec.gem2deb:34: syntax error, unexpected keyword_end, expecting end-of-input
Traceback (most recent call last):
	11: from /usr/bin/dh_ruby:96:in `<main>'
	10: from /usr/lib/ruby/vendor_ruby/gem2deb/dh_ruby.rb:43:in `clean'
	 9: from /usr/lib/ruby/vendor_ruby/gem2deb/dh_ruby.rb:201:in `installers'
	 8: from /usr/lib/ruby/vendor_ruby/gem2deb/dh_ruby.rb:201:in `map'
	 7: from /usr/lib/ruby/vendor_ruby/gem2deb/dh_ruby.rb:202:in `block in installers'
	 6: from /usr/lib/ruby/vendor_ruby/gem2deb/dh_ruby.rb:202:in `new'
	 5: from /usr/lib/ruby/vendor_ruby/gem2deb/installer.rb:24:in `initialize'
	 4: from /usr/lib/ruby/vendor_ruby/gem2deb/installer.rb:24:in `new'
	 3: from /usr/lib/ruby/vendor_ruby/gem2deb/metadata.rb:33:in `initialize'
	 2: from /usr/lib/ruby/vendor_ruby/gem2deb/metadata.rb:33:in `chdir'
	 1: from /usr/lib/ruby/vendor_ruby/gem2deb/metadata.rb:34:in `block in initialize'
/usr/lib/ruby/vendor_ruby/gem2deb/metadata.rb:124:in `load_gemspec': E: cannot load gemspec combustion.gemspec (RuntimeError)

Q: modern rails, engine testing, and combustion

The "default Rails" installation/infrastructure for engines has changed a lot since Rails 3.0 when combustion was first written.

I forget if Rails 3.0 even installed a "dummy" app. But the dummy app installed now is relatively light weight already (although still not nearly as light-weight as combustion's).

But additionally, the standard Rails engine setup gives you some features that are dependent upon the 'dummy', including: The ability to run generators rails g model whatever, which are generated into your engine, using generator configuration in your engine.rb. The ability to run rake tasks (now rails tasks, sigh) like db:reset or db:migrate, when the current working directory is your engine (no need to move into dummy dir) (through a really weird engine.rake implementation I don't completely understand, but I think makes the same tasks available as eg app:db:migrate and db:migrate). And the default generated testing tasks call things on your "dummy" db similarly to in an ordinary rails app. The default dummy app is generated with some odd code to make these things possible (it's not really a full/standard rails app in "dummy" already).

The standard documented combustion install breaks these rails g and ability to run rake db:migrate things. I was trying to hack it to see if I could make them work again. I got rails g to work, but not the db-related rake tasks (as integrated by default in the generated testing tasks), yet.

But then I thought: Why am I doing this? What benefits is combustion actually giving me? (And on the other hand new versions of Rails can break combustion as in #92. I won't say they might not break Rails default generated engine setup too, since that tends to be a somewhat neglected part of Rails, but it's probably less likely)

Thinking about what value Combustion adds... I am not sure! (I too have been doing engines since Rails 3.0 where the Rails-generated setup was not good enough, I'm not sure that's still true).

I think hypothetically it might make it easier to have proper non-deprecated default defaults when testing different rails versions, since some of that logic for what is default or what config keys are available in what version is embedded in combustion.

It may make it a little bit easier to have DB setup which is not in Rails migrations, which can be convenient. Not totally sure how you'd do that with stock rails-generated engine dummy setup.

But I'm curious your opinion as Combustion author what the benefits of combustion are over the stock generated rails engine setup. I get the feeling you aren't creating too many new engines yourself anymore where it comes up, and Combustion's maintenance status is somewhat tenuous (although it's still far better maintained than lots of rails-related open source, don't get me wrong :) ). But as I try to figure out if I want to be fighting to make combustion work the way I want, or fighting with default generated Rails setup to make it work how I want instead... I'm curious your thoughts.

Thanks for any!

Errors when Combustion is loading jquery-rails

Sorry about throwing a bunch of code at you...

spec_helper.rb:

ENV["RAILS_ENV"] ||= 'test'
require 'bundler/setup'

require 'combustion'
Combustion.initialize! :active_record, :action_controller, :action_view


require 'rspec/rails'

RSpec.configure do |config|
  #...
end

Gemfile:

source "https://rubygems.org"

group :test do
  gem "sqlite3"
  gem "combustion"

  gem 'rails', '~> 3.2.13'
  gem 'activerecord', '~> 3.2.13'
  gem 'actionpack', '~> 3.2.13'

  gem "rspec-rails"
  gem "factory_girl"
end

gemspec

gemspec:

  s.add_dependency "rails", "~> 3.2.1"
  s.add_dependency "paperclip", "~> 3.4.1"
  s.add_dependency "thinking-sphinx", "~> 2.0.14"
  s.add_dependency "resque", "~> 1.23.0"

  s.add_dependency "bootstrap-sass", "~> 2.3.1"
  s.add_dependency 'sass-rails',   '~> 3.2.3'
  s.add_dependency 'coffee-rails', '~> 3.2.1'
  s.add_dependency "eco", '~> 1.0.0'
  s.add_dependency "jquery-rails", "~> 2.2.1"
  s.add_dependency "simple_form", "~> 2.1.0"
  s.add_dependency "kaminari", "~> 0.14.1"

And I have some requires at the top of my engine.rb:

require 'rails'

# This was necessary for some reason, I guess it was using an 
# older version of rake that didn't have the "namespace" method, 
# and was failing when trying to load "tasks.rb" in thinking sphinx
require 'rake' 

require 'resque'
require 'thinking_sphinx'
require 'paperclip'

require 'jquery-rails'
require 'coffee-rails'
require 'sass-rails'
require 'eco'
require 'bootstrap-sass'

require 'simple_form'
require 'kaminari'

So basically when I run bundle exec rake, I get:

...gems/jquery-rails-2.2.1/lib/jquery/rails/railtie.rb:17:in `block in <class:Railtie>': uninitialized constant Jquery::Rails::Railtie::PROTOTYPE_JS (NameError)

If I remove require 'jquery-rails' from engine.rb, the tests run fine but then my app won't load (sprockets complains, "can't find file 'jquery'").

release as 1.0?

Is it time? I think the approach is proven to work for many of us, and maybe yes?

rails 4 support

The Rails 4 RC 1 is out. Will combustion support it?

Also, how would I go about specifying the version of Rails that Combustion uses? Do I just specify it in my Gemfile e.g.

gem 'rails', '3.1.0'
gem 'combustion'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.