File: io_spec.rb

package info (click to toggle)
ruby-hamster 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,932 kB
  • sloc: ruby: 16,915; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 591 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require "spec_helper"
require "hamster/core_ext/io"

describe IO do
  describe "#to_list" do
    let(:list) { L["A\n", "B\n", "C\n"] }
    let(:to_list) { io.to_list }

    after(:each) do
      io.close
    end

    context "with a File" do
      let(:io) { File.new(fixture_path("io_spec.txt")) }

      it "returns an equivalent list" do
        expect(to_list).to eq(list)
      end
    end

    context "with a StringIO" do
      let(:io) { StringIO.new(fixture("io_spec.txt")) }

      it "returns an equivalent list" do
        expect(to_list).to eq(list)
      end
    end
  end
end