SporkããSpringã«ä¹ãæããçµæï½ï½ï½ï½ï½ï½ï½ï½ï½ï½ï½ï½
ä»ã¾ã§rspec + guard + sporkã§ãã£ã¦ãã¾ãããã©ãsporkã®ãã¹ãã«ããå¹ããªããããã¨ãã¯ã¤ãã¤ãã ãªããã¨æã£ãã®ã§åã®Springã«ä¹ãæãã¦ã¿ããã¨ã«ããã
Gemfile
group :development, :test do gem "rspec-rails", "~> 2.13.0" gem "guard-rspec", "~> 2.5.2" ~snip~ gem 'spring' end
$ bundle install $ spring binstub rspec $ spring rspec Coverage report Rcov style generated for RSpec to /Users/ria10/IdeaProjects/hoge-web/coverage/rcov /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/watcher/listen.rb:36:in `subjects_changed': undefined method `directories' for #<Listen::Listener:0x007f9a5ac5ac78> (NoMethodError) from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/watcher/abstract.rb:47:in `add' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application.rb:100:in `setup' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application.rb:61:in `serve' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application.rb:49:in `block in run' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application.rb:43:in `loop' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application.rb:43:in `run' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application.rb:37:in `start' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:96:in `block in start_child' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:83:in `fork' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:83:in `start_child' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:26:in `start' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:53:in `block in with_child' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:20:in `synchronize' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:42:in `with_child' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/application_manager.rb:61:in `run' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/server.rb:52:in `serve' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/server.rb:40:in `block in boot' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/server.rb:40:in `loop' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/server.rb:40:in `boot' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/server.rb:18:in `boot' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/client/start.rb:13:in `call' from /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/spring-0.0.9/lib/spring/client/command.rb:7:in `call' ~snip~
ã¨ã©ã£ãã
調ã¹ã¦ã¿ãã¨ãã®ã¨ã©ã¼ã¯listen gemã< 1.0ã®ã¨ãã«èµ·ãããããã
https://github.com/jonleighton/spring/issues/161
listen gemããªãã®çµ¡ã¿ã§å ¥ã£ãã®ãããããªããã©ãã¨ã«ããupdateããã
$ bundle exec gem update listen Updating installed gems Updating listen Successfully installed rb-inotify-0.9.0 Successfully installed rb-kqueue-0.2.0 Successfully installed listen-1.2.2 Gems updated: rb-inotify rb-kqueue listen
ãããã¨æã£ã¦ãªãã©ã¤ãããã¾ãåãã¨ã©ã¼ãã§ããã©ããguardã®ãã¼ã¸ã§ã³ãä½ãã¨ãä½ãlistenãã¤ã³ã¹ãã¼ã«ããã¡ããã¿ããã§guardãupdateãã¦ãã£ãããã¾ããã£ãã
ãªãã©ã¤
$ spring rspec No DRb server is running. Running in local process instead ... /usr/local/opt/rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- spork (LoadError)
ã¨ã©ã£ãã
spec/spec_helper.rbã«sporkãrequireãã¦ããããã ã£ãã
ããã¨Spork絡ã¿ã®è¨è¿°ãåé¤ãã¦ãªãã©ã¤ã
$ spring rspec No DRb server is running. Running in local process instead ... ..................................................................................................................................................................................................................................................................................................................
ãã¾ããã£ãã
guardã¨çµã¿åããã¦ã¿ããguard-springã¨ããgemãããã
https://github.com/mknapik/guard-spring
Gemfile
group :development, :test do gem "rspec-rails", "~> 2.13.2" gem "guard-rspec", "~> 3.0.2" gem 'spring' gem 'guard-spring' end >|| $ bundle install $ guard init spring WARN: Unresolved specs during Gem::Specification.reset: thor (>= 0.14.6) ffi (>= 0.5.0) lumberjack (>= 1.0.2) WARN: Clearing out unresolved specs. Please report a bug if this causes problems. 20:49:44 - INFO - Guard here! It looks like your project has a Gemfile, yet you are running 20:49:45 - INFO - spring guard added to Guardfile, feel free to edit it
ãªããããã¢ãã¯ã¼ãã³ã°ãã§ããè¤æ°ãã¼ã¸ã§ã³ã®gemãå ¥ã£ã¦ããã¨ãããããã¨ã«ãªãããããbundle exec gem cleanupã§æé¤ãããããã¨ããã®ç¶æ ã§ãGuardfileã«ã³ã³ãã£ã°ã追è¨ã¯ããã¦ããã
追è¨ãããã³ã³ãã£ã°ãæ¶ãã¦ãªãã©ã¤ã
$ bundle exec guard init spring 21:00:16 - INFO - spring guard added to Guardfile, feel free to edit it
ãã¾ããã£ãããã ã
Guradãã£ã¢ã«ããã¯è¿½å ãããã³ã³ãã£ã°ä»¥å¤ã¯å ¨é¨æ¶ãã¦ãã¾ã£ãã
$ bundle exec guard 21:32:02 - WARN - Failed to create all required binstubs 21:32:02 - INFO - Guard::Spring Initialized 21:32:02 - INFO - Guard uses Growl to send notifications. 21:32:02 - INFO - Guard uses TerminalTitle to send notifications. Spring is not running 21:32:02 - INFO - Stopping Spring 21:32:02 - INFO - Starting Spring 21:32:02 - INFO - Guard is now watching at '/Users/ria10/IdeaProjects/hoge-web'
ã¡ããã¨ãã¡ã¤ã«ãå¤æ´ãããã¨åãã2åãåãããã£ã
spec_helper.rbãã以ä¸ã®è¨è¿°ãæ¶ããªãã¨ãµã¼ãã¹ã§ããï¼ååãã¦ãã¾ããããã
require 'rspec/autorun'
æä½æ¥ã§ãã¹ããèµ°ãããæãå¾ ããã«æ¸ã
$ spring rspec spec/routing/ ...................................................... Finished in 0.61229 seconds 54 examples, 0 failures Randomized with seed 20789
ã¯ããã»ã»ã»ã
ãã使ãrails console
$ spring rails c Loading development environment (Rails 3.2.13)
ãããï¼åº¦ãããçéï¼
ãã¼ããçã£ãã¨ããããã¾ãã¨ããã£ã¡ã®ã»ããããããªã