Commerce

Testing In Ruby (Rspec, Minitest, Etc.) MCQs

Practice Testing In Ruby (Rspec, Minitest, Etc.) MCQs for competitive exams.

Testing In Ruby (Rspec, Minitest, Etc.) MCQs

Practice questions from this topic.

What is the purpose of the assert_match method in MiniTest?

  1. A. Asserts that a condition is true
  2. B. Asserts that a string matches a regular expression
  3. C. Asserts that a condition is false
  4. D. None of the above
Report Error

Which keyword is commonly used in Cucumber feature files to define a background?

  1. A. Scenario:
  2. B. Given:
  3. C. Background:
  4. D. When:
Report Error

What is the purpose of the should syntax in RSpec?

  1. A. Provides a way to define before and after hooks
  2. B. Provides a way to define shared examples
  3. C. Provides a way to define custom matchers
  4. D. Provides a more readable way to express expectations
Report Error

What is the purpose of the assert_empty method in MiniTest?

  1. A. Asserts that an object is empty
  2. B. Asserts that two objects are equal
  3. C. Asserts that a condition is true
  4. D. Asserts that a condition is false
Report Error

What is the purpose of a background section in a Cucumber feature file?

  1. A. Defines steps that should be run after each scenario
  2. B. Defines steps that are shared across multiple scenarios
  3. C. Defines steps that should be run before all scenarios
  4. D. Defines steps that should be run before each scenario
Report Error

Which command is commonly used to generate a new RSpec test file?

  1. A. rails generate rspec:feature FeatureName
  2. B. rails generate rspec:controller ControllerName
  3. C. rails generate rspec:model ModelName --spec
  4. D. rails generate rspec:model ModelName
Report Error

What is the purpose of a setup block in MiniTest?

  1. A. Executes code after each test case
  2. B. Executes code before all test cases
  3. C. Executes code after all test cases
  4. D. Executes code before each test case
Report Error

What is the purpose of a subject block in RSpec?

  1. A. Records the interactions between objects
  2. B. Overrides the behavior of a method to return a specific value
  3. C. Provides a target object for the example group
  4. D. Defines a memoized helper method that can be used in examples
Report Error

What is the purpose of a cucumber tag in Cucumber testing?

  1. A. Describes the behavior of an application in plain text
  2. B. Labels scenarios with metadata
  3. C. Overrides the behavior of a method to return a specific value
  4. D. None of the above
Report Error

Which method is commonly used to assert that a certain exception is raised in RSpec?

  1. A. assert_raises(ExceptionClass) { ... }
  2. B. expect { ... }.to throw_symbol(:exception_symbol)
  3. C. expect { ... }.to raise_error(ExceptionClass)
  4. D. assert_throw(:exception_symbol) { ... }
Report Error

What is the purpose of a scenario outline in Cucumber testing?

  1. A. Checks if a value meets certain conditions
  2. B. Provides a placeholder for a method that will be defined later
  3. C. Describes the behavior of an application in plain text
  4. D. Allows the same scenario to be run with different combinations of data
Report Error

Which command is commonly used to run MiniTest tests from the command line?

  1. A. ruby test.rb
  2. B. rake test
  3. C. ruby minitest.rb
  4. D. minitest run
Report Error