Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7587611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:43:00+00:00 2026-05-30T19:43:00+00:00

I want to create a small Ruby project with 10 ~ 20 classes/files. I

  • 0

I want to create a small Ruby project with 10 ~ 20 classes/files. I need some gems and I want to use RSpec as a test framework.

I might want to build a gem later on, but that is not certain.

Is there some how-to or guide that shows me how to set up the basic structure of my project?

Questions that I have are:

  • Where do I put all my custom Errors/Exceptions?
  • Are there some conventions out there for naming directories like lib, bin, src etc?
  • Where do I put test data or documents?
  • Where do I require all my files so I have access to them in my project?

I know I could do everything from scratch, but I would like some guidance. There are some good gems out there that I could copy, but I am not certain what I really need and what I can delete.

I looked at http://gembundler.com/, but it stops after setting up Bundler.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:43:01+00:00Added an answer on May 30, 2026 at 7:43 pm

    To get a good start, you can use the bundle gem command and rspec --init.

    ~/code $ bundle gem my_lib
          create  my_lib/Gemfile
          create  my_lib/Rakefile
          create  my_lib/LICENSE.txt
          create  my_lib/README.md
          create  my_lib/.gitignore
          create  my_lib/my_lib.gemspec
          create  my_lib/lib/my_lib.rb
          create  my_lib/lib/my_lib/version.rb
    Initializating git repo in /Users/john/code/my_lib
    ~/code $ cd my_lib/
    ~/code/my_lib $ git commit -m "Empty project"
    ~/code/my_lib $ rspec --init
    The --configure option no longer needs any arguments, so true was ignored.
      create   spec/spec_helper.rb
      create   .rspec
    
    • code goes in lib
    • specs go in spec
    • test data or documents go in spec/fixtures/
    • Require all your ruby files in lib/my_lib.rb. You can define your exceptions in that file, too, or in their own files — according to your own preference.
    • C source files go in ext/my_lib
    • shell scripts and executables go in bin

    When in doubt, just look at how other gems are laid out.


    Further information:

    You should add rspec as a development dependency in your gemspec to make things easier for other developers

    1. Edit my_lib.gemspec, adding gem.add_development_dependency 'rspec' and gem.add_development_dependency 'rake' near the bottom.
    2. Add Bundler.setup and require 'my_lib' to the top of spec/spec_helper.rb to ensure your gem dependencies are loaded when you run your specs.
    3. Add require "rspec/core/rake_task" and task :default => :spec to your Rakefile, so that running rake will run your specs.

    While you’re working on your newest creation, guard-rspec can save you time and hassle by automatically running your specs as files change, alerting you to spec failures.

    ~/code/my_lib $ git add spec/spec_helper.rb
    ~/code/my_lib $ git commit -am "Add RSpec"
    ~/code/my_lib $ vim my_lib.gemspec # add guard development dependency
    ~/code/my_lib $ bundle
    ~/code/my_lib $ bundle exec guard init
    ~/code/my_lib $ vim Guardfile # Remove the sections below the top one
    ~/code/my_lib $ git add Guardfile
    ~/code/my_lib $ git commit -am "Add Guard"
    

    After you’re happy with your creation, push it up to github

    # create a github repository for your gem, then push it up
    ~/code/my_lib $ curl -u myusername https://api.github.com/user/repos -d '{"name":"my_lib"}' 
    ~/code/my_lib $ git remote add origin git@github.com:myusername/my_lib.git
    ~/code/my_lib $ git push
    

    Then, when you’re ready to release your gem on Rubygems.org, run rake release, which will walk you through the steps.

    ~/code/my_lib $ rake release
    

    Further References

    • The Rubygems patterns guide (and home page), from Matheus Moreira’s answer. They’re really great references
    • How I Start by Steve Klabnik
    • Exercise 46: A Project Skeleton from Zed Shaw’s Learn Ruby The Hard Way
    • New Gem with Bundler video on Railscasts
    • docs
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning to do TDD in practice in small project. I want to create
I want to create a small database for my inventory but I have some
I have a directory full of small text files. I want to create a
I want to create a small java application to copy some wiki content from
i want to create functions what get the folder size. I write small function:
I want to create a small document management system. There are several users who
I want to create a small helpdesk ticket control system at work, that would
I know how to create small data driven websites but want to get an
I want to create a small program in C# in Windows that would open
If I want to create a project that is fairly basic (VS2010, C# &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.