/rbsm

A simple social media app using Ruby that created for final project in generasi gigih 1.0 backend path

Primary LanguageRuby

RBSM

Short description about what is RBSM ?

RBSM is a simple social media API-only application based on Ruby lang. This app is used only on one small environment so no authentication is required. Where the user can input data, create a new post with a limit of 1000 characters and a maximum of one attachment. Users can also make comments, check some posts that contain certain hashtags and users can also see trending hashtags for the past 24 hours.

See API Collection here

Prerequisites to run the application locally

There are several things that need to be prepared to run this application locally, including:

Requires

you can click the link for more detail.

  1. Ruby with version 2.7.0 above. Link
  2. MySQL Link

Setup

  1. Open your terminal and clone the App :
git clone https://github.com/hafizulf/rbsm.git
  1. Install bundler to get app dependencies :
cd rbsm
gem install bundler
# check if the bundle is installed properly
bundle -v
# your bundle version
  1. Install gem from Gemfile with this command :
bundle install
  1. Import database :
cd db_schema
# check your mysql status
service mysql status
# if stopped, run it first
service mysql start
# begin import db
mysql -u username -p < database.sql
[Enter your password]
  1. Setup environment. You can write it manually in db/conn.rb, or create a new .env file:
cd ..
nano .env
# paste and change these lines
export DB_HOST=127.0.0.1
export DB_NAME=social_media
export DB_USER=your-username
export DB_PASS=your-password
# save and exit
  1. Run .env :
source .env
  1. Create folders for attachment :
mkdir -p public/uploads/posts
mkdir -p public/uploads/comments
  1. Run the app with this command :
ruby app.rb
  1. Access the App from your browser :
http://localhost:4567

How to run test suite

You can check this Link for installing rspec to your system. Or if you follow the steps above, then you are ready to run the test.

Running Specs

# open your terminal and change directory to app folder
cd rbsm
# run unit test for all
rspec spec/
# run unit test for model/controller only
rspec spec/model
# run unit test for spesific file (in case for post model)
rspec spec/model/post.rb
# run unit test for spesific file (by line)
rspec spec/model/post.rb:10

Code Coverage

You can check the result of test coverage by visiting index.html in Code Coverage Directory