learn-co-curriculum / playlister-sinatra

Other
0 stars 387 forks source link

One of the song_form_spec tests passes when it shouldn't. #73

Closed Sdcrouse closed 5 years ago

Sdcrouse commented 5 years ago

Hi. I found a strange bug in one of the tests that I can't explain. In spec/features/05_song_form_spec.rb there is a test that checks that the songs/new.erb form doesn't make a new Artist if that Artist exists. Somehow, that test passes even when I don't have that functionality in my form.

I poked around with binding.pry and discovered something: Artist.all had the Artist in its array when I paused between lines of code in the test. However, when I paused inside of my get 'songs/new' route, Artist.all returned a blank array; the same was true from within my songs/new.erb file.

Here is what my get 'songs/new' route looks like:

get '/songs/new' do
    @artists = Artist.all
    @genres = Genre.all
    erb :"songs/new"
  end

I don't see anything wrong with my controller. Any Artist that I create, shows up in my index and show pages, so I don't think there's anything wrong with my songs/new.erb file or any of my other routes, either.

Honestly, I have no idea why Artist.all returns a blank array when the test goes into my songs_controller.rb file. I just wanted to bring it to your attention.

Thanks for looking into this, as always.

---Sdcrouse

drakeltheryuujin commented 5 years ago

Hi there,

Thank you for your feedback! We'll take a look at this more closely and reassess the code in upcoming releases of this curriculum.

As always, thanks for contributing! 💙