From 4dd02cc4e35212ce6c564af3acc8e25175aa12aa Mon Sep 17 00:00:00 2001 From: Eloy Duran Date: Wed, 25 May 2011 17:48:09 +0200 Subject: [PATCH] Improve rake spec task. --- Rakefile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 1d060a1..1283a89 100644 --- a/Rakefile +++ b/Rakefile @@ -9,9 +9,26 @@ task :serve_fixtures do exec "rackup -s webrick ./Spec/fixtures/config.ru" end +def is_fixture_server_running? + require 'socket' + TCPSocket.new('localhost', 9292) + true +rescue Errno::ECONNREFUSED + false +end + desc "Run the specs" task :spec do - exec "ruby #{File.expand_path('../vendor/NuBacon/bin/nu-bacon.rb', __FILE__)} --project iTrakt.xcodeproj --target Specs" + ios_sim = `which ios-sim`.strip + if ios_sim.empty? + puts "[!] Unable to find `ios-sim'. Install it with: $ brew install ios-sim" + exit 1 + elsif !is_fixture_server_running? + puts "[!] It seems the fixture server isn't running. Start it with: $ rake serve_fixtures" + else + sh "xcodebuild -project iTrakt.xcodeproj -target Specs -configuration Debug -sdk iphonesimulator4.2" + exec "#{ios_sim} launch build/Debug-iphonesimulator/Specs.app" + end end task :default => :spec