Giter Club home page Giter Club logo

ruby-sinatra's Introduction

Vanilla Ruby Sinatra Project

This repository shows a basic setup for a Sinatra web application in Ruby.

Getting Started

Ruby and Bundler is expected to be installed on our system.

Installing

After cloning this repository, change into the newly created directory and run

bundle install

This will install all dependencies needed for the project.

Running the Tests

All tests can be run by executing

bundle exec rspec

rspec will automatically find all tests inside the spec directory and run them.

Testing Approach

The main Sinatra application is defined in app/Application.rb. The tests for it use rack-test to verify that the index page can be rendered successfully. This gem provides helper methods to exercise a Rack application during testing (e.g. get to send a GET request to the application).

Running the Application

Sinatra uses Rack, a standard interface for Ruby webservers, behind the scenes. Rack applications can be configured via a file called config.ru and started with the command rackup.

When executing

bundle exec rackup

it will automatically look for the file config.ru as it is the default when no arguments were given.

When executing the above command it will print logging information similar to the following:

$: bundle exec rackup
[2017-07-13 07:20:01] INFO  WEBrick 1.3.1
[2017-07-13 07:20:01] INFO  ruby 2.3.1 (2016-04-26) [x86_64-linux]
[2017-07-13 07:20:01] INFO  WEBrick::HTTPServer#start: pid=26153 port=9292
...

This shows that the application is running and listening on port 9292. The host and port can also be configured via --host and --port arguments respectively.

Using a browser to navigate to http://localhost:9292 will then show the example page.

Built With

License

This project is licensed under the MIT License - see the license.md file for details.

ruby-sinatra's People

Contributors

christophgockel avatar

Watchers

 avatar  avatar

Forkers

david-forer

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.