Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Uses ruby_scribe to convert your Test::Unit (+ shoulda) tests into RSpecs

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 rspecify.gemspec
README.rdoc

Build Status

RSpecify

Converting your tests from Test::Unit to RSpec is a drag when done by hand. This utility intelligently converts them to get you (hopefully) 90% of the way there.

In-Progress

NOTE: This gem is not essentially unusable and is being continually worked on - more of a proof of concept for now.

Command-Line Usage

The gem comes with a thor task that you can use to print out a converted version of any Ruby file containing Test::Unit Code.

$ rspecify cat test_project.rb

API Usage

This is built on the tree-walking base class RubyTransform::Transformer from the ruby_transform project. The principal transform, which is a composite of other more granular transforms, is +RSpecify::Transformer+. Here's how it can be used in conjunction with ruby_parser:

sexp = RubyParser.new.parse(File.read(path))
sexp = RSpecify::Transformer.new.transform(sexp)

emitter = RubyScribe::Emitter.new
emitter.methods_without_parenthesis += ["it", "describe", "context", "should", "should_not"]
emitter.emit(sexp)

Supported Test::Unit Assertion Transforms:

  • assert_equals

  • assert_not_equals

  • assert_not_nil

Example:

Original (Test::Unit):

class MyClass < ActiveSupport::TestCase
  def test_should_be_one
    assert_equals something, 1
  end

  def test_should_not_be_one
    assert_not_equals something, 1
  end

  def test_should_not_be_nil
    assert_not_nil something
  end
end

Transformed (RSpec):

describe MyClass do
  it "should be one" do
    something.should == 1
  end

  it "should not be one" do
    something.should_not == 1
  end

  it "should not be nil" do
    something.should_not be_nil
  end
end
Something went wrong with that request. Please try again.