Skip to content

Commit

Permalink
Rubinius support
Browse files Browse the repository at this point in the history
  • Loading branch information
glv committed Sep 16, 2010
1 parent 346551e commit b93a9e3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
*.sw?
*.rbc
.DS_Store
coverage
rdoc
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -5,7 +5,7 @@ gem 'rspec', '= 2.0.0.beta.22'

group :test do
gem 'rake', '>= 0.8.7'
gem 'rcov', '>= 0.9.9'
#gem 'rcov', '>= 0.9.9'
end

group :release do
Expand Down
3 changes: 1 addition & 2 deletions Gemfile.lock
Expand Up @@ -10,7 +10,6 @@ GEM
rubyforge (>= 2.0.0)
json_pure (1.4.6)
rake (0.8.7)
rcov (0.9.9)
rspec (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
Expand All @@ -25,10 +24,10 @@ GEM
json_pure (>= 1.1.7)

PLATFORMS
java
ruby

DEPENDENCIES
jeweler (>= 1.4.0)
rake (>= 0.8.7)
rcov (>= 0.9.9)
rspec (= 2.0.0.beta.22)
36 changes: 4 additions & 32 deletions README.md
Expand Up @@ -58,16 +58,17 @@ in many ways.

Currently, test/unit compatibility is much more limited than in
RSpec 1. The goal is not to make RSpec 2 a drop-in replacement for
test/unit; rather, we have two more limited goals:
test/unit; rather, I have three more limited goals:

1. to allow RSpec 2 examples to easily make use of test/unit assertions
in cases where those assertions are valuable, or where assertions
might be the best way to express particular expectations.
2. to make it *easy* for a project to switch an existing test/unit
suite over to run under RSpec, as the start of a gradual, piecemeal
conversion to RSpec.
3. to demonstrate how to extend RSpec 2.

As such, there are some things we don''t support:
As such, there are some things that are not supported:

* The top-level module name is different. For example, one requires
`rspec/unit` rather than `test/unit`, and extends `RSpec::Unit::TestCase`
Expand All @@ -79,37 +80,8 @@ As such, there are some things we don''t support:
* All test output and summaries are in RSpec style; test/unit-compatible
output is not supported.

We will certainly consider supporting those things if there is demand.

I originally wrote this test/unit compatibility gem for Micronaut, a
lightweight RSpec clone by Chad Humphries. Micronaut has been rolled
into RSpec as the core of RSpec 2, and I was able to move the test/unit
compatibility over with minimal changes.

The point of this gem is not that I think test/unit is a better way
to write tests than the RSpec style. I admit that I'm a TDD oldtimer
who sees RSpec as mostly a cosmetic (rather than fundamental) change,
but that doesn't mean it's not an important change. My curmudgeonly
nature has its limits, and I do find specs a big improvement.

So why rspec-unit? Three reasons:

1. I wanted to show off the generality of Micronaut's (and now RSpec's)
architecture. I hope rspec-unit can serve as an example for anyone
who wants to experiment with new ways of expressing tests and specs
on top of RSpec.
2. Many projects with existing test/unit test suites might want to
benefit from the [metadata goodness][metadata] in RSpec 2, or begin
a gradual, piecemeal change to an RSpec style. That's pretty
easy to do with rspec-unit.
3. Even when writing specs and examples, I frequently encounter
cases where an assertion is more expressive than a `should`
expression. It's nice just to have assertions supported within
RSpec examples.
I will certainly consider supporting those things if there is demand.

[uth]: http://blog.thinkrelevance.com/2009/4/1/micronaut-innovation-under-the-hood
[metadata]: http://blog.thinkrelevance.com/2009/3/26/introducing-micronaut-a-lightweight-bdd-framework

## To Do

It would be nice to try using the assertion code from minitest,
Expand Down
4 changes: 2 additions & 2 deletions spec/test_case_spec.rb
Expand Up @@ -229,7 +229,7 @@ class SampleTestCaseForName < RSpec::Unit::TestCase

it "sets :caller" do
@foo.metadata[:example_group][:caller].first.should =~ Regexp.new(Regexp.escape(@foo.metadata[:example_group][:location]))
@foo.metadata[:example_group][:caller].size.should == @caller_at_foo_definition.size + 3
@foo.metadata[:example_group][:caller].size.should be_>(@caller_at_foo_definition.size)
end

it "has nil for :block and :describes" do
Expand Down Expand Up @@ -310,7 +310,7 @@ def test_baz; end
def test_baz; end
end
test_baz_metadata[:caller].first.should match(/^#{Regexp.escape(@foo.examples.first.metadata[:location])}/)
test_baz_metadata[:caller].size.should == caller.size + 3
test_baz_metadata[:caller].size.should be_>(caller.size)
end

it "records test_info metadata for next test method" do
Expand Down

0 comments on commit b93a9e3

Please sign in to comment.