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.

In Jest run one specific test in a file using npm test

02/08/19  Public, Testing / TDD


  • using Jest JavaScript framework
  • have an npm script in package.json for test set to jest
  "scripts": {
    "test": "jest"
  • have a test file in the following location:

1 vote - harrylevine

Set up a Ruby project with RSpec

01/30/19  Public, Testing / TDD, Ruby General

1. First make sure you have rspec and byebug installed:

➜  byebug -v
  Running byebug 9.1.0
➜  rspec -v
RSpec 3.6
  - rspec-core 3.6.0
  - rspec-expectations 3.6.0
  - rspec-mocks 3.6.0
  - rspec-rails 3.6.1
  - rspec-supp...

1 vote - harrylevine

Can call multiple `expects` in an `it` block without stopping on failure

11/30/17  Public, Testing / TDD

By adding :aggregate_failures to the end of anit statement, you can call multiple expects in that it block, and if any of them fail, the tests keep testing.

For example, in the this spec, if expect(Post.count).to eq 4 fails, the test ...

1 vote - harrylevine

Checking for rubocop offenses in a given file

11/07/17  Public, Testing / TDD

You can check what is/is not passing rubocop for a given file by calling:

rubocop app/whatever/whatever/my_file.rb

You can get even more output by passing it the -D flag, which adds the actual name of the cop.


1 vote - harrylevine

Disabling and re-enabling a rubocop rule for a specific set of code

11/07/17  Public, Testing / TDD

For example, if this rule is in your .rubocop.yml file:

  Description: Don't use self where it's not needed.
  StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-self-unless-required
  Enabled: true

1 vote - harrylevine