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

  • Home
  • SEARCH
  • 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 7965177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:04:35+00:00 2026-06-04T06:04:35+00:00

I’m building an app including a Rails API and want to use Ruby MiniTest::Spec

  • 0

I’m building an app including a Rails API and want to use Ruby MiniTest::Spec to test.

What’s a good way to set it up?

For example, good directory organization, good way to include files, etc.?

I’m using the guidelines in the book Rails 3 In Action which uses RSpec and has a great chapter on APIs. The big change is preferring MiniTest::Spec.

  • 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-06-04T06:04:36+00:00Added an answer on June 4, 2026 at 6:04 am

    Answering with what I’ve found so far in case it’s helpful to other developers….

    spec/api/items_spec.rb

    require 'spec_helper'
    
    class ItemsSpec < ActionDispatch::IntegrationTest
    
      before do
        @item = Factory.create(:item)
      end
    
      describe "items that are viewable by this user" do
        it "responds with good json" do
          get "/api/items.json"
          response.success?.must_equal true
          body.must_equal Item.all.to_json
          items = JSON.parse(response.body)
          items.any?{|x| x["name"] == @item.name}.must_equal true
        end
      end
    
    end
    

    spec/spec_helper.rb

    ENV["RAILS_ENV"] = "test"
    require File.expand_path('../../config/environment', __FILE__)
    gem 'minitest'
    require 'minitest/autorun'
    require 'action_controller/test_case'
    require 'capybara/rails'
    require 'rails/test_help'
    require 'miniskirt'
    require 'factories'
    require 'mocha'
    
    # Support files                                                                                                                                                                                                                                                                  
    Dir["#{File.expand_path(File.dirname(__FILE__))}/support/*.rb"].each do |file|
      require file
    end
    

    spec/factories/item.rb

    Factory.define :item do |x|
      x.name { "Foo" }
    end
    

    app/controllers/api/base_controller.rb

    class Api::BaseController < ActionController::Base
      respond_to :json
    end
    

    app/controllers/api/items_controller.rb

    class Api::ItemsController < Api::BaseController
      def index
        respond_with(Item.all)
      end
    end
    

    config/routes.rb

    MyApp::Application.routes.draw do
      namespace :api do
        resources :items
      end
    end
    

    Gemfile

    group :development, :test do
      gem 'capybara'  # Integration test tool to simulate a user on a website.
      gem 'capybara_minitest_spec'  # MiniTest::Spec expectations for Capybara node matchers.
      gem 'mocha'  # Mocking and stubbing library for test doubles for Ruby.
      gem 'minitest', '>= 3'  # Ruby's core TDD, BDD, mocking, and benchmarking.
      gem 'minitest-capybara'  #  Add Capybara driver switching parameters to minitest/spec.
      gem 'minitest-matchers'  # RSpec/Shoulda-style matchers for minitest.
      gem 'minitest-metadata'  # Annotate tests with metadata key-value pairs.
      gem 'minitest-spec-rails'  # Drop in MiniTest::Spec support for Rails 3.
      gem 'miniskirt'  # Factory creators to go with minitest.
      gem 'ruby-prof'  # Fast code profiler for Ruby with native C code.
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the

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.