Skip to content

stephan-buckmaster/rails-test

Repository files navigation

README

This is an app to test basic proficiency in Ruby on Rails.

The test consists in correcting the app code in order to get the tests to pass, with zero failures and errors.

All required dependencies are documented in the Gemfile. As it says, this is for Rails version 7.2 which requires Ruby 3.1 at minimum. But the functionality covered by the test is very basic, the versions hardly come in.

Tip: All fixes are one-liners. You might find that one failure is much more difficult to fix than all the others.

Sample run-through

$ bundle install
$ bundle exec rake db:test:prepare
$ bundle exec rake 

Test output, before fixing tests

$ bundle exec rake 

Running 23 tests in a single process (parallelization threshold is 50) Run options: --seed 60835

Running:

F

Failure: OrderTest#test_calculates_total_2_books [test/models/order_test.rb:30]: Expected: 3.23 Actual: 0.423e1

bin/rails test test/models/order_test.rb:26

..F

Failure: OrderTest#test_calculates_total_1_book [test/models/order_test.rb:23]: Expected: 1.23 Actual: 0.223e1

bin/rails test test/models/order_test.rb:20

F

Failure: OrderTest#test_calculates_total_0 [test/models/order_test.rb:17]: Expected: 0 Actual: 1

bin/rails test test/models/order_test.rb:15

..F

Failure: HomeControllerTest#test_shows_orders [test/controllers/home_controller_test.rb:7]: Expected at least 1 element matching "a[href="/"]", found 0. Expected 0 to be >= 1.

bin/rails test test/controllers/home_controller_test.rb:4

......F

Failure: OrdersControllerTest#test_should_create_order_with_books [test/controllers/orders_controller_test.rb:31]: "Order.count" didn't change by 1, but by 0. Expected: 3 Actual: 2

bin/rails test test/controllers/orders_controller_test.rb:30

F

Failure: BooksControllerTest#test_should_get_index [test/controllers/books_controller_test.rb:10]: Expected: "Book 1" Actual: "book.name". Expected 0 to be >= 1.

bin/rails test test/controllers/books_controller_test.rb:8

..E

Error: BooksControllerTest#test_should_get_edit: ActionView::Template::Error: undefined method rendertemplating' for an instance of #<Class:0x00007f69c348ec50> app/views/books/edit.html.erb:3 test/controllers/books_controller_test.rb:36:in block in class:BooksControllerTest'

bin/rails test test/controllers/books_controller_test.rb:35

.F

Failure: BooksControllerTest#test_should_reject_book_with_negative_price [test/controllers/books_controller_test.rb:48]: Expected response to be a <422: Unprocessable Content>, but was a <302: Found> redirect to http://www.example.com/books/1 Response body: . Expected: 422 Actual: 302

bin/rails test test/controllers/books_controller_test.rb:46

E

Error: BooksControllerTest#test_should_create_book: NoMethodError: undefined method sve' for an instance of Book app/controllers/books_controller.rb:27:in block in create' app/controllers/books_controller.rb:26:in create' test/controllers/books_controller_test.rb:24:in block (2 levels) in class:BooksControllerTest' test/controllers/books_controller_test.rb:23:in `block in class:BooksControllerTest'

bin/rails test test/controllers/books_controller_test.rb:22

.

Finished in 0.449682s, 51.1473 runs/s, 95.6231 assertions/s. 23 runs, 43 assertions, 7 failures, 2 errors, 0 skips

Test output, after fixing tests

$ bundle exec rake 
Running 23 tests in a single process (parallelization threshold is 50)
Run options: --seed 59244

# Running:

.......................

Finished in 0.425100s, 54.1049 runs/s, 138.7908 assertions/s.
23 runs, 59 assertions, 0 failures, 0 errors, 0 skips

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published