Aruba の Text 周りの機能についてまとめます。
サンプル
extract_text
文字列からANSI escape codeを取り除いた値を取得します
require 'spec_helper'
RSpec.describe 'extract_text', type: :aruba do
before(:each) { run("echo -n \"\e[31mhoge\"") }
before(:each) { stop_all_commands }
it { expect(unescape_text(last_command_started.output)).to eq "\e[31mhoge" }
it { expect(extract_text(unescape_text(last_command_started.output))).to eq 'hoge' }
end
- 実行結果
$ rspec -fd -c spec/text/extract_text_spec.rb
extract_text
should eq "\e[31mhoge"
should eq "hoge"
Finished in 0.11998 seconds (files took 0.23258 seconds to load)
2 examples, 0 failures
その他
その他に sanitize_text
, unescape_text
などの機能があります。
詳細は外部資料のリンクをご確認ください。