diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2017-08-01 18:23:36 +0000 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2017-08-01 18:23:36 +0000 |
commit | 9ba8685ea701a2f805d4bf6fb71ff52c49065c92 (patch) | |
tree | 13daac9aae82d3f733dd4ce46f3a28a806b27982 /spec/lib/gitlab/quick_actions/substitution_definition_spec.rb | |
parent | c4e7875d2909588e55c21a7cf19e31f60bce200f (diff) | |
parent | 0edf2b0d421144686ee399f44c26a2c4e1b2df05 (diff) | |
download | gitlab-ce-9ba8685ea701a2f805d4bf6fb71ff52c49065c92.tar.gz |
Merge branch 'master' into 'docs-specific-review-examples'docs-specific-review-examples
# Conflicts:
# doc/development/code_review.md
Diffstat (limited to 'spec/lib/gitlab/quick_actions/substitution_definition_spec.rb')
-rw-r--r-- | spec/lib/gitlab/quick_actions/substitution_definition_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb b/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb new file mode 100644 index 00000000000..1bb8bc51c96 --- /dev/null +++ b/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe Gitlab::QuickActions::SubstitutionDefinition do + let(:content) do + <<EOF +Hello! Let's do this! +/sub_name I like this stuff +EOF + end + subject do + described_class.new(:sub_name, action_block: proc { |text| "#{text} foo" }) + end + + describe '#perform_substitution!' do + it 'returns nil if content is nil' do + expect(subject.perform_substitution(self, nil)).to be_nil + end + + it 'performs the substitution by default' do + expect(subject.perform_substitution(self, content)).to eq <<EOF +Hello! Let's do this! +I like this stuff foo +EOF + end + end + + describe '#match' do + it 'checks the content for the command' do + expect(subject.match(content)).to be_truthy + end + + it 'returns the match data' do + data = subject.match(content) + expect(data).to be_a(MatchData) + expect(data[1]).to eq('I like this stuff') + end + + it 'is nil if content does not have the command' do + expect(subject.match('blah')).to be_falsey + end + end +end |