This repository has been archived by the owner on Jul 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from devxoul/rake-test
Add test.
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs << 'test' | ||
end | ||
|
||
desc "Run tests" | ||
task :default => :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
require 'test/unit' | ||
|
||
require_relative "../lib/cocoaseeds" | ||
|
||
class CoreTest < Test::Unit::TestCase | ||
|
||
def setup | ||
pwd = File.expand_path(File.dirname(__FILE__)) | ||
|
||
@project_dirname = File.join(pwd, "TestProj") | ||
@seeds_dirname = File.join(@project_dirname, "Seeds") | ||
|
||
# clean | ||
FileUtils.rm_rf(@project_dirname) | ||
|
||
# create a new project | ||
@project_filename = File.join(@project_dirname, "TestProj.xcodeproj") | ||
project = Xcodeproj::Project.new(@project_filename) | ||
project.new_target(:application, "TestProj", :ios) | ||
project.save | ||
|
||
# cocoaseeds | ||
@seed = Seeds::Core.new(@project_dirname) | ||
end | ||
|
||
def teardown | ||
FileUtils.rm_rf(@project_dirname) | ||
end | ||
|
||
def project | ||
Xcodeproj::Project.open(@project_filename) | ||
end | ||
|
||
def seedfile(content) | ||
path = File.join(@project_dirname, "Seedfile") | ||
content = content ? content.strip.sub(/^\s+/, '') : '' | ||
File.write(path, content) | ||
end | ||
|
||
def test_install | ||
seedfile %{ | ||
github "devxoul/JLToast", "1.2.2", :files => "JLToast/*.{h,swift}" | ||
} | ||
@seed.install | ||
|
||
assert\ | ||
File.exists?(File.join(@seeds_dirname, "JLToast")), | ||
"Directory Seeds/JLToast not exists." | ||
|
||
assert_not_nil\ | ||
self.project["Seeds"]["JLToast"], | ||
"Group 'Seeds/JLToast' not exists in the project." | ||
|
||
self.project["Seeds"]["JLToast"].files.each do |file| | ||
assert_match /.*\.(h|swift)/, file.name | ||
end | ||
end | ||
|
||
def test_remove | ||
seedfile %{ | ||
github "devxoul/JLToast", "1.2.2", :files => "JLToast/*.{h,swift}" | ||
} | ||
@seed.install | ||
|
||
seedfile nil | ||
@seed.install | ||
|
||
assert\ | ||
!File.exists?(File.join(@seeds_dirname, "JLToast")), | ||
"Directory Seeds/JLToast exists." | ||
|
||
assert_nil\ | ||
self.project["Seeds"]["JLToast"], | ||
"Group 'Seeds/JLToast' exists in the project." | ||
end | ||
|
||
end |