Sha256: f7a037d8fd99a8e476563eebf7afcf522367c7f2fdc6e90eeea7684b9fdf49bc

Contents?: true

Size: 1.88 KB

Versions: 4

Compression:

Stored size: 1.88 KB

Contents

require "spec_helper"

describe XcodeProject::Project do
	let(:proj) { prepare_example_project }

	describe "#new" do
		context "if the project file exists" do
			it "constructs an project object" do
				XcodeProject::Project.new(example_project_bundle_path).should be_an_instance_of(XcodeProject::Project)
			end
		end

		context "if the project file doesn't exist" do
			let(:proj_ne) { "#{example_empty_sandbox_path}/ghost.xcodeproj" }
			it "trows the exception" do
				lambda { XcodeProject::Project.new(proj_ne) }.should raise_exception(XcodeProject::FilePathError)
			end
		end
	end

	describe "#file_path" do
		it "returns the project's file path" do
			proj.file_path.should eql(example_project_file_path)
		end
	end

	describe "#bundle_path" do
		it "returns the project's bundle path" do
			proj.bundle_path.should eql(example_project_bundle_path)
		end
	end

	describe "#find_projs" do
		context "if a path contains project files" do
			it "returns an array of project objects" do
				projs = XcodeProject::Project.find_projs(example_sandbox_path)
				projs.size.should eql(1)
				projs.first.bundle_path.should eql(proj.bundle_path)
			end
		end

		context "if a path doesn't contain project files" do
			it "returns an empty array" do
				projs = XcodeProject::Project.find_projs(example_empty_sandbox_path)
				projs.size.should eql(0)
			end
		end
	end

	describe "#read" do
		it "returns the data object" do
			proj.read.should be_an_instance_of(XcodeProject::Data)
		end

		it "reads the project file" do
			mock.proxy(proj).file_path
			proj.read
		end
	end

	describe "#write" do
		it "writes the project file" do
			data = proj.read

			mock.proxy(proj).file_path
			proj.write(data)
		end
	end

	describe "#change" do
		it "reads the file file and then writes it" do
			proj_mock = mock.proxy(proj)
			proj_mock.read
			proj_mock.write(is_a(XcodeProject::Data))
			proj.change {|data| }
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xcodeproject-0.3.1 spec/project_spec.rb
xcodeproject-0.3.0 spec/project_spec.rb
xcodeproject-0.2.4 spec/project_spec.rb
xcodeproject-0.2.3 lib/xcodeproject/spec/project_spec.rb