Skip to content
Browse files

initial checkin

  • Loading branch information...
0 parents commit 8cba352a10d924173781ebcb51aa2b91738dc2f0 @tenderlove committed Feb 5, 2009
Showing with 68 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +8 −0 Rakefile
  3. +1 −0 lib/busted.rb
  4. +18 −0 lib/busted/gem.rb
  5. +8 −0 tasks/test.rb
  6. +20 −0 test/busted/test_gem.rb
  7. +10 −0 test/helper.rb
3 .gitignore
@@ -0,0 +1,3 @@
+.*.swp
+*.tmproj
+tags
8 Rakefile
@@ -0,0 +1,8 @@
+require 'rake'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+require 'rake/testtask'
+require 'rake/clean'
+require 'tasks/test'
+
+task :default => :test
1 lib/busted.rb
@@ -0,0 +1 @@
+require 'busted/gem'
18 lib/busted/gem.rb
@@ -0,0 +1,18 @@
+module Busted
+ class Gem
+ class << self
+ def spec_for name, version = nil
+ require 'rubygems'
+ dep = ::Gem::Dependency.new(name, version || ::Gem::Requirement.default)
+ specs = ::Gem.source_index.search dep
+ specs.sort_by { |spec|
+ File::Stat.new(spec.full_gem_path).mtime
+ }.last
+ end
+ end
+
+ def initialize gemspec
+ @gemspec = gemspec
+ end
+ end
+end
8 tasks/test.rb
@@ -0,0 +1,8 @@
+Rake::TestTask.new do |t|
+ %w[ lib ].each do |dir|
+ t.libs << dir
+ end
+
+ t.test_files = FileList['test/**/test_*.rb']
+ t.verbose = true
+end
20 test/busted/test_gem.rb
@@ -0,0 +1,20 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "helper"))
+
+module Busted
+ class TestGem < TestCase
+ def setup
+ require 'rubygems'
+ dep = ::Gem::Dependency.new('', ::Gem::Requirement.default)
+ specs = ::Gem.source_index.search dep
+ @spec = specs.first
+ @name = @spec.name
+ assert @name
+ end
+
+ def test_spec_for
+ broken_gem = Busted::Gem.spec_for(@name)
+ assert broken_gem
+ assert broken_gem.version
+ end
+ end
+end
10 test/helper.rb
@@ -0,0 +1,10 @@
+require 'test/unit'
+require 'busted'
+
+module Busted
+ class TestCase < Test::Unit::TestCase
+ unless RUBY_VERSION >= '1.9'
+ undef :default_test
+ end
+ end
+end

0 comments on commit 8cba352

Please sign in to comment.
Something went wrong with that request. Please try again.