So, I am learning ruby outside of my job, which is not programming
related. Eventually want to move into programming though for a job,
because I do enjoy this stuff.
However, I am currently a little confused on the current puzzle I’m
working on and want to make sure I’m going down the right path.
Basically, I will give a snippet of the rspec puzzle that I’m working on
right now (obivously there is more, but doing this to save space and
because I feel if I can put down the correct path, I can try to figure
the rest out):
describe Name do
@name = Name.new
describe ‘title’ do
it ‘should capitalize’ do
@name.title = “joe”
@name.title.should == “Joe”
it 'should capitalize every word' do @name.title = "stuart smith" @name.title.should == "Stuart Smith" end
My solution so far has been this:
I have always been used to setting up classes like this. Where I first
make an initialize method and then “accessor” methods (I think that is
the name for these. The methods that actually do stuff for classes).
Am I on the correct path here, or am I setting up this class all wrong
for these tests? The above passes the first test. I feel I may need to
do a loop for the second test.
Can someone let me know if I am doing this all wrong? Or give me some
guidance on how to write good code for this situation?
Thanks for any help.