Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
main
------

* Fix `EmberCli::App#test` to report a failing suite by returning `false`
instead of exiting the process from inside the gem — one failing Ember suite
no longer aborts the caller (RSpec included) mid-run. `EmberCli.test!`
raises `EmberCli::TestFailureError` when a suite fails, which still exits
`rake ember:test` nonzero

0.13.0
------

Expand Down
6 changes: 5 additions & 1 deletion lib/ember_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def install_dependencies!
end

def test!
each_app(&:test)
each_app do |app|
unless app.test
fail TestFailureError, "The Ember test suite failed for #{app.name.inspect}"
end
end
end

def compile!
Expand Down
1 change: 1 addition & 0 deletions lib/ember_cli/errors.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module EmberCli
class BuildError < StandardError; end
class DependencyError < BuildError; end
class TestFailureError < StandardError; end
end
2 changes: 1 addition & 1 deletion lib/ember_cli/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def install
end

def test
run! ember.test
run ember.test
end

private
Expand Down
35 changes: 35 additions & 0 deletions spec/lib/ember_cli/shell_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "ember_cli/shell"

describe EmberCli::Shell do
describe "#test" do
it "returns a successful status when the suite passes" do
shell = build_shell(ember: "true")

status = shell.test

expect(status).to be_success
end

it "returns an unsuccessful status when the suite fails" do
shell = build_shell(ember: "false")

status = shell.test

expect(status).not_to be_success
end
end

# The `ember` executable is the seam: `Command#test` builds the command
# line from it, so `true` and `false` stand in for a passing and a failing
# `ember test` run.
def build_shell(ember:)
paths = double(
"EmberCli::PathSet",
ember: ember,
root: Pathname.new(Dir.pwd),
log: Pathname.new(File::NULL),
)

EmberCli::Shell.new(paths: paths)
end
end
27 changes: 27 additions & 0 deletions spec/lib/ember_cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,33 @@
end
end

describe ".test!" do
it "runs every application's test suite" do
passing = test_app(name: "passing", passed: true)
also_passing = test_app(name: "also-passing", passed: true)
stub_apps(passing: passing, also_passing: also_passing)

EmberCli.test!

expect(passing).to have_received(:test)
expect(also_passing).to have_received(:test)
end

it "raises when an application's test suite fails" do
failing = test_app(name: "failing", passed: false)
stub_apps(failing: failing)

expect { EmberCli.test! }.to raise_error(
EmberCli::TestFailureError,
/"failing"/,
)
end

def test_app(name:, passed:)
instance_double(EmberCli::App, name: name, test: passed)
end
end

def stub_apps(applications)
allow(EmberCli).to receive(:apps).and_return(applications)
end
Expand Down