Posts mit dem Label Ruby werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Ruby werden angezeigt. Alle Posts anzeigen

2010-07-22

BrainDump: irb - require returns LoadError: no such file to load

Situation:
irb(main):011:0> require 'json'
LoadError: no such file to load -- json
 from (irb):11:in `require'
 from (irb):11
 from :0
irb(main):012:0> require 'rubygems'
=> true
irb(main):013:0> require 'json'
=> true
irb(main):014:0>  

Solution:
Do
require 'rubygem' 
before

2010-07-10

Culerity, Cucumber and Couchapp - Part 2

Some further modifications in the files mentioned here were necessary to get the initial setup runable.
(System configuration: WinXP, JRuby 1.5.1, CouchDB 0.11, couchapp 0.6.2)
  1. step_definitions/common_culerity_steps.rb - add this
    1. def couchapp
    2.   'rem' # enter your couchapp name here
    3. end
  2. support/paths.rb - modify

    Before:
    1.     when /start page/                                            
    2.       "/#{database}/_design/#{database}/index.html"
    3.     else                                                        
    4.  
    After:
    1.     when /start page/
    2.       "/#{database}/_design/#{couchapp}/index.html"
    3.     else
  3. step_definitions/common_culerity_steps.rb - remove ":resynchronize => true," from
    1.     $browser = Culerity::RemoteBrowserProxy.new $server, {
    2.       :browser => :firefox,
    3.       :javascript_exceptions => true,
    4.       :resynchronize => true,
    5.       :status_code_exceptions => true}
    6.  
  4. start_page.feature - modify the example scenario to
    1.   Scenario: go to the start page        
    2.     When I go to the start page          
    3.     Then I should see the text "Generated CouchApp"

After this modifications I got:
E:\projects\privat\rem>jruby -S cucumber --no-color
Feature: start page
  In order to feel welcome
  As a user
  I want to be welcomed on the start page

  Scenario: go to the start page                    # features\start_page.feature:7
2010-07-10 17:01:12 [INFO] Visit your CouchApp here:
http://localhost:5984/hejhej/_design/rem/index.html
    When I go to the start page                     # features/step_definitions/common_culerity_steps.rb:90
    Then I should see the text "Generated CouchApp" # features/step_definitions/common_culerity_steps.rb:119

1 scenario (1 passed)
2 steps (2 passed)
0m8.625s

E:\projects\privat\rem>

2010-07-09

Culerity, Cucumber and Couchapp

Starting a new couchapp application I want to try BDD. I found a small tutorial how to testing couchapps with cucumber and culerity. Unfortunatly I have to deal with WinXP, and so I run into some trouble because the culerity server doesn't start. Finally I can solve it by insert "jruby " in culerity-0.2.10/lib/culerity.rb, line 28.

Before:
def self.run_server
   IO.popen(File.dirname(__FILE__) + "/../bin/run_celerity_server.rb", 'r+').extend(ServerCommands)
end
After:
def self.run_server
   IO.popen("jruby " + File.dirname(__FILE__) + "/../bin/run_celerity_server.rb", 'r+').extend(ServerCommands)
end

2009-04-03

Initd Script für cruisecontrolrb

Based on the $CCRB_HOME/daemon/cruise.sample version.


#!/usr/bin/ruby
# chkconfig: 235 99 10
# description: Start or stop the SnipSnap server
#
### BEGIN INIT INFO
# Provides: cruisecontrolrb
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start or stop the cruisecontrolrb daemon
### END INIT INFO

ENV['PATH']="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"

require "fileutils"
include FileUtils

require "rubygems"

begin
gem 'mongrel'
rescue => e
puts "Error: daemon mode of CC.rb requires mongrel installed"
exit 1
end

def cruise_path
"/home/cruise/cruisecontrolrb"
end

def cruise_user
"cruise"
end

def cruise_log
"/var/log/cruisecontrolrb.log"
end

def start
system "su - #{cruise_user} -c 'cd #{cruise_path} && ./cruise start -d >> #{cruise_log}'"
end

def stop
system "mongrel_rails stop -P #{cruise_path}/tmp/pids/mongrel.pid >> #{cruise_log}" if File.exists?("#{cruise_path}/tmp/pids/mongrel.pid")
Dir["#{cruise_path}/tmp/pids/builders/*.pid"].each do |pid_file|
pid = File.open(pid_file){|f| f.read }
system "kill -9 #{pid}"
rm pid_file
end
end

command = ARGV.shift

system "touch #{cruise_log}"
system "chown #{cruise_user} #{cruise_log}"


case command
when 'start'
start
exit 0
when 'stop'
stop
exit 0
when 'restart'
stop
start
exit 0
else
puts "Usage: /etc/init.d/cruise start|stop|restart"
exit 1
end

2009-01-28

Java <=> Ruby

continue <=> next
throw <=> raise
catch <=> rescue
this <=> self
switch <=> case
case <=> when
default <=> else

2007-09-13

gem update hinterm proxy

Wenn Meldungen wie diese ...

ERROR: While executing gem ... (NoMethodError)
undefined method `[]=’ for Gem::ConfigFile

In ruby/site_ruby/1.8/rubygems/config_file.rb folgendes hinzufügen:
def []=(key, value)
@hash[key.to_s]=value
end


Source

2007-09-12