Skip to content

Commit

Permalink
added erb
Browse files Browse the repository at this point in the history
  • Loading branch information
victhevenot committed Nov 18, 2015
1 parent 9166f5c commit c7e6992
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 47 deletions.
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,7 @@ You can run `learn` to get the tests passing and see errors.

1. Create a template called `hello.erb` in `views` that contains an `h1` tag with the content `Hello World`. This should get rendered via a GET `/hello` route by your `App` controller in `app.rb`.

2. Create another template called `goodbye.erb` in `views` that contains an `h1` tag with the content `Goodbye`. This should get rendered via a GET `/goodbye` route by your `App` controller in `app.rb`.
2. Create another template called `goodbye.erb` in `views`. In this view, use ERB tags to create a variable `name`. This variable should store the name `Joe`. Then, using ERB tags, say "Goodbye Joe" in an `h1` tag. This should get rendered via a GET `/goodbye` route by your `App` controller in `app.rb`.

3. Create two templates in `views` - `dogs.erb` and `cats.erb`. Both are rendered via GET `/dogs` and `/cats`, respectively. Make sure that `dogs.erb` contains the text `Dogs are Great!` and `cats.erb` contains the text `Cats are Great, Too!`

4. Create a template called `music.erb` in `views` that gets rendered via GET `/music`. It should contain an `h1` with the content `Music` and an unordered list (`ul`) of some of your favorite music, artists, or genres within `<li>`s. The `views/music.erb` template should contain HTML that would render something similar in structure to:

```
Music
· Future Islands - Seasons (Waiting for you)
· Chemical Brothers - Hey Boy, Hey Girl
· Neutral Milk Hotel - In an Aeroplane Over the Sea
```
3. Create a template called `date.erb` in `views` that gets rendered via GET `/today`. It should contain an `h1` with the content `Today`
Using ERB tags, and the DateTime library, display today's date in a `p` tag. The date should be formatted to look something like this `The date is Wednesday, November 18, 2015`.
1 change: 1 addition & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ class App < Sinatra::Base
erb :index
end


end
42 changes: 7 additions & 35 deletions spec/sinatra_views_lab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,24 @@
end
end

describe 'GET /dogs' do
describe 'GET /date' do
before do
get '/dogs'
get '/date'
end

it 'sends a 200 status code' do
expect(last_response.status).to eq(200)
end

it 'renders a template called "dogs.erb" ' do
expect(last_response.body).to eq(File.read("views/dogs.erb"))
end
end

describe 'GET /cats' do
before do
get '/cats'
end

it 'sends a 200 status code' do
expect(last_response.status).to eq(200)
end

it 'renders a template called "cats.erb" ' do
expect(last_response.body).to eq(File.read("views/cats.erb"))
end
end

describe 'GET /music' do
before do
get '/music'
end

it 'sends a 200 status code' do
expect(last_response.status).to eq(200)
end

it 'renders a template called "music.erb" ' do
expect(last_response.body).to eq(File.read("views/music.erb"))
it 'renders a template called "date.erb" ' do
expect(last_response.body).to include("The date is")
end

it 'includes a list of music' do
it 'includes the current date and time' do
if last_response.status == 200
expect(last_response.body).to include("<ul>")
expect(last_response.body).to include(Date.today.strftime("%A, %B %d, %Y"))
elsif last_response.status = 404
fail "Your application is not responding to GET /music. Did you create that route?"
fail "Your application is not responding to GET /date. Did you create that route?"
end
end
end
Expand Down
Empty file added views/date.erb
Empty file.

0 comments on commit c7e6992

Please sign in to comment.