Def velocitypoints 7 velocity points 8 end 9 end 10

This preview shows page 2 - 4 out of 6 pages.

def velocity=(points) 7 @velocity = points 8 end 9 end 10 patterson = Professor.new(3) 11 fox = Professor.new 6. (3 pts) Given the Ruby code in Listing 2, MARK ALL of the following that are FALSE A. patterson.agility returns the value of an instance variable @agility B. Lines 6-8 could be replaced by attr_accessor(:velocity) C. fox.velocity returns the value of the instance variable @velocity D. patterson.tasks returns 3. Answer B is false, since attr_accessor provides both the setter and getter, but the original code only has a setter. . .
7. (3 pts) Referring to Listing 2, which statement is FALSE about the @tasks attribute of fox ? . . .
Listing 3. 1 def test 2 x = "World" 3 yield("Hello") 4 end 5 6 x = "Ruby" 7 result = test { y => puts "#{y} #{x}" } 8. (3 pts) What is the value of result after executing line 7 of Listing 3?
9. (3 pts) Which one of the following scenarios should be accessible via HTTP GET ?
10. (3 pts) Which step is OPTIONAL when adding the new action MoviesController#bad_movies RottenPotatoes? Assume no JavaScript on the browser. to A. Ensure a route to the action exists in config/routes.rb B. Add the instance method bad_movies in movies_controller.rb C. Implement appropriate URI helper method(s) to generate necessary URIs, such as bad_movies_path D. Ensure the action has a view to render in views/movies/bad_movies.html.{haml ,erb,…}
11. (3 pts) MARK ALL statements that are TRUE for Rails RESTful routes and the resources to which they refer?
12. (3 pts) What kind(s) of tests below will ensure validation of your software: (i) C0 (statement coverage) (ii) unit testing (iii) integration testing (iv) regression testing (v) DU-coverage (all pairs of define X/use X for every variable X)

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture