Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions spec/soundfile_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "./spec_helper"
require "tempfile"
require "./../../soundfile/src/soundfile.cr"

include SoundFile
Expand All @@ -11,6 +10,13 @@ describe SFile do
int = Array(Int32).new
float = Array(Float32).new
double = Array(Float64).new


it "Test File should open" do
File.open(test_wav, "r") do |f|
f.fd.should_not eq(-1)
end
end

it "is a Class" do
SFile.is_a?(Class).should eq(true)
Expand All @@ -33,7 +39,7 @@ describe SFile do
b.info.should eq(a.info)
b.close
end

describe "#open" do
it "returns false when opening a non-existing file for read" do
a.open("invalid.wav", :read).should eq false
Expand Down Expand Up @@ -71,13 +77,16 @@ describe SFile do
end

describe "#open_fd" do
File.open(test_wav, "r") do |f|
it "can open a file given a file descriptor" do
it "can open a file given a file descriptor" do
File.open(test_wav, "r") do |f|
f.fd.should_not eq(-1)
a.open_fd(f.fd, :read).should be_true
a.close
end
end

it "can be invoked with a block" do
it "can be invoked with a block" do
File.open(test_wav, "r") do |f|
a.open_fd(f.fd, :read) do |sf|
sf.class.should eq SFile
sf.info.class.should eq SFile.info.class
Expand All @@ -87,15 +96,16 @@ describe SFile do
end

describe "#open_file" do
File.open(test_wav, "r") do |f|
it "can open a file given a file object" do
it "can open a file given a file object" do
File.open(test_wav, "r") do |f|
a.open_file(f, :read).should be_true
a.close
end
end

File.open(test_wav, "r") do |f|
it "can be invoked with a block" do
it "can be invoked with a block" do
File.open(test_wav, "r") do |f|

a.open_file(f, :read) do |sf|
sf.class.should eq SFile
sf.info.class.should eq SFile.info.class
Expand Down
Loading