19-01-2022

433 words 3 minutes

Fantastic day yesterday, super productive!

  • remember to use RSpec subject ( or not - use let instead! )
  • lets find out what that does?

RSpec subject

RSpec subject, or let?

subject refers to the testing object - usually the class between 'describe / context' and 'do' at the beginning of the file.

subject is clearer in some idiomatic spaces

generally, use let to be more specific - they are lazy instantiation - (memoized) variables

Ruby Memoization

Ruby Memoization

used to cache time-consuming work - if you need to re-use an object or message result, memoize it, and reuse the memoized object (I think this stores is as a symbol?)

Are Ruby Method Names Stored as Symbols?

Ruby's methods are symbols

Yes apparently Likely for efficiency navigating the AST

Symbols return to the early language of Smalltalk and Scheme! :smiley:

A Symbol:
1. are internal representations of a string.
2. They additionally contract that all symbols with the same nam are the same object.
3. Ruby symbols are stored as internally tagged integers, with an internal table to map the magic numbers to identifier names.

Accurate Specs

Better Specs

When describing tests in RSpec, use . (or ::) for a class method's name, and # when referring to an instance method's name.

BAD
describe 'the authenticate method for User' do
describe 'if the user is an admin' do
GOOD
describe '.authenticate' do
describe '#admin?' do

GOALSETTING

  • quantifiable, assessable goals

  • small steps

  • Hoom'n suggests the SMART approach?

    1. S - Specific
    2. M - Measurable
    3. A - Attainable
    4. R - Relevant
    5. T - Time-Based
  • AP Framework

    1. I want to use the let keyword more in RSpec
    2. make it run, read a blog post
    3. the let keyword, and explain to group tomorrow
  • Tomorrows goal - give better feedback?

Test Driven Development

What is TDD?

  • Test Driven Development

  • Get User Specs

  • Create a psuedocode / psuedo structure Algorithmic thinking

  • Design the tests around the psuedo structure

Why
  • Gives direct focus to build efficient code
  • Efficient tests creates an efficient code

Feature Testing - does a class work?

Unit Testing - does a single function work as expected?

Use IRB to check stuff - kind of plan unit tests

  1. Red - Design a test that should, initially, fail

  2. Green - The code exists, and the test passes

  3. Refactor - improving the code without changing behaviour

Ruby - Requiring multiple files

Ruby Conventions structure

Write structuring and pathing convetions for the languages I know? :smiley:

In Ruby TDD, we need to create a

Hoom'n - .class, .methods