rubyrspecapache-pigtest-first

TestFirst Teaching Pig Latin 'rspec_config failed'


I'm in the course of completing the Pig Latin exercise from TestFirst Teaching, but after I made the Ruby file and attempted to run rake, I got the following error:

austin-winslows-macbook-4:04_pig_latin HypnoBoy$ rake
(in /Users/HypnoBoy/Desktop/Code/learn_ruby)
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:45:in `gem_original_require':     
/Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin/pig_latin.rb:15: Invalid char `\342' in expression (SyntaxError)
/Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin/pig_latin.rb:15: Invalid char `\200' in expression
/Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin/pig_latin.rb:15: Invalid char `\246' in expression
/Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin/pig_latin.rb:15: syntax error, unexpected tIDENTIFIER, expecting ']'
  word[i..-1] + cons.join()[0…i] + "ay"
                             ^
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin/pig_latin_spec.rb:20
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `autorun'
from /usr/bin/rspec:23
rake aborted!
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S rspec     /Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin/pig_latin_spec.rb -I/Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin -I/Users/HypnoBoy/Desktop/Code/learn_ruby/04_pig_latin/solution -f documentation -r ./rspec_config failed

(See full trace by running task with --trace)

I think it may have something to do with the version I'm running, but I'm not at all sure.

Mac OSX 10.8.2
Ruby 1.8.7
Rspec 2.13.1
Rake 10.0.4

NOTE! When I run rake on the previous exercises (0-3) they work just fine, but nothing after that works...

EDIT: I updated my rake version, and now when I try to run rake I still get a 'rspec_config failed' error, but I get this as well. HELP!!!

/Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:156:in `run_task'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:124:in `initialize'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:58:in `verbose'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:122:in `send'
/Library/Ruby/Gems/1.8/gems/rspec-core-2.13.1/lib/rspec/core/rake_task.rb:122:in `initialize'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:246:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:184:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:205:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:203:in `each'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:203:in `invoke_prerequisites'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:183:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:73:in `run'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
Tasks: TOP => default => spec
(See full trace by running task with --trace)

EDIT #2: Here's the source code for my Pig Latin exercise, since it says it's a syntax thing.

def isvowel?(letter)
  vowels = ["a", "e", "i", "o", "u"]
  vowels.include?(letter)
end

def translate(word)
  i = 0
  cons = []

  while !isvowel?(word[i])
    cons << word[i]
    i+=1
  end

  word[i..-1] + cons.join()[0…i] + "ay"
end

def translates(string)
  if !string.include?(" ")
    translate(string)
  else
    new = string.split(" ").collect { |word| translate(word) }
  end

  new.join(" ")
end

Solution

  • It's choking on cons.join()[0…i] + "ay" - I noticed that you have a strange looking ... that isn't a standard ...

    Did you copy and paste this part of the code? The difference between … (a strange and unwanted character) and ... (the proper ruby operator) is what is breaking it. Simply delete that other character and write the dots in by hand.