Skip to content

Ruby script to quickly create RSpec test files in matching directories

Notifications You must be signed in to change notification settings

andersennl/rspec-file-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSpec file creator

This project currently uses Ruby version 2.5.1, which is hard coded into the Gemfile. It uses Rails' ActiveSupport to convert the file name to module/class names.

Usage

Running e.g.

rspeccreator.rb app/controllers/users/signup_controller.rb

creates the following file:

spec/controllers/users/signup_controller_spec.rb

with the following content:

require "spec_helper"

describe Users::SignupController do
  
end

As you can see, the script automatically parses the correct module and class names and inserts them appropriately into the spec file.

Setup

git clone https://github.com/andersennl/rspec-file-creator.git
cd rspec-file-creator
bundle

In order to execute the script from everywhere, consider adding the src path to your PATH.

If you're using zsh, add the following to your ~/.zshrc:

export PATH=path-to-this-project/src:$PATH

Now either open up a new shell window or run source ~/.zshrc to load the new path into your PATH.

Now you can continue as described under Usage.

Contribution

Feel free to open up issues or pull requests.

About

Ruby script to quickly create RSpec test files in matching directories

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages