Skip to content
Browse files

Adds documentation for configurable colors

  • Loading branch information...
1 parent 6a54bf8 commit 65700c694430aeda1f28fa3e848d9825e03f8f27 @alindeman alindeman committed
View
31 features/formatters/configurable_colors.feature
@@ -0,0 +1,31 @@
+Feature: Configurable colors
+
+ RSpec allows you to configure the terminal colors used in the text formatters.
+
+ * `failure_color`: Color used when tests fail (default: `:red`)
+ * `success_color`: Color used when tests pass (default: `:green`)
+ * `pending_color`: Color used when tests are pending (default: `:yellow`)
+ * `fixed_color`: Color used when a pending block inside an example passes, but was expected to fail (default: `:blue`)
+ * `detail_color`: Color used for miscellaneous test details (default: `:cyan`)
+
+ Colors are normally specified as symbols. Options are `:black`, `:red`,
+ `:green`, `:yellow`, `:blue`, `:magenta`, `:cyan`, and `:white`.
+
+ @ansi
+ Scenario: Customizing the failure color
+ Given a file named "custom_failure_color_spec.rb" with:
+ """ruby
+ RSpec.configure do |config|
+ config.failure_color = :magenta
+ config.tty = true
+ config.color = true
+ end
+
+ describe "failure" do
+ it "fails and uses the custom color" do
+ expect(2).to eq(4)
+ end
+ end
+ """
+ When I run `rspec custom_failure_color_spec.rb --format progress`
+ Then the failing example is printed in magenta
View
7 features/step_definitions/additional_cli_steps.rb
@@ -30,3 +30,10 @@
normalized_output.should =~ regexp(partial_output)
end
+
+# This step can be generalized if it's ever used to test other colors
+Then /^the failing example is printed in magenta$/ do
+ # \e[35m = enable magenta
+ # \e[0m = reset colors
+ expect(all_output).to include("\e[35m" + "F" + "\e[0m")
+end

1 comment on commit 65700c6

@myronmarston
RSpec member

:+1: Nice work, Andy.

Please sign in to comment.
Something went wrong with that request. Please try again.