Skip to content

Commit

Permalink
Update spec_helper.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
aviflombaum committed Sep 9, 2015
1 parent 5cc3a80 commit aea726e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,29 @@
end
=end
end

def run_file(file)
eval(File.read(file), binding)
end

def get_variable_from_file(file, variable)
file_scope = binding
file_scope.eval(File.read(file))

begin
return file_scope.local_variable_get(variable)
rescue NameError
raise NameError, "local variable `#{variable}' not defined in #{file}."
end
end

def capture_puts
begin
old_stdout = $stdout
$stdout = StringIO.new('','w')
yield
$stdout.string
ensure
$stdout = old_stdout
end
end

0 comments on commit aea726e

Please sign in to comment.