ruby-1.9

Are there any good mutation testing tools for ruby 1.9 and RSpec2?

半世苍凉 提交于 2019-12-03 09:47:59
问题 I used to use Heckle, but it is incompatible with ruby 1.9 because of issues with ParseTree. I've looked for alternatives, but the only thing that looked promising was Chaser, and that did not have any clear documentation that I could use to see if I could make it work with RSpec. It seems to have Test::Unit dependencies. So - is anyone out there using any cool tools to really check the quality of your tests? Alternatively - are there any coverage tools that provide better than c0 coverage?

Append row to csv file Ruby 1.9 CSV lib

天大地大妈咪最大 提交于 2019-12-03 09:32:45
Using Ruby 1.9 and CSV lib, I can't seem to append a row. The example in the documentation opens the file, and overwrites the row. What is the correct way to append rows to the document? Example from documentation: require 'csv' CSV.open("path/to/file.csv", "wb") do |csv| csv << ["row", "of", "CSV", "data"] csv << ["another", "row"] # ... end I think you can change the open to use ab : CSV.open("t.csv", "ab") do |csv| I will usually use the following to write to a csv file (Or any file) File.open("filename", 'a+') {|f| f.write("datatowrite\n)} File.open('filename', 'a'){ |outfile| CSV::Writer

Is autoload thread-safe in Ruby 1.9?

拜拜、爱过 提交于 2019-12-03 07:11:56
问题 It seems to me that the Ruby community has been freaking out a little about autoload since this famous thread, discouraging its use for thread safety reasons. Does anyone know if this is no longer an issue in Ruby 1.9.1 or 1.9.2? I've seen a bit of talk about wrapping requires in mutexes and such, but the 1.9 changelogs (or at least as much as I've been able to find) don't seem to address this particular question. I'd like to know if I can reasonably start autoloading in 1.9-only libraries

How do Enumerators work in Ruby 1.9.1?

人盡茶涼 提交于 2019-12-03 07:04:18
This question is not about how to use Enumerators in Ruby 1.9.1 but rather I am curious how they work. Here is some code: class Bunk def initialize @h = [*1..100] end def each if !block_given? enum_for(:each) else 0.upto(@h.length) { |i| yield @h[i] } end end end In the above code I can use e = Bunk.new.each , and then e.next , e.next to get each successive element, but how exactly is it suspending execution and then resuming at the right spot? I am aware that if the yield in the 0.upto is replaced with Fiber.yield then it's easy to understand, but that is not the case here. It is a plain old

require lib in RSpec with Ruby 1.9.2 brings “no such file to load”

谁说我不能喝 提交于 2019-12-03 02:18:53
I am trying to upgrade one of my Rails projects to Ruby 1.9.2 . All went pretty well, but one RSpec test broke. In this test I require a Ruby lib : # file spec/models/my_lib_spec.rb require 'spec_helper' require 'lib/services/my_lib' describe "MyLib" do it "should do something" do ... The lib looks like this: # file lib/services/my_lib.rb class MyLib def self.do_something ... In Ruby 1.8.7 (REE) the test worked well: $ ruby -v ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin11.1.0], MBARI 0x6770, Ruby Enterprise Edition 2011.03 $ rspec ./spec/models/my_lib_spec.rb .. Finished in 1.4 seconds

gem install mongrel fails with ruby 1.9.1

牧云@^-^@ 提交于 2019-12-03 01:23:34
I initiated myself into rails development yesterday. I installed ruby 1.9.1, rubygems and rails. Running gem install mongrel worked fine and ostensibly installed mongrel too. I am slightly puzzled because: script/server starts webrick by default which mongrel returns nothing locate mongrel returns lots of entries like /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib /Developer/SDKs/MacOSX10

What are tainted objects, and when should we untaint them?

坚强是说给别人听的谎言 提交于 2019-12-02 23:03:26
When do Ruby objects need to be made tainted and when should we untaint them? How does the concept of tainted object make a Ruby script run in safe mode? Can anyone elaborate on this to make the concept clear with some code snippets? What is Tainted? User input is tainted, by definition. For example: string = gets string.tainted? # => true You can also manually taint an object. string = 'Not yet tainted.' string.tainted? # => false (string = 'Explicitly taint me!').taint string.tainted? # => true Why Untaint an Object? Generally, you would untaint an object only after you validate and/or

Are there any good mutation testing tools for ruby 1.9 and RSpec2?

*爱你&永不变心* 提交于 2019-12-02 23:00:17
I used to use Heckle, but it is incompatible with ruby 1.9 because of issues with ParseTree. I've looked for alternatives, but the only thing that looked promising was Chaser, and that did not have any clear documentation that I could use to see if I could make it work with RSpec. It seems to have Test::Unit dependencies. So - is anyone out there using any cool tools to really check the quality of your tests? Alternatively - are there any coverage tools that provide better than c0 coverage? This would kind of help solve the same problem. I'm using cover_me at the moment, but it is c0, like

Is autoload thread-safe in Ruby 1.9?

痴心易碎 提交于 2019-12-02 22:00:00
It seems to me that the Ruby community has been freaking out a little about autoload since this famous thread , discouraging its use for thread safety reasons. Does anyone know if this is no longer an issue in Ruby 1.9.1 or 1.9.2? I've seen a bit of talk about wrapping requires in mutexes and such, but the 1.9 changelogs (or at least as much as I've been able to find) don't seem to address this particular question. I'd like to know if I can reasonably start autoloading in 1.9-only libraries without any reasonable grief. Thanks in advance for any insights. I don't know about the general case,

Ruby 1.9 Ramaze App Failing with “Illegal instruction”

旧城冷巷雨未停 提交于 2019-12-02 00:09:24
问题 I've got an app that I'm trying to get working again after wiping my system and installing Snow Leopard. I installed Ruby 1.9 from Macports (now a later version) and the dev server starts up just fine, but then dies on the first request, only telling me "Illegal instruction". I have no idea what's causing this or even how to go about debugging it. Does anyone have any ideas? 回答1: "Illegal instruction" is usually an error message from the CPU meaning some piece of binary code you tried to run