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...
...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...
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...
...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...
...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.
...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...
...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.
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.
...ways to do this: The preferred way is to use the ExternalInterface class to call Javascript functions from ActionScript, and to bind ActionScript functions to the Flash movie's DOM...
...element so they can be called from Javascript. The deprecated way is to use the global fscommand function to call a Javascript function with a fixed name from Javascript. In...
...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...
...They don't hide methods from inheriting classes.) private Private methods can only be called with implicit receiver. As soon as you specify a receiver, let it only be self...
...your call will be rejected. class A def implicit private_method end def explicit self.private_method end private def private_method "Private called" end end A.new.implicit # => "Private called" A.new.explicit # => NoMethodError...
...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...
}) JS expect(returned_latitude).to eq latitude end Note that we no longer call evaluate_async_script (or evaluate_script, if you're running synchronously) on page, but the...
...map element itself. Inside of the Heredoc we can then refer to map by calling this. By doing this, we no longer reimplement any logic in our test, gain control...
...you're debugging and you lost track of where you are in the current call stack...
...Interactive Git status. Run tig status. Stage/unstage with U, navigate with ENTER/Q. Stash management. Call tig stash, browse the stashes, apply with a, pop with p, drop with !. See Git...
...should do it this way (instead of doing regular monkey patches) you can still call super to get the original implementation of the method the prepended class will appear in...
...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...
end end end You can find a full list of available dynamic calls below: Dynamic call Equivalent Power.current.send(:notes) Power.current.notes Power.current.include?(:notes) Power.current.notes? Power.current.include!(:notes) Power.current.notes! Power.current.include?(:notes...
...as a placeholder for the remote Rails root directory. # * Append ` || test $? =1;` to grep calls in order to avoid exit code 1 (= "nothing found") # * To be able to process the...
...require custom Capistrano task files: # Capfile Dir.glob('lib/capistrano/tasks/*.rake').each do |r| # `import r` calls Rake.application.add_import(r), which imports the file only # *after* this file has been processed, so...
...notification each third retry or use less retries. Also, if you make thousands of calls to an API it may not be wise to send emails if the API is...
...s own ancestors. As a conclusion of (2), a delegated listener will always be called after listeners registered directly on a descendant, regardless of the order in which the listeners...
Register a standard event listener to your target. Before you run your callback, check that the actual element (event.target) matches the desired selector, or has the desired selector...
For this purpose the gem allows you to record execution time when you call rspec with --format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime_rspec.log. As the documentation on this states you...
...second argument to limit the number of applied splits Last Raised Exception In The Call Stack The $! global variable contains the last exception that was raised in the current call...
it 'sends a xlsx export' do # create your exportable data create(:resource, ...) # call your export endpoint get '/backend/resources.xlsx' # check that all expectations are fulfilled expect(response).to be...