Sha256: ee56a354ae974ae79e49b76170e4efba542a90b136eb13f44807456311f34be6

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

require_relative 'spec_helper'

describe XcodeProject::FileNode do
  let(:data_name)      { Hash['name', 'file.name'] }
  let(:data_path)      { Hash['path', 'path/to/file.name'] }
  let(:data_path_name) { data_path.merge!(data_name) }
  let(:data_empty)     { Hash.new }

  describe '#name' do
    context 'if the name is initialized' do
      it 'returns the name as is' do
        [data_name, data_path_name].each do |data|
          expect(XcodeProject::FileNode.new(stub, stub, data).name).to eql(data['name'])
        end
      end
    end

    context 'if the name isn\'t initialized' do
      context 'and the path is initialized ' do
        it 'returns the name as basename of the path' do
          expect(XcodeProject::FileNode.new(stub, stub, data_path).name).to eql(File.basename(data_path['path']))
        end
      end

      context 'and the path isn\'t initialized' do
        it 'returns nil' do
          expect(XcodeProject::FileNode.new(stub, stub, data_empty).name).to be_nil
        end
      end
    end
  end

  describe '#path' do
    context 'if the path is initialized' do
      it 'returns the path as is' do
        [data_path, data_path_name].each do |data|
          expect(XcodeProject::FileNode.new(stub, stub, data_path).path).to eql(data['path'])
        end
      end
    end

    context 'if the path isn\'t initialized' do
      it 'returns nil' do
        expect(XcodeProject::FileNode.new(stub, stub, data_empty).path).to be_nil
      end
    end
  end

  describe '#parent' do
    let(:root) { prepare_example_project.read.send(:root) }

    context 'if the current object is the main group' do
      it 'returns nil' do
        expect(root.project.main_group.parent).to be_nil
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xcodeproject_swift-0.3.14 spec/file_node_spec.rb
xcodeproject_swift-0.3.13 spec/file_node_spec.rb