No Keyboard Output from Guard - ruby-on-rails

When entering into debugger (byebug) with guard-minitest, I am unable to see the output while I am typing. I have seen this problem with Rails 4.2.8 as well as Rails 5.
If I run the test outside of guard, the debugger works fine.
byebug (9.0.6)
guard (2.14.1)
guard-minitest (2.4.6)
rails (4.2.8)

do you have rb-readline gem installed?
In my case removing it from Gemfile solved this issue!

Related

Mongoid::Criteria can't modify frozen String

This perplexes me. A Mongoid::Criteria is not frozen, but if I assign it to a variable in console, it tells me FrozenError (can't modify frozen String: "#<Mongoid::Criteria
Why would that be, and how do I fix it?
mongoid (~> 7.3.0)
rails (~> 6.0.0)
I found this issue in IRB repo: https://github.com/ruby/irb/issues/136.
It means the issue was fixed in a later version of IRB, so my suggestion is to force IRB version higher than 2.8 to get the fix.
Just add gem 'irb', '>= 1.2.8' to your gemfile and test that it works with your current Ruby version.

Rails not using modified gem instead of original

this is what I believe a simple problem I need help with. I'm trying to modify a gem's method so that I can add another argument to it. For this, I've cloned the gem's repo to a local directory and changed the code I needed. Inside my app's Gemfile I'm doing this:
gem 'recommendable', path: "/home/aristizabal95/forked_gems/recommendable"
And running bundle install afterwards. Even though the bundler says it's using my code, when I run the tests I get this error:
ArgumentError: wrong number of arguments (given 4, expected 1..3)
from /var/lib/gems/2.3.0/gems/recommendable-2.2.0/lib/recommendable/rater/recommender.rb:21:in `recommended_for'
which indicates that the app is not running my version of the gem, but the original one. I have no idea why it's not working, and was unable to find any issue related to this.
Thanks in advance
EDIT:
This is what the Gemfile.lock looks like
PATH
remote: /home/aristizabal95/forked_gems/recommendable
specs:
recommendable (2.2.1)
activesupport (>= 3.0.0)
hooks (>= 0.2.1)
redis (>= 2.2.0)
GEM
recommendable!
My guess is that spring still has the gem from the original gem source loaded.
To force spring to reload the gem (from your local source), do:
spring stop
in the console. Then restart your server and you should be using the gem from your local source.

rails activeadmin initialize command frozen

I'm trying to use activeadmin, but when I try to execute the setup command, the terminal keeps frozen, with no output
Gemfile:
gem 'activeadmin', github: 'activeadmin'
Setup command:
rails generate active_admin:install
After a chat, it turned out the generator command worked with spring turned off. The clue was when he stopped the command hung:
^C/Users/letz/.rvm/gems/ruby-2.1.3/gems/spring-1.2.0/lib/spring/client/run.rb:54:in `gets': Interrupt
from /Users/letz/.rvm/gems/ruby-2.1.3/gems/spring-1.2.0/lib/spring/client/run.rb:54:in `verify_server_version'
from /Users/letz/.rvm/gems/ruby-2.1.3/gems/spring-1.2.0/lib/spring/client/run.rb:25:in `call'
from /Users/letz/.rvm/gems/ruby-2.1.3/gems/spring-1.2.0/lib/spring/client/command.rb:7:in `call'
from /Users/letz/.rvm/gems/ruby-2.1.3/gems/spring-1.2.0/lib/spring/client/rails.rb:23:in `call'
The problem was with the spring gem.
I've removed the spring gem from the GemFile, and then it worked

I get the error "rspec: command not found" but 'gem list' shows rspec installed

I'm currently in the directory of an app I'm working on. I think I have rspec installed because when I type:
gem list
I get the following
...
some_gem
rspec (1.3.2)
rspec-rails (1.3.4)
another_gem
...
But when I type
rspec ./spec/my_favorite_test_spec.rb
I get the error
-bash: rspec: command not found
Am I doing something wrong?
RSpec 1.x uses the spec executable. RSpec 2.x uses rspec.

Zentest - How to stop automatic testing when red

I am trying to configure autotest so that when I run my test suite and I have a failing test, autotest stops testing and waits for me to make a change before testing again. With my current configuration autotest keeps testing indefinetly when it encounters a failing test making it a bit of a hassle to deal with (having to tab into terminal and stop the autotest server everytime I get a failing test).
I am working on a rails app using RSpec, Zentest and Spork.
Relevant Gem Versions:
autotest (4.4.6)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
spork (0.9.0.rc8)
ZenTest (4.5.0)
My .autotest file:
module Autotest::Notify
def self.notify title, msg, img, pri='low', time=3000
`notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'`
end
Autotest.add_hook :ran_command do |autotest|
results = [autotest.results].flatten.join("\n")
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
folder = "~/.autotest_icons/"
if output =~ /[1-9]\d*\sfailures?/
notify "FAIL:", "#{output}", folder+"failed.png", 'critical', 10000
elsif output =~ /[1-9]\d*\spending?/
notify "PENDING:", "#{output}", folder+"pending.png", 'normal', 10000
else
notify "PASS:", "#{output}", folder+"passed.png"
end
end
end
Note: Most of my .autotest file was to get popups working in linux to display if my tests are passing or failing.
I have been searching for an answer to this problem for a while and have had no luck and I have found it very difficult to get my hands on some good documentation for Autotest. I have been staring at the RDoc for Zentest for quite a while now as well and I must just be missing something.
Any help, links to examples, etc, would be greatly appreciated.
I had the same problem and found that my development server was writing to the log file. After I added this to my .autotest file, the problem went away:
Autotest.add_hook :initialize do |at|
at.add_exception(%r{^\./\.git})
at.add_exception(%r{^\./log})
end
I saw a similar problem with ZenTest when I had a gem that was writing data to a directory that ZenTest was monitoring. IIRC, it was a gem that did full-text searching -- the index file the search generated was triggering ZenTest to run again, thereby regenerating the index.
I tracked down the problem by modifying the Growl notifications to tell me which files were triggering the autotest run (I was running on a Mac at the time).
The solution was to add an exception/exclude to the .autotest file, to tell it to ignore the index.
(I've just seen : Spork is repeatedly re-running failing tests in autotest which sounds very similar to your problem)

Resources