Cucumber is a BDD tool that provides a language - Given/When/Then syntax for describing "behavior"
The steps in this behavior description maybe implemented as pure Ruby code or in a variety of other DSL's like Capybara or Webrat for acceptance testing web applications. Both Capybara and Webrat are similar - the former has a cleaner/more flexible architecture. They both provide DSL e.g.
visit('/projects')
fill_in('First Name', :with => 'John')
click_link('id-of-link')
Here are reasons why Capybara is better than Webrat from the author himself)
"Webrat is fantastic, and it has done wonders for testing Ruby webapps,
it provides a very slick and elegant DSL for interacting with webapps,
but it also has a couple of problems:
* It is strongly tied to Rails and the Integration Testing built into
Rails
* It doesn't have (comprehensive) support for testing JavaScript
* It is difficult to extend
* There is no driver agnostic test suite to make sure that Selenium
mode for example behaves the same as Rails mode.
* It cannot run different drivers in the same process, so it can't run
one feature under selenium and another in simulation.
All of these pain points led me to tinker around with building a
driver agnostic solution with the following goals:
* Make it dead simple to switch between different drivers
* Support multiple drivers out of the Box
* Provide a comprehensive test suite which can run against any driver
* Make it work with any Rack based framework
* Make it as compatible as possible with the Webrat API
The result of this work is called Capybara and can be found at GitHub
here: http://github.com/jnicklas/capybara
It uses rack-test to simulate a browser instead of Rails' Integration
Testing, which means that interacting with the controller is out (it's
bad practice anyway, imho. It's an integration test after all). I also
intentionally didn't make have_tag and have_text work, since those by
virtue of how they work will never be useful with Selenium, Culerity
or any other browser simulator. Instead there's have_content,
have_xpath and have_css. Other than that it's very similar to Webrat. "
Wednesday, January 26, 2011
Monday, January 17, 2011
Ruby/Rails on Ubuntu
For apt-get to install packages on a new Ubuntu install, first run update: apt-get update
sudo apt-get install curl
sudo apt-get install build-essential (installs libraries required to compile C programs/make)
sudo apt-get install zlib1g-dev libreadline5-dev libssl-dev libxml2-dev
sudo apt-get install ruby1.8
ruby1.8 -ropenssl -rzlib -rreadline -e "puts:Hello"
sudo apt-get install rubygems
sudo gem install rails (rails script is found in /var/lib/gems/1.8)
export PATH=/var/lib/gems/1.8/bin/:$PATH
sudo apt-get install ruby1.8-dev << this package is essential for building ruby native extensions.
MYSQL:
sudo apt-get mysql-server mysql-client
libmysql-ruby: This is an API module that allows to access MySQL database from programs in Ruby.
libmysqlclient-dev: package includes development libraries and header files for MySQL
sudo apt-get libmysql-ruby libmysqlclient-dev
gem install mysql
APACHE & PASSENGER:
sudo apt-get apache2
sudo gem install passenger
sudo passenger-install-apache2-module
sudo apt-get install curl
sudo apt-get install build-essential (installs libraries required to compile C programs/make)
sudo apt-get install zlib1g-dev libreadline5-dev libssl-dev libxml2-dev
sudo apt-get install ruby1.8
ruby1.8 -ropenssl -rzlib -rreadline -e "puts:Hello"
sudo apt-get install rubygems
sudo gem install rails (rails script is found in /var/lib/gems/1.8)
export PATH=/var/lib/gems/1.8/bin/:$PATH
sudo apt-get install ruby1.8-dev << this package is essential for building ruby native extensions.
MYSQL:
sudo apt-get mysql-server mysql-client
libmysql-ruby: This is an API module that allows to access MySQL database from programs in Ruby.
libmysqlclient-dev: package includes development libraries and header files for MySQL
sudo apt-get libmysql-ruby libmysqlclient-dev
gem install mysql
APACHE & PASSENGER:
sudo apt-get apache2
sudo gem install passenger
sudo passenger-install-apache2-module
Thursday, October 21, 2010
Java Performance Tuning
Oracle Technetwork article on gc tuning
Memory leaks in Java
java
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9000
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-agentlib:hprof=heap=dump,file=/tmp/hprof.bin,
format=b,depth=10
-jar java_app.jar
use jconsole from JDK 6
Memory leaks in Java
java
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9000
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-agentlib:hprof=heap=dump,file=/tmp/hprof.bin,
format=b,depth=10
-jar java_app.jar
use jconsole from JDK 6
Saturday, August 14, 2010
Ssh Port forwarding
SSH port-forwarding can allow secure access to remotehost/remoteport even if firewalls don't allow a direct connection; as long as we can access an ssh-server that has access to the remotehost/remoteport.
ssh -f -L localport:remotehost:remoteport hostname tail -f /dev/null
ssh-server must be running on hostname and hostname must be able to connect to remoteport and remotehost.
ssh -f -L localport:remotehost:remoteport hostname tail -f /dev/null
ssh-server must be running on hostname and hostname must be able to connect to remoteport and remotehost.
Saturday, July 31, 2010
Branch vs Trunk based development
Branching to develop new features is a common practice with large software development efforts. This has several drawbacks - primarily it prevents refactoring because merges become a huge problem, as suggested here. An alternative is the notion of "branch by abstraction" - where everyone works on the trunk but features can be turned on/off.
Saturday, May 22, 2010
Versioning in RESTful Web services
Two kinds of versioning: Data versioning vs schema(language) versioning
Langage versioning should be forward-compatible - not require existing clients to change their implementation. See Tag recommendations
Options from Stu Charlton
- version in content
- versions in URI
- versions in MIME-type http header
Langage versioning should be forward-compatible - not require existing clients to change their implementation. See Tag recommendations
Options from Stu Charlton
- version in content
- versions in URI
- versions in MIME-type http header
Tuesday, December 8, 2009
HATEOAS (Hypermedia as the Engine of Application State)
HATEOAS requires that each server response must contain not only the requested data — but also control information (in the forms of specially tagged URLs) describing the next set of permitted interactions with the server .....
Craig McClanahan's post on advantages of using HATEOAS - reduced client' coding errors, avoid invalid state transitions, fine grained evolution of the api's.
Jim Webber's
Craig McClanahan's post on advantages of using HATEOAS - reduced client' coding errors, avoid invalid state transitions, fine grained evolution of the api's.
Jim Webber's
Subscribe to:
Posts (Atom)