ruby

test_helper don't load when I make a test

送分小仙女□ 提交于 2021-02-08 01:54:41
问题 I need make a test of a model, but when I do this: ruby test/unit/user_test.rb I have also tried with other methods: ruby -I test test/unit/user_test.rb rake test:units TEST=test/unit/user_test.rb But anyone make the test and said: test/unit/user_test.rb:1:in `require': no such file to load -- test_helper (LoadError) Or like. This is part of the code (only the beginning): require 'test_helper' class UserTest < Test::Unit::TestCase self.use_instantiated_fixtures = true fixtures :users def test

test_helper don't load when I make a test

霸气de小男生 提交于 2021-02-08 01:53:14
问题 I need make a test of a model, but when I do this: ruby test/unit/user_test.rb I have also tried with other methods: ruby -I test test/unit/user_test.rb rake test:units TEST=test/unit/user_test.rb But anyone make the test and said: test/unit/user_test.rb:1:in `require': no such file to load -- test_helper (LoadError) Or like. This is part of the code (only the beginning): require 'test_helper' class UserTest < Test::Unit::TestCase self.use_instantiated_fixtures = true fixtures :users def test

Ruby forcing garbage collection not working as expected

空扰寡人 提交于 2021-02-08 01:42:09
问题 In the following code: class ExampleClass def initialize ObjectSpace.define_finalizer(self, proc{puts 'dead'}) end end ex = ExampleClass.new ex = nil GC.start while true # the while loop is to prevent the program from terminate # if the program does terminate, the finalizer gets called in the end like expected end The finalizer here is never called and there is no output. I would have expected the garbage collector to collect ex since it has been dereferenced. Why is GC.start not forcing ex

Why rvm needs login shell?

余生长醉 提交于 2021-02-07 22:46:17
问题 As far as I know, rvm is a set of bash scripts. Why it need login shells? Which property which only exists in login shells is necessary for rvm? Related post: rvm installation not working: “RVM is not a function” 回答1: Your RVM config line ( [[ -s "$HOME/.rvm ... ) likely located is in .profile , which is only read when your bash is on login-shell mode. There are other config files that are read in other modes as well, like .bashrc when the shell is interactive, but non-login or file defined

Using bcrypt-ruby to validate hashed passwords using version $2y

北城余情 提交于 2021-02-07 20:55:20
问题 We're in a bit of a bind where we need to use Ruby to auth users against an existing db of users. The user's passwords were all generated using password_compat PHP library. All the hashed passwords start with $2y. I've been using bcrypt-ruby to try and authenticate the users and I haven't found any success. #This user's password is "password" irb(main):041:0> g = BCrypt::Password.new("$2y$10$jD.PlMQwFSYSdu4imy8oCOdqKFq/FDlW./x9cMxoUmcLgdvKCDNd6") => "$2y$10$jD.PlMQwFSYSdu4imy8oCOdqKFq/FDlW.

Using bcrypt-ruby to validate hashed passwords using version $2y

半世苍凉 提交于 2021-02-07 20:47:24
问题 We're in a bit of a bind where we need to use Ruby to auth users against an existing db of users. The user's passwords were all generated using password_compat PHP library. All the hashed passwords start with $2y. I've been using bcrypt-ruby to try and authenticate the users and I haven't found any success. #This user's password is "password" irb(main):041:0> g = BCrypt::Password.new("$2y$10$jD.PlMQwFSYSdu4imy8oCOdqKFq/FDlW./x9cMxoUmcLgdvKCDNd6") => "$2y$10$jD.PlMQwFSYSdu4imy8oCOdqKFq/FDlW.

Ruby 2.4 Enumerable#sum breaks in Rails 5.1

余生颓废 提交于 2021-02-07 20:11:36
问题 In Rails 5.1.4 using Ruby 2.3.5, I get this behavior: >> [].sum #> nil I'd like to upgrade to Ruby 2.4, where Enumerable#sum is implemented natively. Testing this in IRB using Ruby 2.4.2, I get this result: >> [].sum #> 0 That's OK, and I can handle the different result. But going back to the Rails console in Rails 5.1.4 using Ruby 2.4.2, I get this: >> [].sum #> NoMethodError: undefined method `each' for nil:NilClass However, in a newly created Rails 5.1.4 project, I don't get this error.

How to Specify One Worker on a Queue for Delayed Jobs

对着背影说爱祢 提交于 2021-02-07 19:29:26
问题 How can I specify one worker for a specific queue when using delayed jobs? I know I can run this command: # Use the --pool option to specify a worker pool. You can use this option # multiple times to start different numbers of workers for different queues. # The following command will start 1 worker for the tracking queue, # 2 workers for the mailers and tasks queues, and 2 workers for any jobs: RAILS_ENV=production script/delayed_job --pool=tracking --pool=mailers,tasks:2 --pool=*:2 start

Action Cable issue: messages occasionally not delivering or occasionally sent to the wrong channel

≡放荡痞女 提交于 2021-02-07 19:05:41
问题 I'm using Action Cable for a chat application with many different channels. Everything is set up with Redis and Postgresql (to save messages) on Heroku and 95% of the time works great in development and production. Occasionally though, messages sent do not show up. The message is sent, it is saved in the database, but then it never shows up on the front end unless I refresh. Or, the message shows up in another channel for which it is not directed. Again, everything is properly saved in the

Action Cable issue: messages occasionally not delivering or occasionally sent to the wrong channel

£可爱£侵袭症+ 提交于 2021-02-07 19:01:22
问题 I'm using Action Cable for a chat application with many different channels. Everything is set up with Redis and Postgresql (to save messages) on Heroku and 95% of the time works great in development and production. Occasionally though, messages sent do not show up. The message is sent, it is saved in the database, but then it never shows up on the front end unless I refresh. Or, the message shows up in another channel for which it is not directed. Again, everything is properly saved in the