rlmoser99 / ruby_rspec_TOP

A tutorial that I developed for students at The Odin Project to learn RSpec.

Home Page:https://github.com/TheOdinProject/ruby_testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

02_array_spec.rb

andrewjh271 opened this issue · comments

For this context, I wasn't sure what was being asked of me, since the test already passes. I also wasn't sure what the context description meant.

context 'when using an implicit subject, the third element' do
    # remove the 'x' before running this test
    xit 'should equal 21' do
      # update the implicit subject to make this test pass
      subject << 13 # REMOVE
      subject << 7 # REMOVE
      subject << 21 # REMOVE
      expect(subject[2]).to eq(21)
    end
  end

I did this to make the test pass a different way, since those 3 lines have # REMOVE next to them, but I'm not sure if that's what you intended.

it 'should equal 21' do
      # update the implicit subject to make this test past
      subject[2] = 21
      expect(subject[2]).to eq(21)
end

I need to remove the # REMOVE. When I first wrote out these files, I used this notation to remind myself remove those lines after I created the answer files. I didn't want to create the answer files too soon and then have 3+ files to update as I change or re-arrange concepts.

In addition, I will update the context to clarify. Thanks for this input!

Oh ok, cool. That makes sense. Happy to contribute!

I probably should have fixed this using a branch to merge, so that I could link this issue to a pull request. Now that you are contributing to this project, I should probably not work on master branch anyway!

The point of this exercise was to update the subject inside the test (it doesn't matter how you do it). So I also added that the array should be empty at the beginning of the test.

  context 'when updating an implicit subject' do
    # remove the 'x' before running this test
    xit 'should be empty then have length of 1' do
      expect(subject).to be_empty
      # update the implicit subject to make this test pass
      expect(subject.length).to eq(1)
    end
  end

Since I don't have a pull request to link, here is the link the commit if you want to see the diff:
5515228

Let me know if this clarifies the problem & also resolves this issue.

Looks great! I think that's clear what the assignment is asking for now.