Skip to content

Commit

Permalink
fix spec
Browse files Browse the repository at this point in the history
  • Loading branch information
QWYNG committed May 23, 2024
1 parent 93272c5 commit 5672838
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 54 deletions.
39 changes: 12 additions & 27 deletions spec/green_day/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,24 @@
<<~SPEC
RSpec.describe 'abc150/A.rb' do
it 'test with "2 900\\n"' do
if ENV['GD_REPL']
File.chmod(0o755, 'abc150/A.rb')
system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "2 900\\n\\\\004"; interact'))
else
io = IO.popen('ruby abc150/A.rb', 'w+')
io.puts("2 900\\n")
io.close_write
expect(io.readlines.join).to eq("Yes\\n")
end
io = IO.popen('ruby abc150/A.rb', 'w+')
io.puts("2 900\\n")
io.close_write
expect(io.readlines.join).to eq("Yes\\n")
end
it 'test with "1 501\\n"' do
if ENV['GD_REPL']
File.chmod(0o755, 'abc150/A.rb')
system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "1 501\\n\\\\004"; interact'))
else
io = IO.popen('ruby abc150/A.rb', 'w+')
io.puts("1 501\\n")
io.close_write
expect(io.readlines.join).to eq("No\\n")
end
io = IO.popen('ruby abc150/A.rb', 'w+')
io.puts("1 501\\n")
io.close_write
expect(io.readlines.join).to eq("No\\n")
end
it 'test with "4 2000\\n"' do
if ENV['GD_REPL']
File.chmod(0o755, 'abc150/A.rb')
system(%q(expect -c 'set timeout 2; spawn ruby abc150/A.rb; send "4 2000\\n\\\\004"; interact'))
else
io = IO.popen('ruby abc150/A.rb', 'w+')
io.puts("4 2000\\n")
io.close_write
expect(io.readlines.join).to eq("Yes\\n")
end
io = IO.popen('ruby abc150/A.rb', 'w+')
io.puts("4 2000\\n")
io.close_write
expect(io.readlines.join).to eq("Yes\\n")
end
end
Expand Down
39 changes: 12 additions & 27 deletions spec/green_day/test_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@
expect(subject).to eq(
<<~SPEC
\s\sit 'test with "2 900\\n"' do
\s\s\s\sif ENV['GD_REPL']
\s\s\s\s\s\sFile.chmod(0o755, 'submit_file')
\s\s\s\s\s\ssystem(%q(expect -c 'set timeout 2; spawn ruby submit_file; send "2 900\\n\\\\004"; interact'))
\s\s\s\selse
\s\s\s\s\s\sio = IO.popen('ruby submit_file', 'w+')
\s\s\s\s\s\sio.puts("2 900\\n")
\s\s\s\s\s\sio.close_write
\s\s\s\s\s\sexpect(io.readlines.join).to eq("Yes\\n")
\s\s\s\send
\s\s\s\sio = IO.popen('ruby submit_file', 'w+')
\s\s\s\sio.puts("2 900\\n")
\s\s\s\sio.close_write
\s\s\s\sexpect(io.readlines.join).to eq("Yes\\n")
\s\send
SPEC
)
Expand All @@ -43,27 +38,17 @@
<<~SPEC
RSpec.describe 'submit_file' do
\s\sit 'test with "2 900\\n"' do
\s\s\s\sif ENV['GD_REPL']
\s\s\s\s\s\sFile.chmod(0o755, 'submit_file')
\s\s\s\s\s\ssystem(%q(expect -c 'set timeout 2; spawn ruby submit_file; send "2 900\\n\\\\004"; interact'))
\s\s\s\selse
\s\s\s\s\s\sio = IO.popen('ruby submit_file', 'w+')
\s\s\s\s\s\sio.puts("2 900\\n")
\s\s\s\s\s\sio.close_write
\s\s\s\s\s\sexpect(io.readlines.join).to eq("Yes\\n")
\s\s\s\send
\s\s\s\sio = IO.popen('ruby submit_file', 'w+')
\s\s\s\sio.puts("2 900\\n")
\s\s\s\sio.close_write
\s\s\s\sexpect(io.readlines.join).to eq("Yes\\n")
\s\send
\s\sit 'test with "3 900\\n"' do
\s\s\s\sif ENV['GD_REPL']
\s\s\s\s\s\sFile.chmod(0o755, 'submit_file')
\s\s\s\s\s\ssystem(%q(expect -c 'set timeout 2; spawn ruby submit_file; send "3 900\\n\\\\004"; interact'))
\s\s\s\selse
\s\s\s\s\s\sio = IO.popen('ruby submit_file', 'w+')
\s\s\s\s\s\sio.puts("3 900\\n")
\s\s\s\s\s\sio.close_write
\s\s\s\s\s\sexpect(io.readlines.join).to eq("No\\n")
\s\s\s\send
\s\s\s\sio = IO.popen('ruby submit_file', 'w+')
\s\s\s\sio.puts("3 900\\n")
\s\s\s\sio.close_write
\s\s\s\sexpect(io.readlines.join).to eq("No\\n")
\s\send
end
Expand Down

0 comments on commit 5672838

Please sign in to comment.