Sha256: d942d0ad6f595c8631a307563134c3f78917459ba37a43e23976451afea1c873

Contents?: true

Size: 961 Bytes

Versions: 2

Compression:

Stored size: 961 Bytes

Contents

require "open3"
require "#{ENV['HOME']}/.ruby_learner/workshop/lib/workplace.rb"

filename = "#{ENV['HOME']}/.ruby_learner/workshop/lib/workplace.rb"
check_method = false

RSpec.describe "STDIN-check" do
  it 'check case-method, return boolean' do
    File.open(filename, "r") do |file|
      file.each_line do |line|
        check_method = true if line.include?('case')
      end
    end
    puts "Message: you don't use case-methods." if !check_method
    expect( check_method ).to eq(true)
  end
  it 'given Japan, return "こんにちは\n"' do
    allow(STDIN).to receive(:gets) { "Japan\n" }
    expect { gree() }.to output("こんにちは\n").to_stdout
  end
  it 'given USA, return "Hello\n"' do
    allow(STDIN).to receive(:gets) { "USA\n" }
    expect { gree() }.to output("Hello\n").to_stdout
  end
  it 'given Italy, return "else\n"' do
    allow(STDIN).to receive(:gets) { "Italy\n" }
    expect { gree() }.to output("else").to_stdout
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_learner-1.2.0 contents/questions/sequential_check/section_4/part_3/spec/workplace_spec.rb
ruby_learner-1.1.15 questions/sequential_check/section_4/part_3/spec/workplace_spec.rb