diff --git a/features/builder.feature b/features/builder.feature index 032c318c..e779302c 100644 --- a/features/builder.feature +++ b/features/builder.feature @@ -17,11 +17,17 @@ Feature: Builder Then "images/Read me (example).txt" should exist at "test-app" Then "images/Child folder/regular_file(example).txt" should exist at "test-app" Then ".htaccess" should exist at "test-app" + Then the last exit code should be "0" Scenario: Build glob Given a built app at "glob-app" with flags "--glob '*.css'" Then "stylesheets/site.css" should exist at "glob-app" and include "html" Then "index.html" should not exist at "glob-app" + Then the last exit code should be "0" + + Scenario: Build with errors + Given a built app at "build-with-errors-app" + Then the last exit code should be "1" # Scenario: Force relative assets # Given a built app at "relative-app" with flags "--relative" diff --git a/fixtures/build-with-errors-app/config.rb b/fixtures/build-with-errors-app/config.rb new file mode 100644 index 00000000..3e6fe528 --- /dev/null +++ b/fixtures/build-with-errors-app/config.rb @@ -0,0 +1 @@ +set :layout, false \ No newline at end of file diff --git a/fixtures/build-with-errors-app/source/index.html.erb b/fixtures/build-with-errors-app/source/index.html.erb new file mode 100644 index 00000000..31962969 --- /dev/null +++ b/fixtures/build-with-errors-app/source/index.html.erb @@ -0,0 +1 @@ +<%= error_error_error %> \ No newline at end of file diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb index ee32b5c0..f065e7db 100644 --- a/lib/middleman/builder.rb +++ b/lib/middleman/builder.rb @@ -42,11 +42,13 @@ module Middleman destination, request_path = ::Middleman::Builder.shared_instance.reroute_builder(destination, request_path) response = ::Middleman::Builder.shared_rack.get(request_path.gsub(/\s/, "%20")) - create_file(destination, response.body, config) if response.status == 200 + + create_file(destination, response.body, config) destination rescue say_status :error, destination, :red + abort end end end diff --git a/lib/middleman/core_extensions/show_exceptions.rb b/lib/middleman/core_extensions/show_exceptions.rb index ad21b0f5..256e0ff7 100644 --- a/lib/middleman/core_extensions/show_exceptions.rb +++ b/lib/middleman/core_extensions/show_exceptions.rb @@ -3,7 +3,7 @@ require 'rack/showexceptions' module Middleman::CoreExtensions::ShowExceptions class << self def registered(app) - app.after_configuration do + app.configure :development do if show_exceptions use ::Middleman::CoreExtensions::ShowExceptions::Middleware end diff --git a/lib/middleman/step_definitions/builder_steps.rb b/lib/middleman/step_definitions/builder_steps.rb index 8f48c64a..7cf02733 100644 --- a/lib/middleman/step_definitions/builder_steps.rb +++ b/lib/middleman/step_definitions/builder_steps.rb @@ -42,4 +42,9 @@ end Then /^"([^\"]*)" should not exist at "([^\"]*)"$/ do |target_file, path| target = File.join(PROJECT_ROOT_PATH, "fixtures", path, "build", target_file) File.exists?(target).should be_false -end \ No newline at end of file +end + +Then /^the last exit code should be "([^\"]*)"$/ do |exit_code| + exit_code = exit_code.to_i + $?.exitstatus.should == exit_code +end