Simple/dumb solution
Have RSpec build ember into rails' public/ before your feature specs.
# build ember, hijack rails public/ directory to host ember app
# this way no need to change settings or run any servers
# assumes rails API root path is not used (since ember now hosted from it)
RSpec.configure do |config|
public_path = Rails.root.join('public')
config.before(:context, type: :feature) do
Dir.chdir 'frontend' do
builder = spawn("ember build --environment=ci -output-path=#{public_path}")
_pid, status = Process.wait2(builder)
fail "non-zero exit status #{status}" unless status == 0
end
end
config.after(:context, type: :feature) do
`git clean -fd #{public_path}`
`git checkout #{public_path}`
end
end
Configuring
Our ember-cli app is in rails-root/frontend, you may need to change the name or path to point at yours
You might want to experiment with the environment part, e.g. using production instead. I do this because my production env is hard-coded to target an API we host on heroku but I want the tests to be self-contained, i.e. run against the rails app capybara hosts.
Git is needed for cleanup. If you don't have that you could build to another path and use mv to swap out the rails public/ dir then put it back afterwards.
You may prefer not to have a global install of ember-cli used to build your project (for versioning reasons). If you want to use the project local one point the spawn command at node_modules/ember-cli/bin/ember instead of just ember.
Otherwise, ember-cli-rails
If you're treating the ember app as a component of your rails app, and want to write tests at the rails level (rspec, capybara, etc) then ember-cli-rails is likely a good choice.
This gem handles building the ember app and serving it from the urls you mount it at in your rails routes.
This is transparent to capybara: it sends a request to a ruby webserver and is given back html that calls out to css and js, just like rails normally does.
Be aware there are some issues with assets from ember-cli getting served by rails with the right paths at the moment, which made me switch away to get something deployed quickly. If you're using the rails asset pipeline for css, images and so on, then you shouldn't have a problem. For me, it affected images and webfonts in the ember-cli app.
Apart from that there will need to be a server for the api and a server for the ember front-end (proxying to the rails api), and capybara will need telling to connect to the ember front-end.
This Rakefile and this post seem like a start.
401 unauthorized
back as the failing response? If so, try binding.pry and ensure the user exists right before sign in (you did mention you checked the console). Also, check the failures in /log/test.log. This was happening to me, and it was caused by my mis-configuration of DatabaseCleaner in myrails_helper.rb
– Ryan