2012年12月27日星期四

2012年12月26日星期三

2012年12月19日星期三

2012年12月17日星期一

2012年6月17日星期日

使用vagrant 搭建js 测试环境

vagrant 是一个使用virtualbox搭建虚拟开发环境的工具,
http://vagrantup.com/
virtualbox是oracle公司的开源虚拟机产品,

js 测试使用  capybara-webkit 和cucumber 作为BDD测试工具,

还用到了 ,因为vagrant默认安装的ubuntu 环境没有X Server
安装过程异常麻烦,自己看着一步一步来就好了。。


设置taobao的ruby gem源

$ gem sources --remove http://rubygems.org/
$ gem sources -a http://ruby.taobao.org/
修改 Gemfile 将 http://rubygems.org 改为 http://ruby.taobao.org/
source 'http://ruby.taobao.org/'

安装vagrant

gem install vagrant
添加box vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
在线下载lucid32.box太慢的话可以用下载工具下载好,放到当前文件夹里
建立文件夹
vagrant init lucid32
使用vagrant up 启动虚拟机
linux和mac可以直接vagrant ssh连接,windows用户可以使用SecureCRT 连接
虚拟机里默认的ruby版本为1.8.7,可以使用rbenv安装最新的1.9.3
安装之前需要先更新系统,默认的apt源为美国的,可以改成中国的加快速度
编译ruby需要一些工具,可以使用apt安装
sudo apt-get install build-essential zlib1g-dev curl git-core sqlite3 libsqlite3-dev
使用rbenv安装ruby-1.9.3-p194
# install rbenv and Ruby 1.9.3
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source .bash_profile
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build/
sudo ./install.sh 
rbenv install 1.9.3-p194
用到的gem包
https://github.com/cucumber/cucumber
https://github.com/thoughtbot/capybara-webkit
https://github.com/leonid-shevtsov/headless
nodejs ssl支持 apt-get install libcurl4-openssl-dev