diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-13 04:17:18 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-13 04:17:18 +0300 |
commit | 5a07b760dff04660d9c7da84852c710b1fc2f786 (patch) | |
tree | 6aa67c32c6b80dcc1c7cbfe4f9f62e57edb76b3e /spec/lib/gitlab/slash_commands | |
parent | 5d4993d62357e438b6211247278025040f3ae382 (diff) |
Refactor slash command definition
Diffstat (limited to 'spec/lib/gitlab/slash_commands')
-rw-r--r-- | spec/lib/gitlab/slash_commands/extractor_spec.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/spec/lib/gitlab/slash_commands/extractor_spec.rb b/spec/lib/gitlab/slash_commands/extractor_spec.rb index ac7296bdba1..8a6801205fa 100644 --- a/spec/lib/gitlab/slash_commands/extractor_spec.rb +++ b/spec/lib/gitlab/slash_commands/extractor_spec.rb @@ -5,7 +5,7 @@ describe Gitlab::SlashCommands::Extractor do shared_examples 'command with no argument' do it 'extracts command' do - commands = extractor.extract_commands!(original_msg) + commands = extractor.extract_commands(original_msg) expect(commands).to eq [['open']] expect(original_msg).to eq final_msg @@ -14,7 +14,7 @@ describe Gitlab::SlashCommands::Extractor do shared_examples 'command with a single argument' do it 'extracts command' do - commands = extractor.extract_commands!(original_msg) + commands = extractor.extract_commands(original_msg) expect(commands).to eq [['assign', '@joe']] expect(original_msg).to eq final_msg @@ -23,14 +23,14 @@ describe Gitlab::SlashCommands::Extractor do shared_examples 'command with multiple arguments' do it 'extracts command' do - commands = extractor.extract_commands!(original_msg) + commands = extractor.extract_commands(original_msg) expect(commands).to eq [['labels', '~foo ~"bar baz" label']] expect(original_msg).to eq final_msg end end - describe '#extract_commands!' do + describe '#extract_commands' do describe 'command with no argument' do context 'at the start of content' do it_behaves_like 'command with no argument' do @@ -49,7 +49,7 @@ describe Gitlab::SlashCommands::Extractor do context 'in the middle of a line' do it 'does not extract command' do msg = "hello\nworld /open" - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq "hello\nworld /open" @@ -82,7 +82,7 @@ describe Gitlab::SlashCommands::Extractor do context 'in the middle of a line' do it 'does not extract command' do msg = "hello\nworld /assign @joe" - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq "hello\nworld /assign @joe" @@ -99,7 +99,7 @@ describe Gitlab::SlashCommands::Extractor do context 'when argument is not separated with a space' do it 'does not extract command' do msg = "hello\n/assign@joe\nworld" - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq "hello\n/assign@joe\nworld" @@ -125,7 +125,7 @@ describe Gitlab::SlashCommands::Extractor do context 'in the middle of a line' do it 'does not extract command' do msg = %(hello\nworld /labels ~foo ~"bar baz" label) - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq %(hello\nworld /labels ~foo ~"bar baz" label) @@ -142,7 +142,7 @@ describe Gitlab::SlashCommands::Extractor do context 'when argument is not separated with a space' do it 'does not extract command' do msg = %(hello\n/labels~foo ~"bar baz" label\nworld) - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq %(hello\n/labels~foo ~"bar baz" label\nworld) @@ -152,7 +152,7 @@ describe Gitlab::SlashCommands::Extractor do it 'extracts command with multiple arguments and various prefixes' do msg = %(hello\n/power @user.name %9.10 ~"bar baz.2"\nworld) - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to eq [['power', '@user.name %9.10 ~"bar baz.2"']] expect(msg).to eq "hello\nworld" @@ -160,7 +160,7 @@ describe Gitlab::SlashCommands::Extractor do it 'extracts multiple commands' do msg = %(hello\n/power @user.name %9.10 ~"bar baz.2" label\nworld\n/open) - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to eq [['power', '@user.name %9.10 ~"bar baz.2" label'], ['open']] expect(msg).to eq "hello\nworld\n" @@ -168,7 +168,7 @@ describe Gitlab::SlashCommands::Extractor do it 'does not alter original content if no command is found' do msg = 'Fixes #123' - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq 'Fixes #123' @@ -177,7 +177,7 @@ describe Gitlab::SlashCommands::Extractor do it 'does not extract commands inside a blockcode' do msg = "Hello\r\n```\r\nThis is some text\r\n/close\r\n/assign @user\r\n```\r\n\r\nWorld" expected = msg.delete("\r") - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq expected @@ -186,7 +186,7 @@ describe Gitlab::SlashCommands::Extractor do it 'does not extract commands inside a blockquote' do msg = "Hello\r\n>>>\r\nThis is some text\r\n/close\r\n/assign @user\r\n>>>\r\n\r\nWorld" expected = msg.delete("\r") - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq expected @@ -195,7 +195,7 @@ describe Gitlab::SlashCommands::Extractor do it 'does not extract commands inside a HTML tag' do msg = "Hello\r\n<div>\r\nThis is some text\r\n/close\r\n/assign @user\r\n</div>\r\n\r\nWorld" expected = msg.delete("\r") - commands = extractor.extract_commands!(msg) + commands = extractor.extract_commands(msg) expect(commands).to be_empty expect(msg).to eq expected |