Sha256: 02437eba128643348cef876b0c2eeefed7a402ace5de6a5d36c107d92861076c

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe Belajar::Test do

  it { is_expected.to respond_to :path }
  it { is_expected.to respond_to :run }

  before(:all) do
    prepare_solutions
    Belajar.config.solutions_path = solutions_basepath
  end

  let(:unit_path) { all_unit_dirs.first }
  let(:test_path) { all_test_file_paths.first }

  subject { Belajar::Test.new(unit_path) }

  it "has the appropriate path" do
    expect(subject.path).to eq test_path
  end

  describe "#run" do
    before do
      course_name = course_dir_names.first
      chapter_name = chapter_dir_names.first
      unit_name = unit_dir_names.first
      @code = available_solution(course_name, chapter_name, unit_name).code
    end

    it "returns a Belajar::TestResult" do
      expect(subject.run(@code)).to be_a Belajar::TestResult
    end

    context "when passing" do
      it "returns a passing result" do
        expect(subject.run(@code).passed?).to be_truthy
      end
    end

    context "when failing" do
      it "returns a failing result" do
        code = "print 'BYE WORLD'"
        expect(subject.run(code).passed?).to be_falsey
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belajar-0.1.1 spec/belajar/test_spec.rb