Explore the docs »
· Report Bug · Request Feature
The Tea House backend is build on Rails 5.2.8.1 and Ruby 2.7.4
-
Clone the repo
git clone git@github.com:neb417/tea_house.git
-
Add gems In group :development, :test do
gem 'capybara' gem 'factory_bot_rails' gem 'faker' gem 'pry' gem 'rspec-rails' gem 'rubocop-faker' gem 'rubocop-rails' gem 'shoulda-matchers' gem 'simplecov'
-
Install Gems with
$bundle install
-
Migrate database with
$rails db:{create,migrate}
-
Seed development/test database with
$rails db:seed
-
Run test suite with
$bundle exec rspec
- GET a customer subsctriptions by customer id
Postman:
GET http://localhost:3000/api/v1/subscriptions
query params
key: customer_id
value: 2
{
"data": {
"subscriptions": [
{
"id": 4,
"price": 500,
"status": "cancelled",
"frequency": 14,
"title": "Rize",
"tea": {
"title": "Rize",
"description": "Meditation fanny pack kickstarter truffaut kinfolk aesthetic blue bottle chia.",
"temperature": 100,
"brew_time": 222
}
},
{
"id": 5,
"price": 3008,
"status": "active",
"frequency": 14,
"title": "Gaoshan",
"tea": {
"title": "Gaoshan",
"description": "Echo chia selfies slow-carb keytar viral authentic jean shorts.",
"temperature": 93,
"brew_time": 233
}
},
{
"id": 10,
"price": 500,
"status": "active",
"frequency": 7,
"title": "English Breakfast",
"tea": {
"title": "English Breakfast",
"description": "Street shabby chic hella butcher occupy five dollar toast mumblecore chia banjo.",
"temperature": 92,
"brew_time": 211
}
}
]
}
}
- CREATE a customer subscription
Postman:
POST http://localhost:3000/api/v1/subscriptions
query params
key: customer_id, value: 2
key: tea_id, value: 1
key: title, value: English Breakfast
key: frequency, value: 7
key: price, value: 500
{
"data": {
"id": 10,
"price": 500,
"status": "active",
"frequency": 7,
"title": "English Breakfast",
"tea": {
"title": "English Breakfast",
"description": "Street shabby chic hella butcher occupy five dollar toast mumblecore chia banjo.",
"temperature": 92,
"brew_time": 211
}
}
}
- UPDATE a customer subscription
Postman:
PATCH http://localhost:3000/api/v1/subscriptions/4
query params
key: id, value: 4
key: customer_id, value: 2
key: tea_id, value: 1
key: frequency, value: 7
key: price, value: 500
status: cancelled
{
"data": {
"success": "Your subscriptions have been updated"
}
}
- CREATE a customer
Postman:
POST http://localhost:3000/api/v1/customers
query params
key: first_name, value: Jerry
key: last_name, value: Johnson
key: email, value: mail@mail.com
key: address, value: 123 South St, Town, ST, 12345
{
"data": {
"id": 6,
"first_name": "Jerry",
"last_name": "Johnson",
"email": "mail@mail.com",
"address": "123 South St, Town, ST, 12345"
}
}
Capybara | factory_bot_rails | faker |
pry | rspec-rails | rubocop-faker |
rubocop-rails | shoulda-matchers | simplecov |