summaryrefslogtreecommitdiff
path: root/spec/ruby/core/dir/pos_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/dir/pos_spec.rb')
-rw-r--r--spec/ruby/core/dir/pos_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/ruby/core/dir/pos_spec.rb b/spec/ruby/core/dir/pos_spec.rb
new file mode 100644
index 0000000000..1e364fbe3c
--- /dev/null
+++ b/spec/ruby/core/dir/pos_spec.rb
@@ -0,0 +1,53 @@
+require_relative '../../spec_helper'
+require_relative 'fixtures/common'
+require_relative 'shared/closed'
+require_relative 'shared/pos'
+
+describe "Dir#pos" do
+ before :all do
+ DirSpecs.create_mock_dirs
+ end
+
+ after :all do
+ DirSpecs.delete_mock_dirs
+ end
+
+ it_behaves_like :dir_closed, :pos
+
+ before :each do
+ @dir = Dir.open DirSpecs.mock_dir
+ end
+
+ after :each do
+ @dir.close rescue nil
+ end
+
+ it "returns an Integer representing the current position in the directory" do
+ @dir.pos.should.is_a?(Integer)
+ @dir.pos.should.is_a?(Integer)
+ @dir.pos.should.is_a?(Integer)
+ end
+
+ it "returns a different Integer if moved from previous position" do
+ a = @dir.pos
+ @dir.read
+ b = @dir.pos
+
+ a.should.is_a?(Integer)
+ b.should.is_a?(Integer)
+
+ a.should_not == b
+ end
+end
+
+describe "Dir#pos=" do
+ before :all do
+ DirSpecs.create_mock_dirs
+ end
+
+ after :all do
+ DirSpecs.delete_mock_dirs
+ end
+
+ it_behaves_like :dir_pos_set, :pos=
+end