Sha256: 173efa323137e0ed464b02808ecfd7fcf5228258cfd399df9b0027e483b84f50

Contents?: true

Size: 1.22 KB

Versions: 55

Compression:

Stored size: 1.22 KB

Contents

describe 'NSData' do

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

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

  describe 'writing to a url' do
    it 'should write data to a url' do
      subject = 'data'.dataUsingEncoding(NSUTF8StringEncoding)
      subject.write_to(@url).should == true
      @file_name.file_exists?.should == true
    end
  end

  describe 'reading from a file' do

    it 'should read data from a file' do
      subject = 'data'.dataUsingEncoding(NSUTF8StringEncoding)
      subject.write_to(@file_name).should == true
      contents = NSData.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 = NSData.read_from(file_name)
      contents.should == nil
    end

  end

end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
sugarcube-3.0.4 spec/cocoa/nsdata_files_spec.rb
sugarcube-3.0.3 spec/cocoa/nsdata_files_spec.rb
sugarcube-3.0.2 spec/cocoa/nsdata_files_spec.rb
sugarcube-3.0.1 spec/cocoa/nsdata_files_spec.rb
sugarcube-3.0.0 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.12.3 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.12.2 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.12.1 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.12.0 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.11.1 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.11.0 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.10.0 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.9.1 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.8.2 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.8.1 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.8.0 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.7.1 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.7.0 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.6.0 spec/cocoa/nsdata_files_spec.rb
sugarcube-2.5.0 spec/cocoa/nsdata_files_spec.rb