Complete the code to define a lazy variable using let.
let(:user) { [1] }before(:each) inside let block.describe or it inside let.The let block defines a lazy variable. Here, User.new creates a new user object when user is called.
Complete the code to run setup code before each test.
before(:each) do
[1]
endlet(:user) inside before.describe or it inside before.The before(:each) block runs before every test. Assigning @user = User.new sets up a user instance for tests.
Fix the error in the before hook to properly initialize @count.
before(:each) do
@count = [1]
endcount + 1 without defining count.let(:count) inside before.Inside before, you assign @count = 0 to initialize the variable before each test.
Fill both blanks to create a let variable and use it in a before hook.
let(:number) { [1] }
before(:each) do
@result = number [2] 5
endThe let defines number as 10. The before hook adds 5 to number and stores in @result.
Fill all three blanks to define a let variable, a before hook, and a test using them.
let(:text) { [1] }
before(:each) do
@shouted = text.[2]
end
it 'shouts the text' do
expect(@shouted).to eq([3])
enddowncase instead of upcase.The let defines text as "hello". The before hook calls upcase on it. The test expects "HELLO".