GithubHelp home page GithubHelp logo

johnsantosuosso / rails-engine Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 802 KB

Rails Engine is a Rails application that works within a service-oriented architecture to expose data through an API that the front-end team can consume.

Ruby 18.53% HTML 81.47%
activerecord apis factory-bot faraday postgresql postman rspec-rails ruby ruby-on-rails tdd

rails-engine's Introduction

Rails Engine

  • Rails Engine is a Rails application that works within a service-oriented architecture to expose data through an API that the front-end team can consume.
  • Additional Functionality:
    • Uses serializers to format JSON responses
    • Tests API exposure
    • Uses SQL and ActiveRecord to gather data

📖 Table of Contents

Table of Contents
  1. ➤ Technical Requirements
  2. ➤ Project Files Description
  3. ➤ Database Schema
  4. ➤ Getting Started
  5. ➤ Scenario 1: Run RSpec Test Suite
  6. ➤ Scenario 2: Run Postman Test Collections
  7. ➤ Credits

💻 Technical Requirements

  • Ruby 2.7.4
  • Rails 5.2.6
  • RSpec-Rails 4.0.1
  • JSON API Serializer
  • Factory Bot
  • Faker
  • SimpleCov
  • Postman

Installation instructions found in ➤ Getting Started

💾 Project Files Description

  • app/controllers/api/v1
    1. Contains several controllers responsible for rendering JSON responses and status codes.
  • app/serializers
    1. Serializers for Item and Merchant objects.
    2. Uses the JSON API Serializer Gem to format responses.
  • app/models
    1. Contains models for with added associations and validations
  • spec/factories
    1. Defines FactoryBot objects instantiated in test suite
  • app/requests
    1. Testing suite for API calls to endpoints
  • app/models
    1. Model tests for database objects invoked in API calls

Some other supporting files

  • app/coverage
    1. Shows SimpleCov coverage report

🖥️ Database Schema

Screen Shot 2022-09-04 at 12 53 40 PM

Note: Only Items, Merchants, Invoices, Invoice Items, and Customers were utilized for this project.

📖 Getting Started

1. Create a new directory on your computer where you'd like the program to live.

$ mkdir /your_folder/rails-engine

2. Navigate into the recently created directory.

$ cd /your_folder/rails-engine

3. Copy the repository by clicking on the code button on Github repo page (using SSH).

183747041-40f47875-442e-4008-8d00-8c45bf2731fe

4. Clone the recently copied repository information into your currenty directory.

$ git clone [email protected]:JohnSantosuosso/rails-engine.git

5. Open the repository in your preferred IDE. If you are using VSCode, use the code command shown below:

$ code .

6. Download Tests for Postman.

7. Import Postman tests.

  • In Postman, in the top left corner, click on the Import button, and use the file selector to locate the two files on your operating system.
  • Next, you’ll confirm the import. The test suite should display as a Postman Collection v2.1 and import as a Collection. Click the Import button to continue.
  • Within your collections in Postman, you should see two collections– Rails Engine Lite, Part 1, and Rails Engine Lite, Part 2.

8. In your IDE, install dependencies found in Gemfile using your terminal.

$ bundle install

9. Run migrations and dump schema

$ rake db:{drop,create,migrate,seed}
$ rails db:schema:dump

🔸 Scenario 1: Run RSpec Test Suite

View the tests for API endpoints inside spec/requests.

Test all functionality by running:.

$ bundle exec rspec spec

🔸 Scenario 2: Run Postman Test Collections

API endpoints can be tested both individually and collectively.

  • Testing an endpoint
    • Start the application on your local server
      • $ rails s
    • Open the Postman Test Collections
      • Find the appropriate endpoint within the Postman collection you imported.
      • For example, Get All Merchants. When you select Get All Merchants from the list, you should see a Postman tab open, pre-populated with everything you need to connect to the endpoint in your code and see if it works correctly.
      • Click the Send button in the top right corner.
      • In the lower portion of the Postman interface, you should see Body, Cookies, Headers and a spot that says something like Test Results (7/7). This would indicate that 7 tests passed out of 7. If you see, for example, 3/7 then 3 tests passed and 4 did not.

    📜 Credits

    John Santosuosso

    GitHub Badge LinkedIn Badge

    Project inspired and guided by Turing School of Software and Design's Rails Engine Lite.

rails-engine's People

Contributors

johnsantosuosso avatar

Watchers

 avatar

Forkers

wes30303

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.