veeweeが使えない?
veeweeが使えない
早速、開発環境用のBoxを作ろうと思ったら、エラーが出た!
$ veewee vbox template -bash: veewee: command not found
ないって〜?あ、プラグインで入れたからかな...
$ vagrant veewee vbox templates Usage: vagrant [options] <command> [<args>]
えっ!違う。ん〜、じゃあ普通はどうやってインストールするんだ?
$ gem install veewee Fetching: os-0.9.6.gem (100%) ERROR: While executing gem ... (Errno::EACCES) Permission denied - /Users/xxxx/.rvm/gems/ruby-1.9.3-head/cache/os-0.9.6.gem $ sudo gem install veewee Fetching: os-0.9.6.gem (100%) Successfully installed os-0.9.6 : Parsing documentation for veewee-0.4.5.1 Installing ri documentation for veewee-0.4.5.1 Done installing documentation for os, to_slug, CFPropertyList, fission, posix-spawn, mime-types, diff-lcs, grit, ffi, childprocess, trollop, builder, mini_portile, nokogiri, rbvmomi, opennebula, net-ssh, net-scp, formatador, excon, fog-core, fog-xml, fog-terremark, fog-vmfusion, fog-voxel, fog-profitbricks, multi_json, fog-json, fog-radosgw, fog-sakuracloud, fog-softlayer, inflecto, fog-brightbox, ipaddress, fog, ruby-vnc, ansi, i18n, progressbar, highline, thor, Platform, open4, popen4, veewee after 384 seconds 45 gems installed
インスコしましたよ。では、改めて実行。
$ veewee vbox templates /Users/xxxx/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:315:in `to_specs': Could not find 'veewee' (>= 0) among 22 total gem(s) (Gem::LoadError) Checked in 'GEM_PATH=/Users/xxxx/.rvm/gems/ruby-1.9.3-head:/Users/xxxx/.rvm/gems/ruby-1.9.3-head@global', execute `gem env` for more information from /Users/xxxx/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:324:in `to_spec' from /Users/xxxx/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:58:in `gem' from /Users/xxxx/.rvm/rubies/ruby-1.9.3-head/bin/veewee:22:in `<main>'
あれ?あ、権限ね。
$ sudo veewee vbox templates The following templates are available: veewee vbox define '<box_name>' 'CentOS-4.8-i386' --workdir=/Users/xxxx : veewee vbox define '<box_name>' 'windows-8-preview-amd64' --workdir=/Users/xxxx
やれやれ。ようやく動いた。
Boxを作る。
$ sudo veewee vbox define 'u1404' 'ubuntu-14.04-server-amd64'
まずは、そのまま起動するまでやってみよう。
buildの途中でisoファイルをダウンロードするか聞かれるので、Yes[enter] で続行。
必要なもののダウンロードが終わったら、勝手にVMが上がってインストールが始まる。
$ sudo veewee vbox build u1404
しばらく待つと、build successfully!と、sshのログインコマンドが表示されアクセスできる。
シャットダウンするとvmは落ちて、VirtualBoxにも追加されてない。あれ、もっかい起動するときどーすんだ?
最初から環境作るには、スクリプトいじっとかないといけないみたいだけど面倒だなぁ。
PythonでTDD
PythonでもTDDを導入してみたいので、簡単なソースでお試ししてみる。
使っているのはPython2.7なんだけど、標準ライブラリにunittestというのがあるらしい。
でも最近は nose というのが使われているらしいので乗っかってみる。
nose のインストール
$ easy_install nose Searching for nose Reading https://pypi.python.org/simple/nose/ Best match: nose 1.3.4 Downloading https://pypi.python.org/packages/source/n/nose/nose-1.3.4.tar.gz#md5=6ed7169887580ddc9a8e16048d38274d Processing nose-1.3.4.tar.gz Writing /var/folders/5q/j2ypq41j30v1zm_s7kq9t6n40000gp/T/easy_install-yqYb1G/nose-1.3.4/setup.cfg Running nose-1.3.4/setup.py -q bdist_egg --dist-dir /var/folders/5q/j2ypq41j30v1zm_s7kq9t6n40000gp/T/easy_install-yqYb1G/nose-1.3.4/egg-dist-tmp-Lw0Yc5 no previously-included directories found matching 'doc/.build' Adding nose 1.3.4 to easy-install.pth file Installing nosetests script to /usr/local/bin Installing nosetests-2.7 script to /usr/local/bin Installed /usr/local/lib/python2.7/site-packages/nose-1.3.4-py2.7.egg Processing dependencies for nose Finished processing dependencies for nose
簡単^ ^準備完了?ちゃんと動くんかな
テストケースを書いてみる
Python nose でユニットテストを書いてみた / 桃缶食べたい。 こちらを参考にさせていただき、書いてみた。
myfunc.py
# -*- coding: utf-8 -*- def add(num1, num2): return num1 + num2
test/test.py
# -*- coding: utf-8 -*- from myfunc import add class TestAdd(object): def setup(self): pass def teardown(self): pass def test_add_nums(self): assert add(1, 10) == 11
実行
$ nosetests -v test.TestAdd.test_add_nums ... ok ---------------------------------------------------------------------- Ran 1 test in 0.003s OK
OK!!
Mac + VirtualBox + Vagrant で開発環境構築(1)
まずは下準備
VirualBoxのインストール
https://www.virtualbox.org/wiki/Downloads からダウンロードしてインストール
記事時点のバージョン 4.3.20
Vagrantのインストール
https://www.vagrantup.com/downloads.html からダウンロードしてインストール
記事時点のバージョン 1.6.5
実はgemでインストールすると最新が入らないトラップに引っかかった。
gemでインストールすると...
$ sudo gem install vagrant Fetching: vagrant-1.5.0.gem (100%) Thanks for wanting to use Vagrant! Unfortunately, this is not the way to install Vagrant anymore. We now make installers for the various operating systems Vagrant supports. Vagrant is no longer distributed as a RubyGem. Please download the latest version for your operating system from the URL below. If you still wish to use the RubyGem version, you can manually install version 1.0.7. Note that the RubyGem version hasn't been updated in over a year and will no longer receive any updates. Prior to installing Vagrant using the installer, make sure you uninstall all your Vagrant gems, since they sometimes conflict. http://www.vagrantup.com If you want to learn more about why we don't distribute using RubyGems anymore, please read this: http://mitchellh.com/abandoning-rubygems Successfully installed vagrant-1.5.0 Parsing documentation for vagrant-1.5.0 Installing ri documentation for vagrant-1.5.0 Done installing documentation for vagrant after 0 seconds 1 gem installed
もうインストーラで入れろと? では、アンインストール
$ sudo gem uninstall vagrant Remove executables: vagrant in addition to the gem? [Yn] Removing vagrant Successfully uninstalled vagrant-1.5.0
この後、インストーラで入れたのにバージョンが1.5.0のままになってた。
whichで確認すると何やら別の場所(忘れた~ ~;)を参照してたので削除した。
アンインストールでキレイにして欲しい。
私の環境(MacOSX Lion)ではインストーラで入れた先は /usr/bin/vagrant らしい。
$ which vagrant /usr/bin/vagrant $ vagrant -v Vagrant 1.6.5
veeweeのインストール
Vagrantのプラグインとして入れるようなので、コマンド一発!
$ vagrant plugin install veewee Installing the 'veewee' plugin. This can take a few minutes... Installed the plugin 'veewee (0.4.5.1)'!
とりあえず、ここまでで準備完了...のハズ。
足りなかったら、そのときで^ ^;;