Skip to content

Commit

Permalink
Fixed more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
p8 committed Aug 23, 2010
1 parent b458242 commit 35b2970
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tryruby/app/views/tutorials/es_intro.html
Expand Up @@ -350,7 +350,7 @@ <h3>Ruby se Sienta y Espera</h3>
<li><code class="faded">&nbsp;&nbsp;f &lt;&lt; "Cat and Girl: http://catandgirl.com/\n"</code></li>
<li><code>end</code></li>
</ul>
<div class="answer">#.File:/Home/comics\.txt \(closed\).</div>
<div class="answer">#.File:/Home/comics\.txt.</div>
</div>
<div class="stretcher">
<h3>El Reloj Clavado en el Archivo</h3>
Expand Down
2 changes: 1 addition & 1 deletion tryruby/app/views/tutorials/intro.rhtml
Expand Up @@ -350,7 +350,7 @@ of <code>lines</code>. By using lines, ruby will return each line of the poem.</
<li><code class="faded">&nbsp;&nbsp;f &lt;&lt; "Cat and Girl: http://catandgirl.com/\n"</code></li>
<li><code>end</code></li>
</ul>
<div class="answer">#.File:/Home/comics\.txt \(closed\).</div>
<div class="answer">#.File:/Home/comics\.txt.</div>
</div>
<div class="stretcher">
<h3>The Clock Nailed To the File</h3>
Expand Down
11 changes: 7 additions & 4 deletions tryruby/lib/tryruby.rb
Expand Up @@ -68,7 +68,10 @@ def to_s
end

class File

def inspect
"#<File:#{@path}>"
end

def self.expand_path(*args)
file_name, dir_string = args
dir_string ||= FileSystem.current_dir.to_s
Expand Down Expand Up @@ -243,9 +246,9 @@ def run_line(code)
EOF
begin
result = Thread.new { eval cmd, TOPLEVEL_BINDING }.value
#rescue SecurityError => e
# puts e
#return Output.illegal
rescue SecurityError => e
puts e
return Output.illegal
rescue Exception => e
return Output.error :error => e, :output => get_stdout
ensure
Expand Down
6 changes: 5 additions & 1 deletion tryruby/test/unit/fake_f_s_test.rb
Expand Up @@ -59,7 +59,11 @@ def test_fake_dir_to_s_for_sub_sub_dir
end
end
end


def test_file_open
assert_equal("#<File:/comics.txt>", File.open("/comics.txt", "a") { |f| f << "a"}.inspect)
end

def test_file_expand_path_for_current_dir
assert_equal "/", File.expand_path(".")
Dir.mkdir "Home"
Expand Down
2 changes: 1 addition & 1 deletion tryruby/test/unit/try_ruby_test.rb
Expand Up @@ -172,7 +172,7 @@ def test_lesson5
input 'File.open("/Home/comics.txt", "a") do |f|', line_continuation: 1
input 'f << "Cat and Girl: http://catandgirl.com/\n"', line_continuation: 1
input 'end', result: Proc.new { |value|
assert_equal "#<File:/Home/comics.txt (closed)>", value.inspect
assert_equal "#<File:/Home/comics.txt>", value.inspect
}
input 'File.mtime("/Home/comics.txt")', result: Time
input 'File.mtime("/Home/comics.txt").hour', result: Fixnum
Expand Down

0 comments on commit 35b2970

Please sign in to comment.