0.0
No commit activity in last 3 years
No release in over 3 years
Read model file to extract the validations/associations and then utilize Rails generator to write correspondent shoulda test cases to your correspondent spec file
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

QuickShoulda ¶ ↑

<img src=“https://badge.fury.io/rb/quick_shoulda.png” alt=“Gem Version” /> <img src=“https://travis-ci.org/nqtien310/quick_shoulda.png?branch=master” alt=“Build Status” />

A Rails generator which automatically generates Shoulda test cases ,

Just by specifying path to your model file , a bunch of Shoulda test cases will be generated for you in the correspondent spec file

Examples : ¶ ↑

Sample model :

app/models/user.rb

class User < ActiveRecord::Base
  validates :username , :presence => true
  validates :email, :format => EmailRegex, :uniqueness => true

  has_many :posts
  has_many :comments, :through => :posts
end

Just 1 simple command

Rails generate quick_shoulda:g User
or
Rails generate quick_shoulda:g app/models/user.rb

These lines will be added to spec/models/user_spec.rb ( QuickShoulda will automatically create this file if it’s not yet created )

describe 'User' do
  describe '#Validations' do
    it { should validate_presence_of(:username) }
    it { should validate_uniqueness_of(:email) }
    it { should allow_value('us@gmail.com').for(:email) }
    it { should allow_value('us.vn@gmail.com').for(:email) }
    it { should allow_value('us_vn@gmail.com').for(:email) }
  end

  describe '#Associations' do
    it { should have_many(:posts) }
    it { should have_many(:comments).through(:posts) }
  end
end

Installation¶ ↑

gem install 'quick_shoulda'

or add to Gemfile:

group :development do
  gem 'quick_shoulda'
end

Usage¶ ↑

Path to model file as parameter

Rails generate quick_shoulda:g app/models/user.rb

Model name as parameter

Rails generate quick_shoulda:g User

multi model name / paths as parameter

Rails generate quick_shoulda:g User Post Comment Admin::Statistic
or
Rails generate quick_shoulda:g app/models/user.rb app/models/post.rb

Configurations¶ ↑

Install config file by

Rails generate quick_shoulda:install

This will place the .qshoulda.yml in the root path , then edit this file for configuration purpose

Config location to put the generated spec files

spec_folder: test/models

Contributing¶ ↑

  1. Fork it

  2. Create your feature branch (‘git checkout -b my-new-feature`)

  3. Commit your changes (‘git commit -am ’Added some feature’‘)

  4. Push to the branch (‘git push origin my-new-feature`)

  5. Create new Pull Request

Copyright © 2013 nqtien310@gmail.com.