spec/dump/snapshot_spec.rb in dump-1.1.0 vs spec/dump/snapshot_spec.rb in dump-1.2.0
- old
+ new
@@ -118,12 +118,12 @@
end
end
describe 'with tags' do
before do
- # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
- dumps_tags = [''] + %w[a a,d a,d,o a,d,s a,d,s,o a,o a,s a,s,o d d,o d,s d,s,o o s s,o z]
+ # 0 1 2 3 4 5 6 7 8 9 10 11 12 131415 16
+ dumps_tags = [''] + %w[a a,d a,d,o a,d,s a,d,s,o a,o a,s a,s,o d d,o d,s d,s,o o s s,o z]
paths = dumps_tags.each_with_index.map do |dump_tags, i|
path = dump_path("196504140659#{10 + i}@#{dump_tags}.tgz")
expect(File).to receive(:file?).with(path).at_least(1).and_return(true)
path
end
@@ -133,19 +133,26 @@
it 'returns all dumps if no tags send' do
expect(described_class.list(:tags => '')).to eq(described_class.list)
end
{
- 'x' => [],
- '+x' => [],
- 'z' => [16],
- 'a,d,s,o' => [1..15],
+ 'x' => [],
+
+ '+x' => [],
+
+ 'z' => [16],
+
+ 'a,d,s,o' => [1..15],
+
'+a,+d,+s,+o' => [5],
- '-o' => [0, 1, 2, 4, 7, 9, 11, 14, 16],
+
+ '-o' => [0, 1, 2, 4, 7, 9, 11, 14, 16],
+
'a,b,c,+s,-o' => [4, 7],
- '+a,+d' => [2, 3, 4, 5],
- '+d,+a' => [2, 3, 4, 5],
+
+ '+a,+d' => [2, 3, 4, 5],
+ '+d,+a' => [2, 3, 4, 5],
}.each do |tags, ids|
it "returns dumps filtered by #{tags}" do
expect(described_class.list(:tags => tags)).to eq(described_class.list.values_at(*ids))
end
end
@@ -253,21 +260,21 @@
end
end
describe 'get_filter_tags' do
it 'splits string and returns uniq non blank sorted tags' do
- expect(described_class.new('').send(:get_filter_tags, 'a,+b,+c,-d')).to eq({:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d]})
- expect(described_class.new('').send(:get_filter_tags, ' a , + b , + c , - d ')).to eq({:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d]})
- expect(described_class.new('').send(:get_filter_tags, ' a , + c , + b , - d ')).to eq({:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d]})
- expect(described_class.new('').send(:get_filter_tags, ' a , + b , + , - ')).to eq({:simple => %w[a], :mandatory => %w[b], :forbidden => []})
- expect(described_class.new('').send(:get_filter_tags, ' a , a , + b , + b , - d , - d ')).to eq({:simple => %w[a], :mandatory => %w[b], :forbidden => %w[d]})
+ expect(described_class.new('').send(:get_filter_tags, 'a,+b,+c,-d')).to eq(:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d])
+ expect(described_class.new('').send(:get_filter_tags, ' a , + b , + c , - d ')).to eq(:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d])
+ expect(described_class.new('').send(:get_filter_tags, ' a , + c , + b , - d ')).to eq(:simple => %w[a], :mandatory => %w[b c], :forbidden => %w[d])
+ expect(described_class.new('').send(:get_filter_tags, ' a , + b , + , - ')).to eq(:simple => %w[a], :mandatory => %w[b], :forbidden => [])
+ expect(described_class.new('').send(:get_filter_tags, ' a , a , + b , + b , - d , - d ')).to eq(:simple => %w[a], :mandatory => %w[b], :forbidden => %w[d])
expect{ described_class.new('').send(:get_filter_tags, 'a,+a') }.not_to raise_error
- expect{ described_class.new('').send(:get_filter_tags, 'a,-a') }.to raise_error
- expect{ described_class.new('').send(:get_filter_tags, '+a,-a') }.to raise_error
+ expect{ described_class.new('').send(:get_filter_tags, 'a,-a') }.to raise_error ArgumentError, /clashes/
+ expect{ described_class.new('').send(:get_filter_tags, '+a,-a') }.to raise_error ArgumentError, /clashes/
end
it 'accepts non string' do
- expect(described_class.new('').send(:get_filter_tags, nil)).to eq({:simple => [], :mandatory => [], :forbidden => []})
+ expect(described_class.new('').send(:get_filter_tags, nil)).to eq(:simple => [], :mandatory => [], :forbidden => [])
end
end
describe 'assets_root_link' do
it 'creates temp dir, chdirs there, symlinks rails app root to assets, yields and unlinks assets even if something was raised' do