I have an extremely simple unit test. I'm not sure why it fails when the expected is the same as the actual!
Here is the method I am testing:
def calibration_constant
big_decimal = self.coefficient * (10**self.exponent)
return big_decimal.to_f
end
Note, that coefficient is "6.1" and exponent is "1"
Here is the relevant test lin...
[Edited to use much simpler code which shows the problem]
The following code gives a segmentation fault on the last line
require 'rubygems'
gem 'mysql'
gem 'dbi'
require 'dbi'
require 'mysql'
dsn = "DBI:Mysql:DATABASE:www.HOST.net" # redacted
dbh = DBI.connect(dsn, "USERNAME", "PASSWORD") # redacted
sth = dbh.execute("select * from ...
Is it possible to embed Ruby into Erlang? Would Yecc be the correct tool for that? If it is possible how many man hours would it take, rough estimate?
...
I'm trying to run rake test:units and I keep getting this:
Mysql::Error: Duplicate entry '2147483647' for key 1: INSERT INTO `ts_schema_migrations` (version) VALUES ('20081008010000')
The "ts_" is there because I have ActiveRecord::Base.table_name_prefix set. I'm confused because there is no value '20081008010000' already in the tabl...
I'm starting to get a bit desperate in my attempts to get a ruby script to connect to MySQL.
I've given up on DBI, as I just don't seem to be able to get it to work no matter what I do. I figured I might have more luck with just using mysql.rb from ruby-mysql. However, in using that I get the following error:
./mysql.rb:453:in `read': ...
I have a small database and have been adding entries through a Rails page. I "destroyed" one of the entries and now my sequence of IDs are skipping by one. For example, I now have 42 then 44, instead of the obvious: 42, 43, 44.
I was wondering if there was a way to edit the ID number of a new object through the console. I have tried:
r...
Where does Rails store data created by saving activerecord objects during tests?
I thought I knew the answer to that question: obviously in the _test database. But it looks like this is not true!
I used this system to test what's happening to saved ActiveRecord data during rspec tests:
$ rails -d mysql test
$ cd test
$ nano config/d...
Hi, everyone!
I want to execute another ruby script from my Shoes app. I try
button "..." do
`ruby -rubygems /Users/kemiisto/Desktop/Ruby/gears.rb`
end
but nothing happens. In the case of other commands, for example
button "..." do
`open /Applications/TextEdit.app/`
end
all works fine. Any ideas?
...
I have been trying to reach the sources and references for Hpricot at
code.whytheluckystiff.net
For a long time now. Do you know if the site, the repository or the author moved to a different location or if it is only a transient situation?
Best regards and happy coding
...
Hi,
For my next project I plan to create images with text and graphics. I'm comfortable with ruby, but interested in learning python. I figured this may be a good time because PIL looks like a great library to use. However, I don't know how it compares to what ruby has to offer (e.g. RMagick and ruby-gd). From what I can gather PIL ...
I am primarily a Java developer, and I've been reading a lot of in-depth work on threads and concurrency. Many very smart people (Doug Lea, Brian Goetz, etc) have authored books on these topics and made contributions to new concurrency libraries for Java.
As I start to learn more about Python, Ruby, and other languages, I'm wondering: ...
I'm trying to build some unit tests for testing my Rails helpers, but I can never remember how to access them. Annoying. Suggestions?
...
I'm pretty sure the answer is "no" but I thought I'd check.
Background:
I have some legacy data in Access, need to get it into MySQL, which will be the DB server for a Ruby application that uses this legacy data.
Data has to be processed and transformed. Access and MySQL schemas are totally different. I want to write a rake task in Ru...
I have some classes that will do something based on some conditions . The conditions are sent as parameters to some methods . My questions is related to ruby coding style :
should the conditions be sent as lambdas/blocks , or as some objects that inherit from a condition class ?
which is more efficient in terms of OOP ?
Thanks !
...
When writing ruby code, it is easy to test how different functions behave by testing them out in irb. But to test code in C, I usually have to open up a separate IDE and write code there to test how it works. Is there an interpreter-like tool available in Unix or Windows platform?
...
I have created Ruby test script that use Selenium RC to test my web app directly in 2 browsers(IE, Firefox). My script runs - first on IE then continue on firefox and then should be continued and finished in already opened IE browser. My problem is: I can't continue(reconnect) to run my script in already opened IE browser. I use @browse...
I have a class with some methods. It's supersekret but I've reproduced what I can here.
Class RayGun
# flashes red light
# requires confirmation
# makes "zowowowowowow" sound
def stun!
# ...
end
# flashes blue light
# does not require confirmation
# makes "trrrtrtrtrrtrtrtrtrtrtr" sound
def freeze!
# ...
end...
I'm having some trouble with my Rails app being very slow on my staging server. What is most confusing is that the final line of the log output for each request.
It seems the View and Database times aren't even close to the entire render time. On one page it is as bad as ~1000ms for Completion, ~450ms for the View and ~20ms Database.
...
We're having great results with the Phusion stack (Passenger and Ruby Enterprise Edition) in house, but I haven't been able to find much in the way of data on their use in the wild, particularly REE. I'd love something akin to WWR's High Profile Organizations Using Rails or Ben Forta's Who's Using ColdFusion? list.
There's some google g...
I'm trying to wrap my head around functional programming in ruby and there doesn't seem to be much good documentation out there.
Essentially, I'm trying to write a combine function that would have a Haskell type signature of:
[a] -> [a] -> (a -> a -> a) -> [a]
So
combine([1,2,3], [2,3,4], plus_func) => [3,5,7]
combine([1,2,3], [2,3...