From: Heesob Park Date: 2013-02-05T23:21:08+09:00 Subject: Re: old syntax? what's going on here 2013/2/5 tamouse mailing lists > > I have this in a _spec.rb file: (a gem I inherited at work) > > Open3.expects(:popen3).with do |command| > case part_of_command > when Regexp: command =~ part_of_command > when String: command.include?(part_of_command) > else raise "Can't match that" > end > end > > which ruby is complaining about: > > spec/ruby_gpg_spec.rb:7: syntax error, unexpected ':', expecting > keyword_then or ',' or ';' or '\n' > when Regexp: command =~ part_of_command > ^ > spec/ruby_gpg_spec.rb:8: syntax error, unexpected keyword_when, > expecting keyword_end > when String: command.include?(part_of_command) > ^ > spec/ruby_gpg_spec.rb:9: syntax error, unexpected keyword_else, > expecting keyword_end > else raise "Can't match that" > ^ > spec/ruby_gpg_spec.rb:241: syntax error, unexpected keyword_end, expecting > $end > > I'm completely unfamiliar with what is supposed to be happening above, > but I rather assume that Regexp: and String: have something to do with > the Open3.expects bit. > > I'm a bit pressed for time right now, can anyone give me some fast > pointers? Already delving into Open3... > The above case syntax is legitimate in ruby 1.8 but not in 1.9. Refer to http://blog.grayproductions.net/articles/getting_code_ready_for_ruby_19 Regards, Park Heesob