Complete the code to create a test double named 'user'.
user = [1]("user")
In Ruby testing, double creates a test double object.
Complete the code to make the test double respond to 'name' with 'Alice'.
allow(user).to receive(:[1]).and_return("Alice")
The receive method specifies which message the double should respond to. Here, it is :name.
Fix the error in the code to verify the double received the 'save' message.
expect(user).to have_received(:[1])The have_received matcher checks if the double received the :save message.
Fill both blanks to create a double that responds to 'title' with 'Book' and 'author' with 'John'.
book = double("book", [1]: "Book", [2]: "John")
The double is created with attributes title and author set to given values.
Fill all three blanks to create a double 'car' with 'make' as 'Toyota', 'model' as 'Corolla', and verify it received 'start'.
car = double("car", [1]: "Toyota", [2]: "Corolla") allow(car).to receive(:start) car.start expect(car).to have_received(:[3])
The double has make and model attributes, and we verify it received the start message.