swt2-intro-exercise / rails-exercise-18-lassesteffen

rails-exercise-18-lassesteffen created by GitHub Classroom
MIT License
0 stars 0 forks source link

Author page should display author details #5

Closed swt2public closed 5 years ago

swt2public commented 5 years ago

Scenario

Given an author named 'Alan Turing' When a user visits the author's page Then no error should occour

Hints

There should be a page that shows all of an author's details: the show page / details page.

Did you know? You can use FactoryBot.create :author to create and save a valid author object in your tests. If you un-comment the code in spec/factories/authors.rb, the author will be initialized with meaningful values.

To visit the details page of an author in a test, you can use visit author_path(@alan).

You should create a separate file for feature tests for the author details page, make sure it ends with _spec.rb, so that RSpec recognizes it as a test and runs it. You can test for the existence of text on a page using the have_text matcher: expect(page).to have_text(...).

In order to implement the required behavior a show action on the AuthorsController as well as a new view (app/views/authors/show.html.erb) will be needed. The relevant section of the Ruby on Rails guide for this is here.

Error

Got ActionController::UnknownFormat: AuthorsController#show is missing a template for this request format and variant.

request.formats: ["text/html"] request.variant: []

NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.

Estimated progress: 20% complete

swt2public commented 5 years ago

Sorry, it's not working for me yet:

Scenario

Given an author named 'Alan Turing' When a user visits the author's page Then no error should occour

Error

Got ActionController::UnknownFormat: AuthorsController#show is missing a template for this request format and variant.

request.formats: ["text/html"] request.variant: []

NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.

If you have problems solving this task, please don't hesitate to contact the teaching team!