...object).to receive(:foo).with('arg1', 'arg2') This expectation would be met with this call: object.foo('arg1', 'arg2') But what if the argument is expected to be an object with...

end Looking at the hidden browser Option 1: Run without headless You can call your tests with NO_HEADLESS=1 bundle exec cucumber to see the Chrome window for...

...subsequent runs: Spec: # spec/models/ / _spec.rb describe ModelName::ExampleApi do describe ' ' do it ' ', :vcr do # calls to API # expectations end end end Generated Cassette: spec/vcr/ / _ /

...in your config e.g. Rails.application.config.fetch(:foobar). You might also want to chain the method calls for nested configs e.g. Rails.application.config.fetch(:foobar).fetch(:bar). This approach allows you to have '', true...

...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...

...To fine-tune its config, you may pass an options argument to the svgo.optimize call. Usually, you want to keep the default and specify only a few settings. Do this...

...is also true on some browsers for DELETE, or in general for any AJAX call that is neither GET or POST. Some workarounds for this issue below.

Within before_* Within after_* Cancel later callbacks throw :abort throw :abort Rollback the transaction throw :abort raise ActiveRecord::Rollback When a callback raises an error Exceptions raised in callbacks...

...transaction, but only exceptions that are not ActiveRecord::Rollback will bubble up to the caller. Further reading Order of the state_machine callback chain and how to abort it.

...ActiveJob events and configure GoodJob's on_thread_error hook. This lets you manually call your exception notifier for every retry, discard, or internal GoodJob error. # config/initializers/good_job.rb # Manually notify on...

github.com

...as keyword arguments. Don't change the syntax, or you'll experience pain. Always call super inside of your overridden #initialize method. A lot of magic things happen in the...

...method stubbing and expectations. If you define initialize with no argument and don't call super, initialize might be hit with this error: ArgumentError: Wrong number of arguments (given...

makandracards.com

...the issue; git on the other hand will use the return value of that call to decide if the state is good or bad. First, start bisecting git bisect start...

Rails migrations allow you to use a change method whose calls are automatically inverted for the down path. However, if you need to some path-specific logic (like SQL UPDATE...

...run change and ignore up and down. However, Rails 4+ features a helper method called reversible: class MyMigration < ActiveRecord::Migration def change rename_table :old_table, :new_table add_column...

...cleared automatically after each test. By including the following helper hooks your tests can call jasmine.fixtures to access a container that is emptied once the test concludes: beforeAll(function() { jasmine.fixtures...

developer.mozilla.org

...you're debugging and you lost track of where you are in the current call stack...

...High-traffic forms with a high probability of value collision Wrap your entire save call in a Mutex, so the second form submission will report a violated uniqueness validations instead...

...Rails, you at least don't need to re-implement that part. Note that calling map(&:html_safe) is okay because we escaped the input, and because splitting it won...

...two line breaks will behave like , they do not actually produce elements. You can call simple_format with custom sanitization options so it only allows and...

class SecureCookies COOKIE_SEPARATOR = "\n".freeze def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) if headers['Set-Cookie'].present? && Rack::Request.new(env).ssl...

simple_format ignores Rails' XSS protection. Even when called with an unsafe string, HTML characters will not be escaped or stripped! Instead simple_format calls sanitize on each of the...

...note that when your invoice model is using a before_save or before_validation callback to sum up item totals and store that value in an attribute, you need to...

...totals which returns net, vat and gross totals in a single hash. Code that calls your invoice usually requires all these values together (e. g. to print an invoice), so...

...both limited to a set of HTTP libraries listed below (as of 2022). Direct calls to Kernel#open or OpenURI#open_uri are not mocked and will trigger real network...

makandra dev

...the event from bubbling up the DOM, so you don't also need to call event.stopPropagation(). Canceling in jQuery event.stopPropagation() effectively also cancels any event handlers attached through jQuery's...

stackoverflow.com

When you use method_missing to have an object return something on a method call, always make sure you also redefine respond_to_missing?. If you don't do it...

...own) relies on respond_to? (for a good reason). For example #respond_to? will call #respond_to_missing? if the method is not defined within the receiver. When it has...

...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...

...holds a .nvmrc file. The project's readme document offers a bash function which calls nvm use after each cd. In fact, it replaces cd in your bash.