title: Padrino, mounting app for Capybara
body: <p>I have a feature spec:
  /spec/features/posts_features_spec.rb:</p>
  
  <pre><code>require 'spec_helper'
  
  describe "Displaying Posts" do
    it "can see posts on posts page" do
      Post.create(title: "Title", content: "Content")
      visit '/posts'
      expect(page).to have_content("Title")
      expect(page).to have_content("Content")
    end
  end
  </code></pre>
  
  <p>When I run the test, I get:</p>
  
  <pre><code>WARNING! No apps are mounted. Please, mount apps in `config/apps.rb`
  </code></pre>
  
  <p>And a failing test, with:</p>
  
  <pre><code>NameError:
         uninitialized constant Post
  </code></pre>
  
  <p>/spec/spec_helper.rb:</p>
  
  <pre><code>require 'rack/test'
  require 'rspec/padrino'
  require 'capybara/rspec'
  
  Capybara.app = Padrino.application
  
  RSpec.configure do |config|
    config.include Rack::Test::Methods
    config.include RSpec::Padrino
    config.include Capybara::DSL
  
    config.expect_with :rspec do |expectations|
      expectations.include_chain_clauses_in_custom_matcher_descriptions = true
    end
  
    config.mock_with :rspec do |mocks|
      mocks.verify_partial_doubles = true
    end
  end
  </code></pre>
  
  <p>/Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  # Padrino supports Ruby version 1.9 and later
  ruby '2.3.0'
  
  # Project requirements
  gem 'rake'
  
  # Component requirements
  gem 'bcrypt'
  gem 'sass'
  gem 'haml'
  gem 'activerecord', '&gt;= 3.1', :require =&gt; 'active_record'
  gem 'sqlite3'
  
  # Test requirements
  group :test do
    gem 'shoulda'
    gem 'rack-test', :require =&gt; 'rack/test'
    gem 'rspec-padrino'
    gem 'capybara'
  end
  
  # Padrino Stable Gem
  gem 'padrino', '0.13.1'
  </code></pre>
  
  <p>/app/app.rb:</p>
  
  <pre><code>module PadrinoBlog
    class App &lt; Padrino::Application
      register SassInitializer
      use ConnectionPoolManagement
      register Padrino::Mailer
      register Padrino::Helpers
  
      enable :sessions
  
      get "/" do
        "Hello World!"
      end
  
      get :about, :map =&gt; '/about_us' do
        render :haml, "%p This is a sample blog created to demonstrate how Padrino works!"
      end
    end
  end
  </code></pre>
  
  <p>/config/apps.rb:</p>
  
  <pre><code>Padrino.configure_apps do
    # enable :sessions
    set :session_secret, '67c26da8db30eaf68907e2de05783d33be5e246b87c194f0579bdb589c0761dd'
    set :protection, :except =&gt; :path_traversal
    set :protect_from_csrf, true
  end
  
  # Mounts the core application for this project
  
  Padrino.mount("PadrinoBlog::Admin", :app_file =&gt; Padrino.root('admin/app.rb')).to("/admin")
  Padrino.mount('PadrinoBlog::App', :app_file =&gt; Padrino.root('app/app.rb')).to('/')
  </code></pre>
  
  <p>I've tried various different things, such as requiring the 'app.rb' file in spec_helper, which then leads to having to require active_record there too, which then leads to a problem because it doesn't know what SassInitializer is, and on and on.</p>
  
  <p>To be honest, I don't really know what I'm doing with this or how everything fits together, so any help would be much appreciated.</p>
  
  <p>The repo's branch <a href="https://github.com/Yorkshireman/padrino_blog/tree/rspec" rel="nofollow">here</a>.</p>