paintbrush

0.1.3
Light Mode Dark Mode

Dynamic Usage

You may have situations where the color you wish to use depends on some state that is unknown until your application is running, and may change between each invocation.

Since Paintbrush colors are regular methods, you can call public_send within the block passed to paintbrush.

subject do
  paintbrush { blue "The action #{public_send outcome_color, outcome} this time!" }
end

let(:outcome_color) { :green }
let(:outcome) { 'succeeded' }

it { is_expected.to include "\e[32msucceeded\e[0m" }

The action succeeded this time!
subject do
  paintbrush { blue "The action #{public_send outcome_color, outcome} this time!" }
end

let(:outcome_color) { :red }
let(:outcome) { 'failed' }

it { is_expected.to include "\e[31mfailed\e[0m" }
The action failed this time!

Documentation generated by rspec-documentation