Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
f0045086
Commit
f0045086
authored
Feb 11, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Specs Integration] Clean up implementation.
parent
02d1c489
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
50 deletions
+74
-50
integration_2_spec.rb
spec/integration_2_spec.rb
+74
-50
No files found.
spec/integration_2_spec.rb
View file @
f0045086
...
@@ -130,23 +130,33 @@ end
...
@@ -130,23 +130,33 @@ end
#
#
def
check_with_folder
(
folder
)
def
check_with_folder
(
folder
)
source
=
File
.
expand_path
(
"../integration/
#{
folder
}
"
,
__FILE__
)
source
=
File
.
expand_path
(
"../integration/
#{
folder
}
"
,
__FILE__
)
Dir
.
glob
(
"
#{
source
}
/after/**/*"
)
do
|
expected
|
Dir
.
glob
(
"
#{
source
}
/after/**/*"
)
do
|
expected_path
|
next
unless
File
.
file?
(
expected
)
next
unless
File
.
file?
(
expected_path
)
relative_path
=
expected
.
gsub
(
"
#{
source
}
/after/"
,
''
)
relative_path
=
expected_path
.
gsub
(
"
#{
source
}
/after/"
,
''
)
expected
=
Pathname
.
new
(
expected_path
)
produced
=
TMP_DIR
+
relative_path
produced
=
TMP_DIR
+
relative_path
case
expected
case
expected_path
when
%r[/xcuserdata/]
when
%r[/xcuserdata/]
# skip
next
when
%r[execution_output
\.
txt$]
when
%r[execution_output
\.
txt$]
# skip for now as the Pod might or might not be in the cache TODO
# skip for now as the Pod might or might not be in the cache TODO
when
%r[Podfile
\.
lock$]
next
compare_lockfile
(
expected
,
produced
,
relative_path
)
end
when
%r[
\.
pbxproj$]
compare_xcodeproj
(
expected
,
produced
,
relative_path
)
it
relative_path
do
else
case
expected_path
compare_generic
(
expected
,
produced
,
relative_path
)
when
%r[Podfile
\.
lock$]
end
file_should_exist
(
produced
)
lockfile_should_match
(
expected
,
produced
)
when
%r[
\.
pbxproj$]
file_should_exist
(
produced
)
xcodeproj_should_match
(
expected
,
produced
)
else
file_should_exist
(
produced
)
file_should_match
(
expected
,
produced
)
end
end
end
end
end
end
...
@@ -154,65 +164,79 @@ end
...
@@ -154,65 +164,79 @@ end
# @!group File Comparisons
# @!group File Comparisons
# Checks that the file exits.
#
# @param [Pathname] file
# The file to check.
#
def
file_should_exist
(
file
)
file
.
should
.
exist?
end
# Compares two lockfiles because CocoaPods 0.16 doesn't oder them in 1.8.7.
# Compares two lockfiles because CocoaPods 0.16 doesn't oder them in 1.8.7.
#
#
def
compare_lockfile
(
expected
,
produced
,
relative_path
)
# @param [Pathname] expected
# The reference in the `after` folder.
#
# @param [Pathname] produced
# The file in the temporary directory after running the pod command.
#
def
lockfile_should_match
(
expected
,
produced
)
expected_yaml
=
YAML
::
load
(
File
.
open
(
expected
))
expected_yaml
=
YAML
::
load
(
File
.
open
(
expected
))
produced_yaml
=
YAML
::
load
(
File
.
open
(
produced
))
produced_yaml
=
YAML
::
load
(
File
.
open
(
produced
))
desc
=
"Lockfile comparison error `
#{
relative_path
}
`"
desc
=
"Lockfile comparison error `
#{
expected
}
`"
desc
<<
"
\n
EXPECTED:
\n
#{
expected_yaml
}
\n
"
desc
<<
"
\n
EXPECTED:
\n
#{
expected_yaml
}
\n
"
desc
<<
"
\n
PRODUCED:
\n
#{
produced_yaml
}
\n
"
desc
<<
"
\n
PRODUCED:
\n
#{
produced_yaml
}
\n
"
it
relative_path
do
expected_yaml
.
should
.
satisfy
(
desc
)
do
|
expected_yaml
|
expected_yaml
.
should
.
satisfy
(
desc
)
do
|
expected_yaml
|
expected_yaml
==
produced_yaml
expected_yaml
==
produced_yaml
end
end
end
end
end
# Compares two Xcode projects in an UUID insensitive fashion and producing a
# Compares two Xcode projects in an UUID insensitive fashion and producing a
# clear diff to highlight the differences.
# clear diff to highlight the differences.
#
#
def
compare_xcodeproj
(
expected
,
produced
,
relative_path
)
# @param [Pathname] expected @see #lockfile_should_match
expected_proj
=
Xcodeproj
::
Project
.
new
(
expected
.
gsub
(
'project.pbxproj'
,
''
))
# @param [Pathname] produced @see #lockfile_should_match
produced_proj
=
Xcodeproj
::
Project
.
new
(
produced
.
to_s
.
gsub
(
'project.pbxproj'
,
''
))
#
def
xcodeproj_should_match
(
expected
,
produced
)
expected_proj
=
Xcodeproj
::
Project
.
new
(
expected
+
'..'
)
produced_proj
=
Xcodeproj
::
Project
.
new
(
produced
+
'..'
)
diff
=
produced_proj
.
to_tree_hash
.
recursive_diff
(
expected_proj
.
to_tree_hash
,
"#produced#"
,
"#reference#"
)
diff
=
produced_proj
.
to_tree_hash
.
recursive_diff
(
expected_proj
.
to_tree_hash
,
"#produced#"
,
"#reference#"
)
desc
=
"Project comparison error `
#{
relative_path
}
`"
desc
=
"Project comparison error `
#{
expected
}
`"
if
diff
if
diff
desc
<<
"
\n
#{
diff
.
to_yaml
.
gsub
(
'"#produced#"'
,
'produced'
.
red
).
gsub
(
'"#reference#"'
,
'reference'
.
yellow
)
}
"
desc
<<
"
\n
#{
diff
.
to_yaml
.
gsub
(
'"#produced#"'
,
'produced'
.
red
).
gsub
(
'"#reference#"'
,
'reference'
.
yellow
)
}
"
end
end
it
relative_path
do
diff
.
should
.
satisfy
(
desc
)
do
|
diff
|
diff
.
should
.
satisfy
(
desc
)
do
|
diff
|
diff
.
nil?
diff
.
nil?
end
end
end
end
end
# Compares two files to check if they are identical and produces a clear diff
# Compares two files to check if they are identical and produces a clear diff
# to highlight the differences.
# to highlight the differences.
#
#
def
compare_generic
(
expected
,
produced
,
relative_path
)
# @param [Pathname] expected @see #lockfile_should_match
it
relative_path
do
# @param [Pathname] produced @see #lockfile_should_match
File
.
exists?
(
expected
).
should
.
be
.
true
#
is_equal
=
FileUtils
.
compare_file
(
expected
,
produced
)
def
file_should_match
(
expected
,
produced
)
description
=
[]
is_equal
=
FileUtils
.
compare_file
(
expected
,
produced
)
description
<<
"File comparison error `
#{
expected
}
`"
description
=
[]
description
<<
""
description
<<
"File comparison error `
#{
expected
}
`"
description
<<
(
"--- DIFF "
<<
"-"
*
70
)
description
<<
""
Diffy
::
Diff
.
new
(
expected
.
to_s
,
produced
.
to_s
,
:source
=>
'files'
,
:context
=>
3
).
each
do
|
line
|
description
<<
(
"--- DIFF "
<<
"-"
*
70
)
case
line
Diffy
::
Diff
.
new
(
expected
.
to_s
,
produced
.
to_s
,
:source
=>
'files'
,
:context
=>
3
).
each
do
|
line
|
when
/^\+/
then
description
<<
line
.
gsub
(
"
\n
"
,
''
).
green
case
line
when
/^-/
then
description
<<
line
.
gsub
(
"
\n
"
,
''
).
red
when
/^\+/
then
description
<<
line
.
gsub
(
"
\n
"
,
''
).
green
else
description
<<
line
.
gsub
(
"
\n
"
,
''
)
when
/^-/
then
description
<<
line
.
gsub
(
"
\n
"
,
''
).
red
end
else
description
<<
line
.
gsub
(
"
\n
"
,
''
)
end
description
<<
""
<<
(
"--- PRODUCED "
<<
"-"
*
66
)
<<
""
description
<<
File
.
read
(
produced
)
description
<<
(
"--- END "
<<
"-"
*
70
)
description
<<
""
is_equal
.
should
.
satisfy
(
description
*
"
\n
"
)
do
|
is_equal
|
is_equal
==
true
end
end
end
end
description
<<
""
<<
(
"--- PRODUCED "
<<
"-"
*
66
)
<<
""
description
<<
File
.
read
(
produced
)
description
<<
(
"--- END "
<<
"-"
*
70
)
description
<<
""
is_equal
.
should
.
satisfy
(
description
*
"
\n
"
)
do
|
is_equal
|
is_equal
==
true
end
end
end
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment