Project

rspecify

0.01
No commit activity in last 3 years
No release in over 3 years
Provides some automation to attempt to convert your Ruby Test::Unit tests into RSpec.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.0

Runtime

~> 0.6.0
~> 2.3.1
~> 0.1.4
~> 0.13
 Project Readme

<img src=“https://secure.travis-ci.org/rubiety/rspecify.png?branch=master” alt=“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