36: def translate_line(line)
37:
38: line.gsub!(/:any_args/, 'any_args')
39: line.gsub!(/:anything/, 'anything')
40: line.gsub!(/:boolean/, 'boolean')
41: line.gsub!(/:no_args/, 'no_args')
42: line.gsub!(/:numeric/, 'an_instance_of(Numeric)')
43: line.gsub!(/:string/, 'an_instance_of(String)')
44:
45: return line if line =~ /(should_not|should)_receive/
46:
47: line.gsub!(/(^\s*)context([\s*|\(]['|"|A-Z])/, '\1describe\2')
48: line.gsub!(/(^\s*)specify([\s*|\(]['|"|A-Z])/, '\1it\2')
49: line.gsub!(/(^\s*)context_setup(\s*[do|\{])/, '\1before(:all)\2')
50: line.gsub!(/(^\s*)context_teardown(\s*[do|\{])/, '\1after(:all)\2')
51: line.gsub!(/(^\s*)setup(\s*[do|\{])/, '\1before(:each)\2')
52: line.gsub!(/(^\s*)teardown(\s*[do|\{])/, '\1after(:each)\2')
53:
54: if line =~ /(.*\.)(should_not|should)(?:_be)(?!_)(.*)/m
55: pre = $1
56: should = $2
57: post = $3
58: be_or_equal = post =~ /(<|>)/ ? "be" : "equal"
59:
60: return "#{pre}#{should} #{be_or_equal}#{post}"
61: end
62:
63: if line =~ /(.*\.)(should_not|should)_(?!not)\s*(.*)/m
64: pre = $1
65: should = $2
66: post = $3
67:
68: post.gsub!(/^raise/, 'raise_error')
69: post.gsub!(/^throw/, 'throw_symbol')
70:
71: unless standard_matcher?(post)
72: post = "be_#{post}"
73: end
74:
75:
76: post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\'|\"|\:|@| ]+)(\})/, '\1(\2)\3')
77: post.gsub!(/^(redirect_to)\s+(.*)/, '\1(\2)')
78: post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\{.*\}|\'|\"|\:|@| ]+)/, '\1(\2)')
79: post.gsub!(/(\s+\))/, ')')
80: post.gsub!(/\)\}/, ') }')
81: post.gsub!(/^(\w+)\s+(\/.*\/)/, '\1(\2)')
82: line = "#{pre}#{should} #{post}"
83: end
84:
85: line
86: end