Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

+ Acceptance specs to run examples in example/ folder and match again…

…st expected output
  • Loading branch information...
commit 01f1232d8b7ba8a900dcc5eff0f3948f1a886921 1 parent 3dfadfa
@txus txus authored
Showing with 29 additions and 0 deletions.
  1. +29 −0 spec/acceptance/examples_spec.rb
View
29 spec/acceptance/examples_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper'
+require 'open3'
+
+describe "Regression examples from example/ directory" do
+
+ Dir["example/*.rb"].each do |example|
+
+ it "parses #{example} successfully" do
+ stdin, stdout, stderr = Open3.popen3("ruby #{example}")
+
+ expected_output_file = example.gsub('.rb', '.out').gsub('example/','example/output/')
+ expected_error_file = example.gsub('.rb', '.err').gsub('example/','example/output/')
+
+ if File.exists?(expected_output_file)
+
+ stdout.readlines.join.strip.should include(File.read(expected_output_file).strip)
+
+ elsif File.exists?(expected_error_file)
+ stderr.readlines.join.strip.should include(File.read(expected_error_file).strip)
+ else
+ error = "Neither #{expected_output_file} nor #{expected_error_file} exists. Cannot compare results with any output or error."
+ fail error
+ end
+
+ end
+
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.