<NME> slices_spec.rb
<BEF> ADDFILE
<MSG> Spec to test handling slices as a resource

1. Should work for newer slices versions
2. Should not break for older versions
3. TODO: Should not break for no slices at all 
<DFF> @@ -0,0 +1,52 @@
+require 'spec_helper'
+
+describe 'Slices' do
+
+  describe "Handle file with slice properly" do
+
+
+    it "should successfully parse a the PSD file of version 7 or above and has slices" do
+      psd = PSD.new('spec/files/slices.psd')
+      psd.parse!
+
+      # File should parse
+      expect(psd).to be_parsed
+
+      # Slices should not be nil
+      expect(psd.resources[:slices]).to_not be_nil
+
+      # slices version should be above 6
+      expect(psd.resources[:slices].data.version).to be > 6
+
+      # Bounds of each slice should not be nil
+      psd.resources[:slices].data.to_a.each do |slice|
+        expect(slice).to_not be_nil
+        expect(slice['bounds']).to_not be_nil
+      end
+    end
+
+
+    it "should successfully parse a the PSD file of version 6 and has slices" do
+      psd = PSD.new('spec/files/pixel.psd')
+      psd.parse!
+
+      # File should parse
+      expect(psd).to be_parsed
+
+      # Slices should still be not nil
+      expect(psd.resources[:slices]).to_not be_nil
+
+      # But slices version should be equal to 6
+      expect(psd.resources[:slices].data.version).to eq 6
+
+      # Slices data to be nil
+      expect(psd.resources[:slices].data.to_a).to be_nil
+    end
+  end
+
+  describe "Handle file without slices properly" do
+    #TODO: All files have atleast one autogenerated slice. Dunno how to handle this case yet!
+    #it "should successfully parse a PSD file which does not have slices" do
+    #end
+  end
+end
\ No newline at end of file

{'addition_count': 52, 'commit_subject': 'Spec to test handling slices as a resource', 'deletion_count': 0, 'file_extension': '.rb', 'lang': 'rb', 'license': 'mit', 'repo_name': 'layervault/psd.rb'}