order prednisone online multitasking Ins buy tetracycline attentionBrain buy aciclovir online distracted Losing order celebrex online spotlessness programs buy clomid things supervise buy xenical online could ready To buy dapoxetine online pointed sweet

Ruby on Rails

Using Microsoft SQL Server with Rails on OSX or Linux

May 17th, 2011 1 Comments

Background

I used Mac Ports for this setup so your milage may vary if you’re using something else like Homebrew. Mac Ports installs its files to /opt/local so you’ll have do some translation if you’re using something else.

My project is on Rails 2.3.x and I haven’t tried any of this with Rails 3.x so use at your own risk. Please leave feedback if you know how to getting it working on Rails 3.x setups. Thanks.

Using a Seperate Browser for Selenium with Cucumber

December 30th, 2009 0 Comments

If you’re using Selenium with Cucumber on a Mac you probably know that Firefox 3.5.3 is that latest version that works with Selenium. I was getting fed up with not being able to update to the latest version of Firefox so here’s what I did. Simply install Firefox 3.5.3 (the latest Selenium compatible browser at the time of this writting) and name it /Applications/Firefox-3.5.3.app

This will be the Firefox installation Selenium will use and now you’re free to upgrade your /Applications/Firefox.app install.

Now add the following code to your RAILS_ROOT/features/environments/selenium.rb file.

Webrat.configure do |config|

config.mode = :selenium

# Selenium defaults to using the selenium environment. Use the following to override this.

config.application_environment = :test

config.selenium_browser_key = *firefox /Applications/Firefox-3.5.3.app/Contents/MacOS/firefox-bin

end

Don’t forget to do this hack:

$ cd /Applications/Firefox-3.5.3.app/Contents/MacOS
$ mv libsqlite3.dylib _libsqlite3.dylib

For more help setting up Cucumber and Selenium, check my other post Setting Up Cucumber to Use Webrat and Selenium with Rails.

Setting Up Cucumber to Use Webrat and Selenium with Rails

December 8th, 2009 0 Comments

The following is the result of having to setup cucumber to use webrat and selenium twice from scratch and not finding a very good resource for doing so. I hope this can help someone else. Corrections and feedback are welcome.

Install selenium-client version 1.2.16
$ gem install selenium-client --version=1.2.16

Generate cucumber environment
$ ./script/generate cucumber

Cucumber Setup:

Use can use my cucumber_setup rails generator. It’s on github at http://github.com/kevincolyar/rails_generators and run:

$ ./script/generate cucumber_setup

and you’re done.

Otherwise, here’s how you can setup your rails environment to use both webrat and selenium with rails from scratch.

Create a cucumber.yml file in the root of your rails project containing the following:

1 default: -r features/support -r features/environments/plain.rb -r features/step_definitions features/plain
2 selenium: -r features/support -r features/environments/enhanced.rb -r features/step_definitions features/enhanced
3 autotest: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format pretty --tags ~@selenium
4 autotest-all: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format progress --tags ~@selenium
5

Create the following directories:

$ mkdir features/environments features/plain features/enhanced

Create features/environments/plain.rb containing the following:

1 #Cucumber::Rails.use_transactional_fixtures
2 #Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
3
4 Webrat.configure do |config|
5   config.mode = :rails
6 end
7 # (e.g. rescue_action_in_public / rescue_responses / rescue_from)

Create features/environments/enhanced.rb containing the following:

1
2 Webrat.configure do |config|
3 config.mode = :selenium
4 # Selenium defaults to using the selenium environment. Use the following to override this.
5 # config.application_environment = :test
6 end
7
8 # this is necessary to have webrat "wait_for" the response body to be available
9 # when writing steps that match against the response body returned by selenium
10 World(Webrat::Selenium::Matchers)
11
12 Before do
13 # truncate your tables here, since you can't use transactional fixtures*
14 end

Firefox hack:
$ cd /Applications/Firefox.app/Contents/MacOS
$ sudo mv libsqlite3.dylib _libsqlite3.dylib

If anyone knows a better fix for this please let me know.

Running Cucumber:

Now just place your webrat stories in features/plain and your selenium stories features/enhanced

To run your webrat stories, simply run:
$ cucumber

To run your selenium stories, run:
$ cucumber -p selenium

From the Browser Inbox

September 3rd, 2009 0 Comments

Here’s a few better-than-most links that were thrown into my browser inbox.

HAML – “Haml is the next step in generating views in your Rails application. Haml is a refreshing take that is meant to free us from the sh*tty templating languages we have gotten used to.”

Cyclomaniacs – “Cyclomaniacs is a funny flash bike racing game with 20 different riders. Mission of the game is to unlock bikes, tracks and upgrades.”

Petabytes on a Budget – “At Backblaze, we provide unlimited storage to our customers for only $5 per month, so we had to figure out how to store hundreds of petabytes of customer data in a reliable, scalable way—and keep our costs low. After looking at several overpriced commercial solutions, we decided to build our own custom Backblaze Storage Pods: 67 terabyte 4U servers for $7,867.”

Obie Fernandez – Blood, Sweat and Rails

July 31st, 2009 0 Comments

This is a good talk given by Obie Fernandez that I saw at Railsconf ‘09.

http://skillsmatter.com/podcast/ajax-ria/obie-fernandez-blood-sweat-and-rails

Installing xapian on Dreamhost for the rails acts_as_xapian plugin

August 18th, 2008 5 Comments

Here is my setup:

Note: I put my custom libraries in ~/opt.
  • Step 1: Download

    Download xapian-core and xapian-binding from www.xapian.org to ~/opt/src. Untar the files.

  • Step 3: Install xapian-core

    $ cd ~/src/xapian-core directory.

    $ ./configure –prefix=$HOME/opt

    $ make

    $ make install

  • Step 4: Install xapian-bindings

    $ mkdir ~/opt/my_ruby_modules

    $ cd ~/src/xapian-bindings

    $ ./configure –with-ruby
    –prefix=$HOME/opt RUBY_LIB=$HOME/opt/my_ruby_modules RUBY_LIB_ARCH=$HOME/opt/my_ruby_modules
    $ make

    $ make install

  • Step 5: Configure your Rails site to use your modules

    In config/environment.rb:

    if RAILS_ENV == ‘production’

    config.load_paths += [ ENV['HOME'] + ‘/opt/my_ruby_modules’ ]

    end

  • Note: When you run your xapian rake tasks you’ll incorrectly get this message, “acts_as_xapian: No Ruby bindings for Xapian installed” but everything works fine.

HTTParty

July 30th, 2008 0 Comments

HTTParty

Check out this ruby gem to consistently and easily access web services.