GithubHelp home page GithubHelp logo

tset's Introduction

Tset

Build Status

Tset generates tests for your models in your Rails application.

Why?

TDD is great, but sometimes you just want to write some codes.

Enter 'Development Driven Test'. Tset enables you to just write codes and worry about tests later.

Installation

Run installation command.

gem install tset

OR if you want to use bundler,

gem 'tset', group: :development

Run bundle install.

Append bundle exec when you run tset commands.

Usage

In your application root directory, run the generator.

tset generate model YOUR_MODEL_NAME

Tset will read your model and generate a test accordingly.

If your model looks like the following,

class Post < ActiveRecord::Base
  validates_presence_of :author
  validates_length_of :author, maximum: 30
  belongs_to :author
end

Tset will generate a spec file such as:

require 'spec_helper'

describe Post do

  describe "associations" do
    it { is.expected_to belong_to(:author) }
  end

  describe "validations" do
    it { is.expected_to ensure_length_of(:author).is_at_most(30) }
    it { is.expected_to validate_presence_of(:author) }
  end
end

By default, the Tset will use RSpec. Help us add Minitest support by contributing.

Dependency

You need shoulda-matchers to run some of tests Tset generates for you.

It lets you use matchers such as validate_presence_of(:name) in your spec.

Architecture

There are four main objects at play: Analyzer, Translator, Writer, and Generator.

  • Analyzer reads your model file, and matches any lines that are deemed 'testable'. It returns an array of Tset::Testable objects.

  • Translator converts Tset::Testable objects into Tset::Test objects.

  • Writer writes the actual test in the spec file, for each Tset::Test objects.

  • Generator copies spec templates, groups all major components together, and responds to CLI.

Random

Tset is a test spelled backwards.

Contributing

Tset is in beta. We need your help to improve it.

TODO

  • Add more translation rules for testables (located in tset/translators/rspec.rb).
  • Support Minitest.
  • Support controllers.

tset's People

Stargazers

Björn Calamay avatar Rob Williams avatar Chew Chit Siang avatar Drew Hamlett avatar Brian Joyce avatar

Watchers

James Cloos avatar Sung avatar  avatar

tset's Issues

Minitest support

Generate tests using minitest if option is specified as such.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.