Question

Provide a line by line explanation of the following RSpec code:23 describe Careerdo 24- 25 26 27 28 29 30 31 32 describe career getters and setters do beforeC:each) @careers Career.newCLabel each part of your explanation according to the line(s) you are describing. Be sure to explain the code in

DETAIL, including what is being called, what is the expected response, the keywords and what they mean etc.

Your response will be graded as follows:

(1 point) Lines 23-­24

(1 point) Lines 26­-28

(1 point) Lines 29­-30

(1 point) Lines 32­-35

(1 point) Lines 36­-39

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Lines 23-­24

'describe' is a RSpec Keyword, which is used to define an group of example. Its is a collection of different tests. It takes a class name and/or string argument. do and end are the keywords which are used to select the action. Here Career is a class name and with the 'career getters and setters' method which will used to set career and job related information.

'do' and 'end' are the keywords followed by the arguments/class name. do will act like the starting of the describe and end will be the stop of the same.

describe uses block with arguments.

Lines 26­-28

'it' is also a keyword in RSpec, it is used to define the example or test case.

Here we want to set name ( name as a test case), line 26 is the initialisation of it block with the argument 'should set job' mean we have to assign some values to parameter 'job' in the block of 'it' which is on line 27. On line 27, 'expect' keyword is used to as a verification step or what we are expecting to assign. i.e. here in name of career getter should be 'John'. Here 'expect' keyword is followed by destination and 'to' keyword and 'eq' keyword. That is expect(destination) to eq (means value should be 'John'). So it will set name= John.
As every expect is terminated with the 'end' keyword.

Lines 29­-30

Same as above, just the difference is above it was Name to set here 'Job' is the argument to be set.
so this block will set Job=firefighter.

Lines 32­-35

RSpec works like general English. Here in this block we want to update the name, hence we have passed the argument to 'it' as 'should be able to change name'. So we will implicitely assigning @careers.name='Jonathan' and same will be accomplished by the 'expect'-as 'expect' is used as verification step here.

'end' is used to complete the block.

Lines 36­-39

Same like line 32--35, here we are updating the job parameter. We are assigning @careers.job=
Parametic' and verifying with the 'expect' block.

'end' is used to complete the block.

Add a comment
Know the answer?
Add Answer to:
Provide a line by line explanation of the following RSpec code:Label each part of your explanation...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using MATLAB Please Write a MATLAB function that takes coord natos of four points as inputs and returns the coord nates of ntersection of the line passing through ooints 1 and 2 and the line passing t...

    Using MATLAB Please Write a MATLAB function that takes coord natos of four points as inputs and returns the coord nates of ntersection of the line passing through ooints 1 and 2 and the line passing through points 3 and 4. For function name and inout arguments, use: P line_int(P1, P2, P3, P4) The function should be able to handle row or column vector entries. This function will use a sub-function called line_eq. This sub-function takes coordinates of two points...

  • C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the r...

    C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the required information. Your function should return the number of student entries read from the file. Empty lines do not count as entries, and should be ignored. If the input file cannot be opened, return -1 and do not print anything.     Your function should be named...

  • in java PART ONE ================================================== Write a program that will read employee earnings data from an...

    in java PART ONE ================================================== Write a program that will read employee earnings data from an external file and then sort and display that data. Copy and paste the input file data below into an external file, which your program will then read. You will want to use parallel arrays for this program. Modify the select sort algorithm to receive both arrays as parameters as well as the size of the arrays. Use the algorithm to sort your earnings array....

  • An agricultural researcher wanted to investigate the effectiveness of a treatment for tapeworm in the stomach of lambs...

    An agricultural researcher wanted to investigate the effectiveness of a treatment for tapeworm in the stomach of lambs. 48 tapeworm-infected lambs of approximately the same age and health were randomly divided into two groups. One group of 24 lambs was treated by being dosed with the drug and the remaining group of 24 lambs was left untreated. After a six month period the lambs were killed and the number of tapeworms in each lamb's stomach was recorded. The data are...

  • Please solve in python and provide comments explaining your codes. Your output must be the same...

    Please solve in python and provide comments explaining your codes. Your output must be the same as the example and result given below in the images. This task is to write a very basic text editor. It allows you to add, delete and modify lines of text.  Use a list of strings to store the lines, with each list element being one line. The elements of the list are modified according the commands given by the user. The editor repeatedly: 1.    displays...

  • Please include excel formulas/steps/directions for each part and where I should input the formulas. Don't just...

    Please include excel formulas/steps/directions for each part and where I should input the formulas. Don't just give the answers. It'd probably be best if you post your own spreadsheet for reference as well, with formulas included. I need a well designed spreadsheet. Thank you! 2 3 You borrow money on a self liquidating installent loan (equal payments at the end of each year, each payment is part principal part interest) Loan $137,000 Interest Rate 10.40% Life (years) Date of Loan...

  • Please answer this like right now West Battery Corp. has recently been receiving complaints from retailers...

    Please answer this like right now West Battery Corp. has recently been receiving complaints from retailers that its 9-volt batteries are not lasting as long as other name brands. James West, head of the TQM program at West's Austin plant, believes there is no problem because his batteries have had an average life of 40 hours, about 10% longer than competitors' models. To raise the lifetime above this level would require a new level of technology not available to West....

  • Please provide your response for the following questions. What types of plans and decisions most likely...

    Please provide your response for the following questions. What types of plans and decisions most likely require board of director involvement, and why? What types of decisions and plans are not appropriate for board involvement, and why?     Tell about a time when an organization was not able to fully achieve all of its goals simultaneously. Why did this occur? Is complete realization of all goals impossible for an organization? Why or why not?     Describe the process that an...

  • PART TWO Write a program which will populate an integer ArrayList with user input, and then...

    PART TWO Write a program which will populate an integer ArrayList with user input, and then provide a menu of various operations to perform on that ArrayList. The first step is to have the user push a bunch of integers into a ArrayList. The second step is to perform various operations on that ArrayList. Your input must be in the format below. The user can enter either a positive integer or -99 to quit. The menu to present is: Sum...

  • Copy the entire program 9A and paste it into this one. Be sure to change the...

    Copy the entire program 9A and paste it into this one. Be sure to change the class name to 9B. Use descriptive variable names in camel-case with the first letter in lowercase. In the Student class, change the public attributes firstName and lastName to private ones. In the Student class, add getters and setters called getFirstName, getLastName, setFirstName, setLastName for the two attributes. In the Student class, add a constructor for the Student class that accepts two Strings, one parameter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT