Giter Site home page Giter Site logo

irb-config's Introduction

Installation

Prerequisites: rvm or rbenv.

To install, run

git clone git://github.com/nviennot/irb-config.git ~/.irb
cd ~/.irb
make install

make install installs all the required gems for all your installed rubies. When installing a new ruby, please make update in the ~/.irb directory.

Updates

To update the repository and all the gems, run

make update

What is it ?

Watch the screencast

Watch the screencast!

It packages:

This way you can switch back and forth from the development environment and the test environment, which is what the rspec/cucumber commands do.

How to use

  • All the goodies are automatically loaded into your rails console.
  • Use the rspec command pretty much like the usual one.
  • Use the cucumber command pretty much like the usual one.
  • Use the rake, test, generate, destroy, update commands as usual.
  • Type help to see the Pry help.

Notes

  • All the gems from your global gemset can be loaded bypassing Bundler.
  • The RSpec/Cucumber context run with your test environment, including your test database settings. Furthermore, whenever you run the rspec command, all your classes are reloaded with reload!.

Vim Integration

With the Screen plugin, you can communicate with screen/tmux to send some commands. I find these one particularly useful:

command -nargs=? -complete=shellcmd W  :w | :call ScreenShellSend("load '".@%."';")
map <Leader>c :ScreenShellVertical bundle exec rails c<CR>
map <Leader>r :w<CR> :call ScreenShellSend("rspec ".@% . ':' . line('.'))<CR>
map <Leader>e :w<CR> :call ScreenShellSend("cucumber --format=pretty ".@% . ':' . line('.'))<CR>
map <Leader>b :w<CR> :call ScreenShellSend("break ".@% . ':' . line('.'))<CR>

This is setup in my Vim configuration.

Assuming you have a tmux session with vim and the rails console:

  • :W saves and reloads the current file in the console.
  • ,c opens a tmux pane with a rails console.
  • ,r saves the file and run the rspec test corresponding to the cursor line.
  • ,e saves the file and run the cucumber test corresponding to the cursor line.
  • ,b puts a break point on the current line

License

irb config is released under the MIT license.

irb-config's People

Contributors

amiel avatar caifara avatar deiga avatar dontneedgithubaccount avatar lunks avatar nviennot avatar quentindecock avatar tjhosford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

irb-config's Issues

rspec - model not reloaded when saved

I'm running a rails console on Tmux, when I update my model and run the rspec test again, the model file is not reloaded...so killing the console and reloading is painful. Any clue?

Recommended additions to existing .tmux.conf/.vimrc?

I'm not sure I want to use a totally different vim setup, and like what I've done so far in customizing my tmux.conf. I'm wondering if there are specific lines you'd recommend I add to these files to make the most use of your irb-config, without having to throw them out or merge completely with a different set?

Problems with running rspec

My goal is to run rspec tests easily through vim and get an instant feedback.

Something like shown here.

Installed irb-config, ran console using test environment but have problems running particular tests:

~/code/zmep (test) > rspec spec/requests/accounts/account_registration_spec.rb:65
NoMethodError: undefined method `use_vcr_cassette' for #<Class:0x0000000b5620b0>
from /home/lapsa/code/zmep/spec/requests/accounts/account_registration_spec.rb:18:in `block (3 levels) in <top (required)>'

As far as I understand, problem is in my spec_helper.rb file

It extends RSpec with VCR macros only before doing Spork fork.

Likely - other configuration gets ignored too.

Any ideas what steps should I take to get towards my goal?

rspec with factorygirl

I added factorygirl to my testing.

When I first run the test I get the proper behavior, but every time thereafter I receive a "Factory not registered: account" where account is my model under test.

It is the same symptoms you would receive if you have not included Factory Girl.

As a work around I have to stop the rails console and restart it.

Any and all help would be awesome.

RuntimeError: Action dashboard already exist

Hi,

I just did a clean install of your current version and I get this:

~/project (main) > rspec spec/requests/sidebar_spec.rb:9
│RuntimeError: Action dashboard already exist. Please change its custom key
│from (eval):8:in `dashboard'    

Any idea what might be wrong?

Non-blocking error with RVM

Installing gems in /Users/lunks/.rvm/rubies:@global...
Unrecognized command line argument(s): '/Users/lunks/.rvm/rubies:@global gem install pry pry-doc pry-rails pry-debugger pry-stack_explorer awesome_print gnuplot coderay' ( see: 'rvm usage' )

Using RVM 1.17.0 (head).

factory_girl-preload fails

I'm not a heavy user of this gem (and certainly not a fan), but it is used on one of the projects I'm trying irb-config on. Sorry for the sudden number of issues, the idea behind irb-config is great, I like it very much!

I think the offending line might be this one: https://github.com/fnando/factory_girl-preload/blob/master/lib/factory_girl/preload.rb#L6

I get a NoMethodError when calling (assume my model is Invite) invites(:factory_name). You can take a look at the readme, but this is similar to how Rails fixtures work.

This is probably the behavior with some other gems as well. I've tried Object.send :include, FactoryGirl::Preload::Helpers, but while a NoMethodError is no longer raised, the before(:suite) did not run.

I've tried running on rails console test, but I get a NoMethodError as well.

binding.pry conflicts with irb-config

I use the gems pry, pry-debugger and pry-stack_explorer.

To create a breakpoint, I write

class UsersController < ApplicationController
  def index
    binding.pry
  end
end

When I remove binding.pry, the breakpoint is still there. I need to restart the server to remove it.

Make Install errors

Hi, I'm receiving the following error when I run make install from inside the ~/.irb dir.

ls: /rubies: No such file or directory
gems: pry pry-doc pry-debugger pry-stack_explorer awesome_print gnuplot coderay     colorize commands rails-env-switcher rspec-console cucumber-console mongoid-colors

Enjoy !

If I run rails c, it loads pry as expected...but if i attempt to run any of the commands listed either through vim or manually I get the following:

2] pry(main)> cucumber features/domain.feature/domain.feature
NameError: undefined local variable or method `features' for main:Object
from (pry):2:in `<main>'
[3] pry(main)>

Otherwise, I'm loving your project! Thanks for any help or advice. I'm very new to using vim/screen/tmux and am managing ruby using rbenv if that is important.

I should add that I also get the following when i run rails c

/Users/nader/.rbenv/versions/1.9.3-p194/gemsets/backupify/bundler/gems/rails- 4078d99bf614/activesupport/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the  future, use String#encode instead.
Loading development environment (Rails 3.0.19)
Error loading ~/.pryrc: IRB is not a module

undefined method `respond_with' for RSpec

My specs are all green when running

rspec spec

But when running through irb-console I get several:

