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
There are several things that need to be prepared to run this application locally, including:
you can click the link for more detail.
- Open your terminal and clone the App :
git clone https://github.com/hafizulf/rbsm.git
- Install
bundler
to get app dependencies :
cd rbsm
gem install bundler
# check if the bundle is installed properly
bundle -v
# your bundle version
- Install gem from
Gemfile
with this command :
bundle install
- 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]
- 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
- Run
.env
:
source .env
- Create folders for attachment :
mkdir -p public/uploads/posts
mkdir -p public/uploads/comments
- Run the app with this command :
ruby app.rb
- Access the App from your browser :
http://localhost:4567
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.
# 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
You can check the result of test coverage by visiting index.html
in Code Coverage Directory