percy / percy-capybara

Visual testing for Capybara with Percy.
https://docs.percy.io/docs/capybara
MIT License
45 stars 23 forks source link

Add Ember CLI Rails Loader #34

Closed djones closed 7 years ago

djones commented 7 years ago

Adds support for loading in assets from both Ember and Rails when using Ember CLI Rails

Configuration

In your spec_helper.rb file you need to configure use of this loader like so:

RSpec.configure do |config|
  # ...
  config.before(:suite) do
    # Ember CLI must compile first to create all the required files.
    EmberCli.compile!

    # You need to tell the loader which apps are mounted on which paths.
    ember_apps = { frontend: '/', admin: '/admin/' }

    Percy::Capybara.use_loader(:ember_cli_rails, { mounted_apps: ember_apps})

    Percy::Capybara.initialize_build
  end

  config.after(:suite) { Percy::Capybara.finalize_build }
end

You would have the above configuration if you have something like this in your routes.rb file:

Rails.application.routes.draw do
  # Useful for just subbing in a vanilla Rails controller for testing.
  # root to: 'pages#index'

  mount_ember_app :admin, to: "/admin", controller: "admin"
  mount_ember_app :frontend, to: "/"
end

Example App

https://github.com/percy/ember-cli-rails-heroku-example/pull/1

Todo

fotinakis commented 7 years ago

Ahh I see that EmberCli.compile! is a manual setup step outside. That's 👍 for now.

djones commented 7 years ago

@fotinakis yeah, and honestly I think that is the right approach anyway. Feels weird for the loader to fire off asset compilation.