Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply_change_to_project_spec: Raise if diff contains no changes. #47

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions spec/kintsugi_apply_change_to_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@
end

it "adds build file to a file reference that already exist" do
file_reference = base_project.main_group.new_reference("bar")
base_project.targets[0].frameworks_build_phase.add_file_reference(file_reference)
base_project.main_group.new_reference("bar")

base_project.main_group.new_reference("bar")

Expand Down Expand Up @@ -752,7 +751,7 @@
base_project.save
theirs_project = create_copy_of_project(base_project.path, "theirs")

theirs_project.root_object.known_regions += ["en"]
theirs_project.root_object.known_regions += ["fr"]

changes_to_apply = get_diff(theirs_project, base_project)

Expand All @@ -763,9 +762,6 @@
end

it "removes known regions" do
base_project.root_object.known_regions += ["en"]

base_project.save
theirs_project = create_copy_of_project(base_project.path, "theirs")

theirs_project.root_object.known_regions = []
Expand Down Expand Up @@ -934,7 +930,15 @@ def create_copy_of_project(project_path, new_project_prefix)
end

def get_diff(first_project, second_project)
Xcodeproj::Differ.project_diff(first_project, second_project, :added, :removed)
diff = Xcodeproj::Differ.project_diff(first_project, second_project, :added, :removed)

diff_without_display_name =
diff.merge("rootObject" => diff["rootObject"].reject { |key, _| key == "displayName" })
if diff_without_display_name == {"rootObject" => {}}
raise "Diff contains no changes. This probably means the test doesn't check anything."
end

diff
end

def add_new_subproject_to_project(project, subproject_name, subproject_product_name)
Expand Down