世界のやまさ

SEKAI NO YAMASA

入門Jenkins 読書記録(1)

前半の Android は後回しにして 7章の Rails を中心に読んだ。

Jenkins の環境は Ubuntu が中心だった。まずは OSX にというところで、 capybara-webkit をそのまま gem から入れようとしたらエラーとなった。Ruby はいろいろつまづきやすい。

capybara-webkit のインストールエラー

エラー内容

Installing capybara-webkit (0.14.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/user/.rbenv/versions/1.9.3-p327/bin/ruby extconf.rb
Command 'qmake -spec macx-g++' not available


Gem files will remain installed in /Users/user/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.14.2 for inspection.
Results logged to /Users/user/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.14.2/./gem_make.out

An error occurred while installing capybara-webkit (0.14.2), and Bundler cannot
continue.
Make sure that `gem install capybara-webkit -v '0.14.2'` succeeds before
bundling.

対処

本書の説明で先に依存関係のあるQtを入れると書いてあったので、おそらくOSXも同様でしょうということで、以下コマンドを実行

brew install qt

無事 bundle install 出来た。

大量の DEPRECATION WARNING

いざ rake rspec を実行すると大量の DEPRECATION が出た。こんな内容

エラー内容

`include Capybara` is deprecated. Please use `include Capybara::DSL` instead.

DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in RSpec::Rails::SetupAndTeardownAdapter instead. (called from <top (required)> at /Users/user/Documents/ruby/blog/spec/controllers/posts_controller_spec.rb:3)
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in RSpec::Rails::TestUnitAssertionAdapter instead. (called from <top (required)> at /Users/user/Documents/ruby/blog/spec/controllers/posts_controller_spec.rb:3)

対処

ぐぐってみるとどうやら rspec-rails のバージョンが古いからみたい。

gem 'rspec-rails', '~> 2.0' を単純に gem 'rspec-rails' にしたらとりあえずでなくなった

DatabaseCleaner のエラー

実行しても、 0 examples, 0 failures となっていてよく見ると以下エラーが出ていた。

エラー内容

Exception encountered: #<DatabaseCleaner::UnknownStrategySpecified: The 'trunsaction' strategy does not exist for the active_record ORM!  Available strategies: truncation, transaction, deletion>

対処

これは単純に typo で transaction にしてあげたらうまく実行できた。

➜  blog git:(master) ✗ rake spec
/Users/user/.rbenv/versions/1.9.3-p327/bin/ruby -S rspec ./spec/controllers/posts_controller_spec.rb ./spec/helpers/posts_helper_spec.rb ./spec/models/post_spec.rb ./spec/requests/posts_spec.rb ./spec/routing/posts_routing_spec.rb ./spec/views/posts/edit.html.erb_spec.rb ./spec/views/posts/index.html.erb_spec.rb ./spec/views/posts/new.html.erb_spec.rb ./spec/views/posts/show.html.erb_spec.rb
No DRb server is running. Running in local process instead ...
Rack::File headers parameter replaces cache_control after Rack 1.5.
...............*F............

Pending:
  PostsHelper add some examples to (or delete) /Users/user/Documents/ruby/blog/spec/helpers/posts_helper_spec.rb
    # No reason given
    # ./spec/helpers/posts_helper_spec.rb:14

Failures:

  1) Posts GET /posts
     Failure/Error: visit posts_path
     NameError:
       undefined local variable or method `posts_path' for #<RSpec::Core::ExampleGroup::Nested_3::Nested_1:0x007ffba5c90e98>
     # ./spec/models/post_spec.rb:6:in `block (3 levels) in <top (required)>'

Finished in 0.26662 seconds
29 examples, 1 failure, 1 pending

Failed examples:

rspec ./spec/models/post_spec.rb:8 # Posts GET /posts
rake aborted!
/Users/user/.rbenv/versions/1.9.3-p327/bin/ruby -S rspec ./spec/controllers/posts_controller_spec.rb ./spec/helpers/posts_helper_spec.rb ./spec/models/post_spec.rb ./spec/requests/posts_spec.rb ./spec/routing/posts_routing_spec.rb ./spec/views/posts/edit.html.erb_spec.rb ./spec/views/posts/index.html.erb_spec.rb ./spec/views/posts/new.html.erb_spec.rb ./spec/views/posts/show.html.erb_spec.rb failed

Tasks: TOP => spec
(See full trace by running task with --trace)

実行して満足したので、今日はこの辺にしておく。

入門Jenkins―実践「継続的インテグレーション」

入門Jenkins―実践「継続的インテグレーション」