Commit 5806f16c authored by Francisco Javier López's avatar Francisco Javier López Committed by Markus Koller

Add invalid field to SnippetInputAction specs

parent 391f364d
......@@ -6,28 +6,34 @@ describe SnippetInputAction do
describe 'validations' do
using RSpec::Parameterized::TableSyntax
where(:action, :file_path, :content, :previous_path, :is_valid) do
'create' | 'foobar' | 'foobar' | 'foobar' | true
'move' | 'foobar' | 'foobar' | 'foobar' | true
'delete' | 'foobar' | 'foobar' | 'foobar' | true
'update' | 'foobar' | 'foobar' | 'foobar' | true
'foo' | 'foobar' | 'foobar' | 'foobar' | false
nil | 'foobar' | 'foobar' | 'foobar' | false
'' | 'foobar' | 'foobar' | 'foobar' | false
'move' | 'foobar' | 'foobar' | nil | false
'move' | 'foobar' | 'foobar' | '' | false
'create' | 'foobar' | nil | 'foobar' | false
'create' | 'foobar' | '' | 'foobar' | false
'create' | nil | 'foobar' | 'foobar' | false
'create' | '' | 'foobar' | 'foobar' | false
'update' | 'foobar' | nil | 'foobar' | false
'update' | 'other' | 'foobar' | 'foobar' | false
where(:action, :file_path, :content, :previous_path, :is_valid, :invalid_field) do
'create' | 'foobar' | 'foobar' | 'foobar' | true | nil
'move' | 'foobar' | 'foobar' | 'foobar' | true | nil
'delete' | 'foobar' | 'foobar' | 'foobar' | true | nil
'update' | 'foobar' | 'foobar' | 'foobar' | true | nil
'foo' | 'foobar' | 'foobar' | 'foobar' | false | :action
nil | 'foobar' | 'foobar' | 'foobar' | false | :action
'' | 'foobar' | 'foobar' | 'foobar' | false | :action
'move' | 'foobar' | 'foobar' | nil | false | :previous_path
'move' | 'foobar' | 'foobar' | '' | false | :previous_path
'create' | 'foobar' | nil | 'foobar' | false | :content
'create' | 'foobar' | '' | 'foobar' | false | :content
'create' | nil | 'foobar' | 'foobar' | false | :file_path
'create' | '' | 'foobar' | 'foobar' | false | :file_path
'update' | 'foobar' | nil | 'foobar' | false | :content
'update' | 'other' | 'foobar' | 'foobar' | false | :file_path
end
with_them do
subject { described_class.new(action: action, file_path: file_path, content: content, previous_path: previous_path).valid? }
subject { described_class.new(action: action, file_path: file_path, content: content, previous_path: previous_path) }
specify { is_expected.to be is_valid}
specify do
expect(subject.valid?).to be is_valid
unless is_valid
expect(subject.errors).to include(invalid_field)
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment