Sha256: 659e87ff78c3d1d67fef1b84f2c48db0bca2a171d597d4f3e145592299d17f95
Contents?: true
Size: 907 Bytes
Versions: 11
Compression:
Stored size: 907 Bytes
Contents
require "open3" is_array1_method = false is_array3_method = false workshop = "#{ENV['HOME']}/.ruby_learner/workshop" filename = "#{workshop}/lib/workplace.rb" RSpec.describe "Array-check" do it 'check loop-method, return boolean' do File.open(filename, "r") do |file| file.each_line do |line| is_array1_method = true if line.include?('nums[1]') is_array3_method = true if line.include?('nums[3]') end end puts "ErrorMessage: you don't use nums[1]-method." if !is_array1_method puts "ErrorMessage: you don't use nums[3]-method." if !is_array3_method expect( is_array1_method ).to eq(true) expect( is_array3_method ).to eq(true) end it 'return [1, 5, 3, 7, 5]\n[1, 2, 3, 4, 5]\n' do stdout, stderr, status = Open3.capture3("ruby #{filename}") expect { puts stdout }.to output("[1, 5, 3, 7, 5]\n[1, 2, 3, 4, 5]\n").to_stdout end end
Version data entries
11 entries across 11 versions & 1 rubygems