Testing / TDD

Don’t we have some people for that? I’m “the people”?? Dang it!
Testing is where the rubber meets the road. If your app works today, but not tomorrow, what’s the point? We all test in our own ways, but the industry has standards and expectations for this. And most employers have their own set of expectations around testing, which may pragmatically exceed standards. Testing can involve learning an entire body of new languages and methods. Testing should be learned early, and practiced often. Testing can be tricky, and the syntax is in flux, as this area is currently like the wild west of development. As you begin to figure out what is and is not currently working for you, you will want to document and remember it. This stack is dedicated to anything and everything around testing.

Shortened, one line version of a spec

04/25/17  Public, Testing / TDD

Here is the full syntax version of a spec:

it "returns no results" do
  expect(results).to be_nil
end

Here is the same spec, in the shortened, one line version:

it { expect(results).to be_nil }

1 vote - harrylevine

Controller spec when controller method is being hit through AJAX

07/29/16  Public, Testing / TDD

I had a controller method that is being called via AJAX. This method does not specifically render any pages (i.e. update.html.erb). The controller spec was throwing a missing template error

Failure/Error: put :update,
ActionView::Miss...

1 vote - harrylevine

Using a backtrace with byebug for debugging

06/02/16  Public, Testing / TDD

When you get the byebug prompt, enter bt:

(byebug) bt

1 vote - harrylevine

Rescue in failing controller spec

04/01/16  Public, Testing / TDD

I was getting a failing controller spec, and the failure message was not helpful at all, nor were any of the debugging approaches. A coworker recommended that I check the controller method itself to see if there is a rescue block in there. Low...

1 vote - harrylevine

Test one specific file or spec with spring, without running guard

03/21/16  Public, Command Line, Shortcuts, Testing / TDD

This syntax will allow you to take advantage of the speed that spring offers, when running just one spec file, or just one spec within the file (or context), without running [guard](https://github.com/guard/g...

1 vote - harrylevine