Testing / TDD
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
Set up a Ruby project with RSpec
11/12/17 Public, Ruby General, Testing / TDD
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-support ...
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.
rub...
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:
Style/RedundantSelf:
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
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