Sha256: 8aa1a7d35a1130713df9ac0b8554c0d53c61b5615d3c072af86262dd5f97a0c1

Contents?: true

Size: 1.87 KB

Versions: 55

Compression:

Stored size: 1.87 KB

Contents

describe 'NSArray' do

  before do
    @file_name = 'write_to_file.plist'.temporary_path
    @url = NSURL.alloc.initFileURLWithPath 'write_to_file'.temporary_path
  end

  describe 'writing to a file' do
    it 'should write [] to a file' do
      subject = []
      subject.write_to(@file_name).should == true
      @file_name.file_exists?.should == true
    end

    it 'should write [] to a url' do
      subject = []
      subject.write_to(@url).should == true
      @file_name.file_exists?.should == true
    end

    it 'should write [...] to a file' do
      subject = [1,2,3]
      subject.write_to(@file_name).should == true
      @file_name.file_exists?.should == true
    end

    it 'should write [...] with nested objects to a file' do
      subject = [1,2,[3,true,false,"",{}]]
      subject.write_to(@file_name).should == true
      @file_name.file_exists?.should == true
    end
  end

  describe 'reading from a file' do

    it 'should read [] from a file' do
      subject = []
      subject.write_to(@file_name).should == true
      contents = NSArray.read_from(@file_name)
      contents.should == subject
    end

    it 'should read [...] from a file' do
      subject = [1,2,3]
      subject.write_to(@file_name).should == true
      contents = NSArray.read_from(@file_name)
      contents.should == subject
    end

    it 'should read [...] with nested objects from a file' do
      subject = [1,2,[3,true,false,"",{}]]
      subject.write_to(@file_name).should == true
      contents = NSArray.read_from(@file_name)
      contents.should == subject
    end

    it 'should not have a file called "wtf is this"' do
      'wtf is this'.document_path.file_exists?.should == false
    end

    it 'should return nil for files that don\'t exist' do
      file_name = 'wtf is this'.document_path
      contents = NSArray.read_from(file_name)
      contents.should == nil
    end

  end

end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
sugarcube-4.0.0 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.5.0 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.4.2 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.4.1 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.4.0 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.7 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.6 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.5 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.4 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.3 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.2 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.1 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.3.0 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.2.0 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.1.1 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.1.0 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.0.8 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.0.7 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.0.6 spec/cocoa/nsarray_files_spec.rb
sugarcube-3.0.5 spec/cocoa/nsarray_files_spec.rb