8.5 Playtime 8.3 Iteration C3: Use a Helper to Format the Price
Demonstrate use of assert_select to test views.
Verify that the tests still pass.
rake test
(in /home/rubys/svn/rails4/Book/util/work-193/depot)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.....
Finished in 0.117701 seconds.
5 tests, 23 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 48351
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
........
Finished in 0.466016 seconds.
8 tests, 11 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 43110
Add tests for layout, product display, and formatting, using counts, string comparisons, and regular expressions.
edit test/functional/store_controller_test.rb
require 'test_helper'
class StoreControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
assert_select '#columns #side a', :minimum => 4
assert_select '#main .entry', 3
assert_select 'h3', 'Programming Ruby 1.9'
assert_select '.price', /\$[,\d]+\.\d\d/
end
end
Show that the tests pass.
rake test:functionals
(in /home/rubys/svn/rails4/Book/util/work-193/depot)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.3-r28190%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
........
Finished in 0.583540 seconds.
8 tests, 15 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 51960
pub depot_e
8.5 Playtime 8.3 Iteration C3: Use a Helper to Format the Price