Skip to content

Commit

Permalink
Cleanup for RSpec2 and addition of Gemfile
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Mar 16, 2012
1 parent 714c506 commit cf63187
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 24 deletions.
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source :rubygems
#gemspec

group :development do
gem 'hoe'
gem 'test-unit', :platform => :ruby_19
gem 'rspec'
gem 'rake'
end
25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
hoe (2.16.1)
rake (~> 0.8)
rake (0.9.2.2)
rspec (2.8.0)
rspec-core (~> 2.8.0)
rspec-expectations (~> 2.8.0)
rspec-mocks (~> 2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
test-unit (2.4.4)

PLATFORMS
ruby

DEPENDENCIES
hoe
rake
rspec
test-unit
19 changes: 8 additions & 11 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,37 @@ File sandbox creates a space for your tests to safely hit the file system. It al

in rspec :

require 'rubygems'
require 'spec'
require 'file_sandbox_behavior'

describe File do
include FileSandbox

it 'should read the contents of a file' do
sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'

sandbox['/b/a.txt'].contents.should == 'some stuff'
File.read(sandbox.root + "/b/a.txt").should == 'some stuff'
end
end

in test unit :

require 'rubygems'
require 'test/unit'
require 'file_sandbox'

class MyFileTest < Test::Unit::TestCase
include FileSandbox

def test_read
in_sandbox do |sandbox|
sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'

assert_equal 'some stuff', File.read(sandbox.root + '/b/a.txt')
assert_equal 'some stuff', sandbox['/b/a.txt'].contents
end
end
end


== Contact

Expand All @@ -51,4 +48,4 @@ License:: LGPL License

== Home Page

http://onemanswalk.com
http://onemanswalk.com
13 changes: 7 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
require 'rubygems'
require 'rake/clean'
require 'rake/testtask'
require 'spec/rake/spectask'
require 'rspec/core/rake_task'
require 'hoe'
require './lib/file_sandbox.rb'

$LOAD_PATH.unshift File.dirname(__FILE__) + "/lib"
require 'file_sandbox'

desc "Default Task"
task :default => [:clean, :test]

desc "Run all tests"
task :test => [:unit, :spec]

Spec::Rake::SpecTask.new(:spec) do |t|
t.spec_files = FileList['examples/*_example.rb']
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = "./examples/*.rb"
end

Rake::TestTask.new(:unit) do |t|
t.test_files = FileList['test/**/*test.rb']
t.verbose = false
end


Hoe.new('file_sandbox', FileSandbox::VERSION) do |p|
p.rubyforge_name = 'filesandbox'
p.summary = p.description = p.paragraphs_of('README.txt', 2).first
Expand Down
6 changes: 2 additions & 4 deletions examples/rspec_example.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
require 'rubygems'
require 'spec'
require 'file_sandbox_behavior'

describe File do
include FileSandbox

it 'should read the contents of a file' do
sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'

sandbox['/b/a.txt'].contents.should == 'some stuff'
File.read(sandbox.root + "/b/a.txt").should == 'some stuff'
end
Expand Down
3 changes: 1 addition & 2 deletions examples/test_unit_example.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
require 'rubygems'
require 'test/unit'
require 'file_sandbox'

Expand All @@ -9,7 +8,7 @@ class MyFileTest < Test::Unit::TestCase
def test_read
in_sandbox do |sandbox|
sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'

assert_equal 'some stuff', File.read(sandbox.root + '/b/a.txt')
assert_equal 'some stuff', sandbox['/b/a.txt'].contents
end
Expand Down
2 changes: 1 addition & 1 deletion lib/file_sandbox_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/file_sandbox'
require 'file_sandbox'

module FileSandbox
def self.included(spec)
Expand Down

0 comments on commit cf63187

Please sign in to comment.