Giter Club home page Giter Club logo

sinatra-twitter-todo's Introduction

Sinatra Twitter Todo

We're going to use Sinatra to get the latest @flatironschool tweets.

Go to each file sequentially and read the comments. They should guide you to the next file in the application's path. Below is the order of the application as well.

First, the Anatomy of a Basic Sinatra App

├── Gemfile
├── README.md
├── Rakefile
├── app.rb # the main web server program
├── config
│   └── environment.rb # project manifest where files are required
├── config.ru # after requiring all of the files, this runs App (app.rb)
├── models # classes and ActiveRecord models
├── public # front-end stuff
│   ├── images
│   ├── javascripts
│   └── stylesheets
├── spec # tests
│   ├── sinatra_twitter_todo_spec.rb
│   └── spec_helper.rb
└── views # template files that render HTML

Go through these files sequentially and follow the comments:

  1. config/environment.rb
  2. models/get_tweets.rb
  3. app.rb
  4. views/tweets.erb
  5. config.ru

Run bundle install and then rackup. Then go to http://localhost:9292 to see the tweets! Play around with getting tweets for other search queries, or, tweet @flatironschool and see your tweet! If you make any changes to the code, you'll need to restart the server and rackup again.

Specs

There's one test, which should already be passing. Let's take a look at it:

it "handles GET to '/'" do 
  get '/'
  expect(last_response).to be_ok
  expect(last_response.status).to eq(200)
end

We're using the Rack::Test module in our specs to make a get request to '/'. The tests expects the status response to be ok (aka, 200). Refer back to the Status Codes lesson.

In other words, what this test is expecting is that all of our code, from start to finish (our code in our GetTweets class, our get method in app.rb, and our rendering of data in our ERB file) results in an ok (200) response from our server.

Resources

View Sinatra Twitter Todo on Learn.co and start learning to code for free.

sinatra-twitter-todo's People

Contributors

ahimmelstoss avatar annjohn avatar artross avatar changamanda avatar fislabstest avatar fs-lms-test-bot avatar irmiller22 avatar kthffmn avatar mrmitchboyer avatar sarogers avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sinatra-twitter-todo's Issues

Initial Feedback

  1. app.rb description

├── app.rb # where the routes live

app.rb is more than a routes file. And beginners have a vague idea of routes. Maybe describe it more as a Controller, or even more abstractly, as the "the main web server program". It represents the specific sinatra web application we're building.

  1. require_all gem

in environment, with require_all 'models' introduce the gem, link to it for further explanation. Remark on all the weird and different ways we've required files, the issues it has caused, and this solution.

  1. The specs don't explain the goal.

The specs are super abstract. We need exposition of the readme of what we're trying to build from an end user experience. As in, they need to have instructions to build this knowing that TDD errors won't give them clues nor will the code in the test. Grab me and let's discuss this - it's a crucial aspect to good quality labs.

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.