Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1 from devxoul/rake-test
Browse files Browse the repository at this point in the history
Add test.
  • Loading branch information
devxoul committed May 8, 2015
2 parents 172d1de + 57afe1c commit fb269fe
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Rakefile
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
77 changes: 77 additions & 0 deletions test/test_core.rb
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

0 comments on commit fb269fe

Please sign in to comment.