...in the debugging console: Understand your current position in the program Read local variables Call methods that are reachable from the current scope Switch into a full irb console and...
Move the program position one statement ahead Jump into the next method call Jump out of the current method call Exit debugging console and resume program
...in JavaScript (as opposed to the code we usually write in Ruby)? What are "callbacks" in JavaScript? Can you find examples for libraries that use callbacks to deal with asynchronicity...
...for libraries that use promises to deal with asynchronicity? How can you parallelize multiple calls of an async function? Exercises Judging asynchronous code Look at the following code: async function...
...What happens when an error occurs? How do we get notified? Understand that each call of a cron job will boot up your Rails application and produce 100% load on...
Sidekiq jobs should never be enqueued in an after_create or after_save callback. Can you find out why? (Hint: You can find a spoiler here)
...results prematurely. To prevent this, get into a habit of explicitely loading scopes by calling to_a when you're done filtering in the database. Learn about the N...
To prevent this, add any other expression after the scope: scope = Movie.all; nil Call #to_sql on a scope to see the query it will produce. This does not...
...It cannot ask Rails to render a view or access the database. Any HTTP calls must be mocked. Learn What do we test with Jasmine? Just as unit tests are...
...sent by the component. Use Jasmine spies to mock the window.fetch() method, inspect its calls and return a promise for a Response...
...text on https://loremipsum.de/. Write a regular expression that matches a sentence, then call it multiple times. Parse Ruby classes Write a ClassScanner class that parses a .rb file...
...parser as a single giant regex. Instead write individual patterns for methods, accessors, etc. Call each patterns until there are no more matches left. You only need to parse the...
...a strong understanding of the following language features/concepts: Writing and reading variables Defining and calling functions Control flow: if, for, switch, ... Functions and function pointers Iterating over lists
...Coming from Ruby you should notice that parentheses (()) are not optional in JavaScript function calls. Understand the difference between function pointers (foo) and function invocations (foo()). Notice the parallels between...
...have a link to the source location on GitHub. CTRL+click on a method call in RubyMine. This will open a list of possible source locations. Note Given that Ruby...
...The monkey patch should print the number of attributes that will be set, then call the original method: movie = Movie.find(1) movie.attributes = { title: 'Sunshine', year: '2007' } # Console prints "Setting...
...app that manages a list of movies and a list of actors. We will call this app "MovieDB" in subsequent cards. Skim the README file of the project if you...
expect(array.include?(5)).to eq(true) Custom matchers Write a custom matcher called have_same_attributes_as. It should compare the attributes of two ActiveRecord instances: movie1 = create...
...examples and contexts in RSpec Testing shared traits or modules without repeating yourself ActiveRecord callbacks Composing a custom matcher from existing matchers Exercise: Shared examples Make the following change to...
...code base. It should be encapsulated in single files or folders. Be easy to call: A service should always try to have a simple public interface, even if that causes...
...street # => "Foo Avenue 77" Hint You can convert any object to a string by calling #to_s on it. The matching should be case-insensitive. Also when the query string...
...random_each. The method should iterate through the array elements in random order and call the given block for each iteration. For example, the following should work...
...Write tests for both exercises. Write multiple variants, each using a different approach: Just call the real API from the example (skip this variant for the "upcoming movie" exercise)
...Write the same script in Ruby. What do you have to do to just call it from the command line without using the ruby command directly? Learn about the "shebang...
end Watch Tobias Pfeiffer's talk: Do You Need That Validation? Let Me Call You Back About It Talk with your mentor about the motivations behind the use of...
Find and talk about examples where a method should better live in a callback and vice versa Find a composition of classes and move the child classes into the...
Hint: For better testability, write a service class with the functionality and only call it in your rake task Use a namespace to rename your task to rake app...
...to perform the actual HTTP request. The class should cache its results so subsequent calls for the same URLs return the HTML size instantly, without making an additional HTTP request...
Best results in other decks
In the following example the method update_offices_people_count won't be called when office_id changes, because it gets overwritten by the second line: after_save :update_offices...
office_id_changed? || trashed_changed? end Or, move the conditions into the callback. This also allows you test the conditions more easily using a unit test:
...DEBUG or MiniMagick.debug = true (deprecated) before the processing happens. This will print all ImageMagick calls to stdout and you can get an idea where the problem is coming from.