undefined method `respond_with' for RSpec

¿Any hints?

Here's my Gemfile.lock

GEM
remote: http://rubygems.org/
specs:
accounts_client (0.0.20)
gravtastic
logical_model (> 0.5.8)
railties (>= 3.1)
actionmailer (3.1.6)
actionpack (= 3.1.6)
mail (
> 2.3.3)
actionpack (3.1.6)
activemodel (= 3.1.6)
activesupport (= 3.1.6)
builder (> 3.0.0)
erubis (
> 2.7.0)
i18n (> 0.6)
rack (
> 1.3.6)
rack-cache (> 1.2)
rack-mount (
> 0.8.2)
rack-test (> 0.6.1)
sprockets (
> 2.0.4)
activemodel (3.1.6)
activesupport (= 3.1.6)
builder (> 3.0.0)
i18n (
> 0.6)
activerecord (3.1.6)
activemodel (= 3.1.6)
activesupport (= 3.1.6)
arel (> 2.2.3)
tzinfo (
> 0.3.29)
activeresource (3.1.6)
activemodel (= 3.1.6)
activesupport (= 3.1.6)
activesupport (3.1.6)
multi_json (>= 1.0, < 1.3)
activity_stream_client (0.0.14)
logical_model (> 0.5.0)
railties (>= 3.1)
appsignal (0.8.7)
activesupport (>= 3.0)
rack
thread_safe
appsignal-mongo (0.1.10)
appsignal (> 0.7)
mongo
arel (2.2.3)
atomic (1.1.15)
bson (1.4.0)
bson_ext (1.4.0)
builder (3.0.4)
cancan (1.6.10)
capybara (2.2.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (
> 2.0)
carrierwave (0.5.8)
activesupport (> 3.0)
carrierwave-mongoid (0.1.7)
carrierwave (
> 0.5.6)
mongoid (> 2.1)
childprocess (0.3.9)
ffi (
> 1.0, >= 1.0.11)
coderay (1.1.0)
colorize (0.6.0)
columnize (0.3.6)
coveralls (0.5.8)
colorize
json
rest-client
simplecov (>= 0.7)
thor
crack (0.4.1)
safe_yaml (> 0.9.0)
cucumber (1.2.1)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (
> 2.11.0)
json (>= 1.4.6)
cucumber-rails (1.2.0)
capybara (>= 1.1.1)
cucumber (>= 1.1.1)
nokogiri (>= 1.5.0)
daemons (1.1.9)
dalli (2.6.4)
database_cleaner (1.2.0)
debugger (1.6.4)
columnize (>= 0.3.1)
debugger-linecache (> 1.2.0)
debugger-ruby_core_source (
> 1.3.0)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.0)
delayed_job (3.0.5)
activesupport (> 3.0)
delayed_job_mongoid (1.0.8)
delayed_job (
> 3.0.0)
mongoid (>= 2.0)
diff-lcs (1.2.5)
docile (1.1.1)
erubis (2.7.0)
ethon (0.4.2)
ffi (> 1.0.11)
mime-types (
> 1.18)
excon (0.31.0)
faker (0.9.4)
i18n (> 0.4)
fast-stemmer (1.0.2)
ffi (1.0.11)
figaro (0.7.0)
bundler (
> 1.0)
rails (>= 3, < 5)
fog (1.19.0)
builder
excon (> 0.31.0)
formatador (
> 0.2.0)
mime-types
multi_json (> 1.0)
net-scp (
> 1.1)
net-ssh (>= 2.1.3)
nokogiri (> 1.5)
ruby-hmac
formatador (0.2.4)
gherkin (2.11.6)
json (>= 1.7.6)
git-pivotal-tracker-integration (1.4.0)
highline (
> 1.6)
pivotal-tracker (> 0.5)
gravtastic (3.2.6)
guard (1.8.3)
formatador (>= 0.2.4)
listen (
> 1.3)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-rspec (3.1.0)
guard (>= 1.8)
rspec (> 2.13)
guard-spork (1.5.1)
childprocess (>= 0.2.3)
guard (>= 1.1)
spork (>= 0.8.4)
happymapper (0.4.1)
libxml-ruby (
> 2.0)
heroku-mongo-backup (0.4.32)
mongo
highline (1.6.20)
hike (1.2.3)
i18n (0.6.9)
json (1.8.1)
kaminari (0.13.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
kgio (2.8.1)
libnotify (0.8.2)
ffi (>= 1.0.11)
libxml-ruby (2.7.0)
listen (1.3.1)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
logical_model (0.5.10)
activemodel
activesupport
ethon (= 0.4.2)
kaminari (> 0.13.0)
typhoeus (= 0.5.0.alpha)
lumberjack (1.0.4)
machinist (1.0.6)
machinist_mongo (1.2.0)
machinist (
> 1.0.6)
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (> 1.16)
treetop (
> 1.4.8)
memcachier (0.0.2)
messaging_client (0.0.3)
logical_model (> 0.5.0)
railties (>= 3.1)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.5.2)
mongo (1.4.0)
bson (= 1.4.0)
mongoid (2.3.3)
activemodel (
> 3.1)
mongo (> 1.3)
tzinfo (
> 0.3.22)
mongoid-rspec (1.4.4)
mongoid (> 2.0)
rspec (
> 2)
mongoid_search (0.2.8)
bson_ext (>= 1.2)
fast-stemmer (> 1.0.0)
mongoid (>= 2.0.0)
multi_json (1.2.0)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.7.0)
nokogiri (1.6.1)
mini_portile (
> 0.5.0)
nokogiri-happymapper (0.5.8)
nokogiri (> 1.5)
overmind_client (0.0.5)
logical_model (
> 0.5.0)
railties (>= 3.1)
padma-deployment (0.0.1)
railties (>= 3.1)
pivotal-tracker (0.5.12)
builder
builder
crack
happymapper (>= 0.3.2)
nokogiri (>= 1.4.3)
nokogiri (>= 1.5.5)
nokogiri-happymapper (>= 0.5.4)
rest-client (> 1.6.0)
rest-client (
> 1.6.0)
polyglot (0.3.3)
pry (0.9.12.4)
coderay (> 1.0)
method_source (
> 0.8)
slop (> 3.4)
rack (1.3.10)
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.1.6)
actionmailer (= 3.1.6)
actionpack (= 3.1.6)
activerecord (= 3.1.6)
activeresource (= 3.1.6)
activesupport (= 3.1.6)
bundler (
> 1.0)
railties (= 3.1.6)
railties (3.1.6)
actionpack (= 3.1.6)
activesupport (= 3.1.6)
rack-ssl (> 1.3.2)
rake (>= 0.8.7)
rdoc (
> 3.4)
thor (> 0.14.6)
raindrops (0.12.0)
rake (10.1.1)
rb-fsevent (0.9.3)
rb-inotify (0.9.3)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
rdoc (3.12.2)
json (
> 1.4)
redcarpet (3.0.0)
rest-client (1.6.7)
mime-types (>= 1.16)
rmagick (2.13.2)
rspec (2.14.1)
rspec-core (> 2.14.0)
rspec-expectations (
> 2.14.0)
rspec-mocks (> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (
> 2.14.0)
rspec-expectations (> 2.14.0)
rspec-mocks (
> 2.14.0)
ruby-hmac (0.4.0)
ruby-mass (0.1.3)
safe_yaml (0.9.7)
shoulda-matchers (2.4.0)
activesupport (>= 3.0.0)
simplecov (0.8.2)
docile (> 1.1.0)
multi_json
simplecov-html (
> 0.8.0)
simplecov-html (0.8.0)
slop (3.4.7)
spork (1.0.0rc4)
sprockets (2.0.4)
hike (> 1.2)
rack (
> 1.0)
tilt (> 1.1, != 1.3.0)
state_machine (1.1.2)
thor (0.14.6)
thread_safe (0.2.0)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
timecop (0.3.5)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
typhoeus (0.5.0.alpha)
ethon (
> 0.4.2)
tzinfo (0.3.38)
unf (0.1.3)
unf_ext
unf_ext (0.0.6)
unicorn (4.7.0)
kgio (> 2.6)
rack
raindrops (
> 0.7)
xpath (2.0.0)
nokogiri (> 1.3)
yard (0.8.7.3)
yard-restful (1.2.2)
yard (
> 0.8.3)

PLATFORMS
ruby

DEPENDENCIES
accounts_client (> 0.0.18)
activity_stream_client (
> 0.0.14)
appsignal
appsignal-mongo
bson (= 1.4.0)
bson_ext (= 1.4.0)
cancan (> 1.6.7)
carrierwave
carrierwave-mongoid
coveralls
cucumber-rails (= 1.2.0)
daemons
dalli
database_cleaner (>= 0.6.7)
debugger
delayed_job_mongoid
ethon (= 0.4.2)
faker (= 0.9.4)
figaro
fog
git-pivotal-tracker-integration
guard-rspec
guard-spork
heroku-mongo-backup (
> 0.4.3)
i18n (> 0.6.6)
kaminari (
> 0.13)
libnotify
logical_model (> 0.5.8)
machinist (= 1.0.6)
machinist_mongo (= 1.2.0)
memcachier
messaging_client
mongoid (= 2.3.3)
mongoid-rspec (= 1.4.4)
mongoid_search
overmind_client (
> 0.0.1)
padma-deployment
rails (= 3.1.6)
rake
rb-inotify
redcarpet
rmagick
rspec-rails (> 2.14)
ruby-mass
shoulda-matchers
spork (> 0.9.0.rc)
state_machine (
> 1.1.2)
timecop (= 0.3.5)
unf
unicorn
yard (~> 0.8.3)
yard-restful

Screen vim plugin dependency

The ScreenShellVertical command is not an editor command, as you depend on the screen vim plugin.

You should document that dependency

Screenshot

LoadError: cannot load such file -- rspec

Hi Nicolas,

Followed the install instructions and get the error:

LoadError: cannot load such file -- rspec

when I open a console and try to run the rspec command.

Any ideas how I can fix this?

thanks

Simon

NoMethodError: undefined method `escape' for nil:NilClass

