diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-07-10 23:17:20 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-10 16:26:21 +0300 |
commit | 3f6d91c53c1bf99ce2e7dfeb9c25ef5f8149b72e (patch) | |
tree | 6aa3c7cc777857ed6a35a50612cf9fec83c94493 /spec/lib/gitlab/string_regex_marker_spec.rb | |
parent | e179707844b043fac6f81a30f82e5f4ba446abde (diff) |
Add Gitlab::StringRegexMarker
Diffstat (limited to 'spec/lib/gitlab/string_regex_marker_spec.rb')
-rw-r--r-- | spec/lib/gitlab/string_regex_marker_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/lib/gitlab/string_regex_marker_spec.rb b/spec/lib/gitlab/string_regex_marker_spec.rb new file mode 100644 index 00000000000..2f5cf6c6e3b --- /dev/null +++ b/spec/lib/gitlab/string_regex_marker_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe Gitlab::StringRegexMarker, lib: true do + describe '#mark' do + let(:raw) { %{"name": "AFNetworking"} } + let(:rich) { %{<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"AFNetworking"</span>}.html_safe } + subject do + described_class.new(raw, rich).mark(/"[^"]+":\s*"(?<name>[^"]+)"/, group: :name) do |text, left:, right:| + %{<a href="#">#{text}</a>} + end + end + + it 'marks the inline diffs' do + expect(subject).to eq(%{<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"<a href="#">AFNetworking</a>"</span>}) + expect(subject).to be_html_safe + end + end +end |