-
-
-
-
- -
-
-
-
(2015/1/9追è¨)
æ¬ä»¶ãtwitterã§åãããRailsãã¥ã¼ããªã¢ã«ã®ä¸ã®äºº(@yaslubãã)ãæ°ã¥ãã¦æ©éãã¥ã¼ããªã¢ã«å´ã®è¨è¼ãä¿®æ£ãã¦ä¸ããã¾ããã®ã§ãç¾æç¹ã§ãã¥ã¼ããªã¢ã«ã©ããã«ããã°æ¬äºè±¡ã¯çºçãã¾ãããä»äºãæ©ãã
-
-
-
-
- -
-
-
-
Railsãã¥ã¼ããªã¢ã«ãã£ã¦ã¦ãã3.6.2Guardã«ãããã¹ãã®èªååãã®ã¨ãããã¨ã©ã¼åºã¦ãã¾ããããªãã¦ã¡ãã£ã¨ããã£ãã®ã§å¯¾å¦æ³ãæ¸ãã¦ããã¾ãã
第3章 ほぼ静的なページの作成 | Rails チュートリアル
ç¾è±¡ã¨ãã¦ã¯ãGemfileã«guard-rspecã追å ãã¦
gem 'guard-rspec', '2.5.0'
bundle installããã¨
$ bundle install
ããã¯æåããã®ã ãã©ã次ã®ãguard init rspecããã¨ãããªãããã®ã¨ã©ã¼ãåºã¾ãã
$ bundle exec guard init rspec 12:53:38 - INFO - Writing new Guardfile to /Users/minamijoyo/work/ruby/rails_projects/sample_app/Guardfile 12:53:38 - ERROR - Could not load 'guard/rspec' or '~/.guard/templates/rspec' or find class Guard::Rspec
ãªããã©ã¤ãã©ãªããã¼ãã§ãã¦ããªãã£ã½ãã§ãã
çµè«ã ãç¥ããã人ã¯Gemfileã§æ示çã«guardã2.6.1ã«æå®ãã¦bundle update guardããã°è§£æ±ºãã¾ãã
... group :development, :test do gem 'sqlite3', '1.3.8' gem 'rspec-rails', '2.13.1' gem 'guard', '2.6.1' gem 'guard-rspec', '2.5.0' end ...
guardã®ãã¼ã¸ã§ã³ã®æ´æ°ã
$ bundle update guard
ãããããããã°ã試ãã«irbã§ãã¼ããã¦ã¿ãã¨
$ irb 2.0.0-p598 :002 > require 'guard/rspec' LoadError: cannot load such file -- guard/guard from /Users/minamijoyo/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' from /Users/minamijoyo/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' from /Users/minamijoyo/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-rspec-2.5.0/lib/guard/rspec.rb:2:in `<top (required)>' from /Users/minamijoyo/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require' from /Users/minamijoyo/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require' from /Users/minamijoyo/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require' from (irb):2 from /Users/minamijoyo/.rvm/rubies/ruby-2.0.0-p598/bin/irb:12:in `<main>'
guard-rspec-2.5.0/lib/guard/rspec.rb:2ã§èªã¿è¾¼ãã§ã
require 'guard/guard'
ã¨ããç®æã失æãã¦ãã£ã½ãã
ä¾åé¢ä¿ã§å
¥ã£ã¦ãgemã®ãã¼ã¸ã§ã³ã¯Gemfile.lockã¨ããã®ã«æ¸ãã¦ããããªã®ã§ãããè¦ãã¨guardã¯2.11.1ã«ãªã£ã¦ãã
railstutorialã®ã½ã¼ã¹Githubã«ããããããï¼ã¨æã£ã¦æ¢ããããã£ãã
GitHub - railstutorial/sample_app_rails_4: The reference implementation of the sample app for the Ruby on Rails Tutorial (Rails 4)
Gemfile.lockè¦ãã¨guardã¯2.6.1ã«ãªã£ã¦ãã
https://github.com/railstutorial/sample_app_rails_4/blob/master/Gemfile.lock
guardã®ã½ã¼ã¹ãGithubã«ãã£ãã®ã§è¦ã«è¡ãã¨
GitHub - guard/guard: Guard is a command line tool to easily handle events on file system modifications.
ç¾æç¹ã®ææ°2.11.1ã ã¨lib/guard/guard.rbãªããã©ã
2.6.1ã®ã½ã¼ã¹ãè¦ã¦ã¿ãã¨lib/guard/guard.rbãããã
https://github.com/guard/guard/tree/c807e26488aa1092b084703243bf3d7090c82cc1/lib/guard
ã©ããããã³ã´ã£ã½ãã
ã¨ããããã§ãGemfileã«æ示çã«guardã2.6.1ã«æå®ãã¦ã¿ãã
source 'https://rubygems.org' ruby '2.0.0' #ruby-gemset=railstutorial_rails_4_0 gem 'rails', '4.0.5' group :development, :test do gem 'sqlite3', '1.3.8' gem 'rspec-rails', '2.13.1' gem 'guard', '2.6.1' gem 'guard-rspec', '2.5.0' end group :test do gem 'selenium-webdriver', '2.35.1' gem 'capybara', '2.1.0' end gem 'sass-rails', '4.0.5' gem 'uglifier', '2.1.1' gem 'coffee-rails', '4.0.1' gem 'jquery-rails', '3.0.4' gem 'turbolinks', '1.1.1' gem 'jbuilder', '1.0.2' group :doc do gem 'sdoc', '0.3.20', require: false end group :production do gem 'pg', '0.15.1' gem 'rails_12factor', '0.0.2' end
ï¼â»æ³¨ï¼Macç°å¢ã§ããgrowlã¯å ¥ãã¦ã¾ããããªããæåã£ã½ãã®ã§Macéç¥ã»ã³ã¿ã¼ã«é£æºããterminal-notifier-guardã¨ããã®ããã¨ã§è©¦ãã¦è¦ãããã¨æããããï¼
Gemfile.lockãç¡è¦ãã¦æ´æ°ããã«ã¯updateããªããããªãããã
$ bundle update guard
å度試ãã¦ã¿ãã
$ bundle exec guard init rspec 13:08:00 - INFO - rspec guard added to Guardfile, feel free to edit it
ã¡ããã¨ãã¼ãããã¦ãã³ãã¬ãã¡ã¤ã«ã§ããã£ã½ãã
Guadfileã«è¿½è¨ããã
# A sample Guardfile # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch # directories %w(app lib config test spec feature) ## Uncomment to clear the screen before every task # clearing :on ## Guard internally checks for changes in the Guardfile and exits. ## If you want Guard to automatically start up again, run guard in a ## shell loop, e.g.: ## ## $ while bundle exec guard; do echo "Restarting Guard..."; done ## ## Note: if you are using the `directories` clause above and you are not ## watching the project directory ('.'), the you will want to move the Guardfile ## to a watched dir and symlink it back, e.g. # # $ mkdir config # $ mv Guardfile config/ # $ ln -s config/Guardfile . # # and, you'll have to watch "config/Guardfile" instead of "Guardfile" require 'active_support/inflector' guard 'rspec', all_after_pass:false do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } # Rails example watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch('config/routes.rb') { "spec/routing" } watch('app/controllers/application_controller.rb') { "spec/controllers" } # Capybara features specs watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" } # Turnip features and steps watch(%r{^spec/acceptance/(.+)\.feature$}) watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } # Custom Rails Tutorial specs watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb", (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : "spec/requests/#{m[1].singularize}_pages_spec.rb")] end watch(%r{^app/views/(.+)/}) do |m| (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" : "spec/requests/#{m[1].singularize}_pages_spec.rb") end watch(%r{^app/controllers/sessions_controller\.rb$}) do |m| "spec/requests/authentication_pages_spec.rb" end end
試ãã«å®è¡ãã¦ã¿ãã
$ bundle exec guard 13:18:20 - INFO - Guard is using TerminalTitle to send notifications. 13:18:20 - INFO - Guard::RSpec is running 13:18:20 - INFO - Running all specs ........ Finished in 0.14311 seconds 8 examples, 0 failures Randomized with seed 28626 13:18:24 - INFO - Guard is now watching at '/Users/minamijoyo/work/ruby/rails_projects/sample_app' [1] guard(main)>
ã¡ããã¨åããã£ã½ãã