Rspec: How to verify if a record has been deleted?
I have created a simple Rspec test to verfiy if a model created has been deleted. However, the test fails because the model still exists. Can anyone provide any assistance on how to determine if the...
View ArticleRuby hash pattern matching - optional pattern
With Ruby 3 hash pattern matching, is it possible to specify that the rest contains only allowed keys?So far I only came up with this:opts = { value: 5, limit: 10 } # valid# opts = { value: 5 } #...
View ArticleHow Puma allows IO waiting to be done in parallel to improve MRI's throughput?
From Puma's README:On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like...
View ArticleWhat are the differences between `bundle exec rake release` and `gem push`?
I'd like to know the difference between using bundle exec rake release to publish a gem. Is there any benefit over gem push in terms of rake catching a runtime error? Specifically I ask this in context...
View ArticleTesting custom exception with a single expect?
I have a function that I want to test raises an exception on an input, but that exception also carries some more information than just a plain message, and I want to test that too. So I did something...
View ArticleIs there a way to use Rspec let! with a scope so it can be used across...
I'm trying to figure out a good way to handle setting rspec memoized variables that will be cleaned up after a set of tests, but not after an individual test.I'd like it to achieve something similar to...
View ArticleCallback for Active Storage file upload
Is there a callback for active storage files on a modelafter_update or after_save is getting called when a field on the model is changed. However when you update (or rather upload a new file) no...
View ArticleHow can I validate my own route before redirect?
Hay! The system I'm working on has the following feature: after your disconnect, the next time you log in, you'll be redirected to the last page you've been. That info is stored in the DB, as a string...
View Articleunexpected behavior of delete_if and reject! methods
I have an array of elements in Rubynums = [1,1,1,2,2,3]The task is to remove some duplicates in-place if element occures in array more than twice.I wrote following code:nums = [1,1,1,2,2,3]def...
View ArticleError during Ruby 2.7.3 installation using RVM
I have tried installing ruby 2.7.3, I got the below errorError running '__rvm_make -j8',please read /Users/sravangunapati/.rvm/log/1706592953_ruby-3.0.0/make.logThere has been an error while running...
View ArticleWhere is the email for user
rails generate scaffold User email:stringModel is empty.class User < ApplicationRecordendController def create @user = User.new(user_params) ... endTable: create_table :users do |t| t.string :email...
View ArticleHow modified brew Formulae for Libvmaf in Mac os BigSur
I have an error installing the libvmaf dependency in mac OS BigSur.Here is the error when installing with:brew install libvmafError : unknown type name 'size_t'This error occurs when the formulae...
View ArticleHow to prepend Sidekiq job to beginning of a queue?
How to prepend Sidekiq job to beginning of a queue?I know that most obvious thing you might want to say right now is "just add a separate high-prio queue, with a separate worker!", but I'm constrained...
View Articletroubles with RVM and OpenSSL
Trying to set up a new macbook for a colleague. Not going well. First I install OpenSSL:Heathers-MacBook-Pro:~ heather$ rvm pkg install opensslFetching openssl-1.0.1c.tar.gz to...
View ArticleRuby Error - Expected Array or String, Got Hash
EDIT - I've re-added the commented out sections to include the other methods I've attempted to solve this to hopefully provide more insight into my process. As of now this program is working, but it...
View ArticleRuby - Google sheets file will not open after saving locally
I'm having an issue with opening an exported file from google sheets. My program consolidates QTY and SKU for selected items to a google sheets file from a local spreadsheet and then saves the sheets...
View ArticleRuby - Cannot save formatted spreadsheet locally
I'm having an issue when trying to save a formatted spreadsheet locally to my computer.The purpose of the program is to consolidate units to reorder based on a master spreadsheet and save it locally....
View ArticleHow to alias a class method within a module?
I am using Ruby v1.9.2 and the Ruby on Rails v3.2.2 gem. I had the following modulemodule MyModule extend ActiveSupport::Concern included do def self.my_method(arg1, arg2) ... end endendand I wanted to...
View ArticleHow to change which version of Ruby I am using
I need to run 2.5.3. I use brew to manage my ruby installation (as I couldn't get rvm to work on my machine). When I run$ruby -vI getruby 2.3.7p456 (2018-03-28 revision 63024)...
View ArticleRuby on Rails, How to make a controller render different page without redirect?
Let's say we have the following pagesclip/show/111image/show/222sound/show/333where 111,222 and 333 are the IDs for different contributionsI developed a new controller called "show" that will detect ID...
View Article