I'm getting this error after the second test run. First time it works ok, second time I run <leader>r I get the following:

from /Users/me/.rvm/gems/ruby-1.9.3-rc1@mygemset/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:66:in `quote_string'

Unable to load pry

I have installed your irb config and it is working when I start irb from console, but when I try to start rails console from any of my projects I see message "Unable to load pry". It is from 4th line in file irb/pry_loader.rb:

return unless IRB.try_require 'pry'

What am I doing wrong? Do you have any suggestions to solve this?

Strange errors

After installing and configuring (irb-config and screen plugin for tmux) I'm able to run the specs and everything. However, when doing it using irb-config it always fail.

Has anyone seen this error before?

Rack application timed out during boot

Hi,

Have you tried using capybara for rspec request specs? I always get Rack application timed out during boot inside rails c, but running it normally everything is fine.

mongoid_colors displays ANSI escapes on terminal colors

I've actually found out that mongoid_colors breaks the characters display on terminal (either bash or zsh) on my local machine.

$ pry
~ (main) > 361;36"36foo1;36"36
=> "foo"
~ (main) >

If I edit my .pryrc file and comment out line 11:

# ~/.pryrc

require 'rubygems'
require '~/.irb/irb/gem_loader'
require '~/.irb/irb/pry_loader'
require '~/.irb/irb/custom' if File.exists?("#{Dir.home}/.irb/irb/custom.rb")
require '~/.irb/irb/awesome_print_loader'
require '~/.irb/irb/bypass_reloader'
require '~/.irb/irb/rails_env_switcher'
require '~/.irb/irb/rspec_console'
require '~/.irb/irb/cucumber_console'
require '~/.irb/irb/rails_colors'
#require '~/.irb/irb/mongoid_colors'
require '~/.irb/irb/plot'
require '~/.irb/irb/rails_commands'

It works as expected:

$ pry
~ (main) > "foo"
=> "foo"
~ (main) >

Line added to global RVM gems list is incorrect

Just checked my global.gems file and it looks like irb-config is incorrectly parsing the string.

I ended up with a line like this:

prynpry-docnpry-debuggernpry-stack_explorernawesome_printngnuplotncoderay

So my guess is that this part of the Makefile is incorrect.

sed 's/ /\n/g'

Also don't you want these to be added as well?

commands rails-env-switcher rspec-console cucumber-console mongoid-colors

Unable to install irb-config with rbnev

I am trying to stall irb-config. I cloned it per the directions in the README.md file and changed into the ~/.irb directory. When I run "make" I get the following error:
Makefile:14: *** Please use rvm or rbenv. Stop.
I isntalled rbenv via homebrew and when I run rbenv --version I get the following output:
rbenv 0.4.0 which is the most current stable release.
I am really excited about using irb-config. What should I do to fix this problem?

Incompatibility with bullet?

When trying to run a test from the rails console, via rspec spec/helpers/dashboard_helper_spec.rb

   Failure/Error: Unable to find matching line from backtrace
     SystemStackError:
       stack level too deep
     # /home/geo/.rvm/gems/ruby-1.9.3-p194@mt/gems/bullet-4.6.0/lib/bullet/active_record3x.rb:10

And this persists for each test in the file. The error seems to go away if I disable Bullet.

load has no effect for models that call validates

Say I have a model that looks like this:

class User < ActiveRecord::Base
  attr_accessible :name, :email

  validates :name, presence: true
end

And a spec that looks like this:

describe User do
  before { @user = User.new(name: "Foo", email: "[email protected]") }
  # ... some respond_to specs ... #

  describe "when user name is not valid" do
    before { @user.name = " " }
    it { should_not be_valid }
  end
end

It will pass as expected, but if I remove the validates:

class User < ActiveRecord::Base
  attr_accessible :name, :email
end

The spec still passes if I'm running in the test enviroment. Writing and loading the model with :W will not change this.

I'm fairly new to rails, so I'm trying to figure out if there is some way to fix this and if not, if it is only validations that will have this effect. I'm a bit concerned with continuing to adopt this work flow, which I do really enjoy, if I can't trust my tests.

Is rbenv support WIP or just dead?

Hi, I love what you show in the screencast and wanted to give it a try.
But the problem is that I'm using rbenv and there was this ticket filed #19

So, is the rbenv support WIP/done/not-going-to-do ??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.