diff options
Diffstat (limited to 'spec/ruby/library/tempfile')
| -rw-r--r-- | spec/ruby/library/tempfile/delete_spec.rb | 12 | ||||
| -rw-r--r-- | spec/ruby/library/tempfile/length_spec.rb | 5 | ||||
| -rw-r--r-- | spec/ruby/library/tempfile/shared/length.rb | 21 | ||||
| -rw-r--r-- | spec/ruby/library/tempfile/shared/unlink.rb | 12 | ||||
| -rw-r--r-- | spec/ruby/library/tempfile/size_spec.rb | 21 | ||||
| -rw-r--r-- | spec/ruby/library/tempfile/unlink_spec.rb | 5 |
6 files changed, 35 insertions, 41 deletions
diff --git a/spec/ruby/library/tempfile/delete_spec.rb b/spec/ruby/library/tempfile/delete_spec.rb index 0332b44dde..b126ceae6a 100644 --- a/spec/ruby/library/tempfile/delete_spec.rb +++ b/spec/ruby/library/tempfile/delete_spec.rb @@ -1,7 +1,15 @@ require_relative '../../spec_helper' -require_relative 'shared/unlink' require 'tempfile' describe "Tempfile#delete" do - it_behaves_like :tempfile_unlink, :delete + before :each do + @tempfile = Tempfile.new("specs") + end + + it "unlinks self" do + @tempfile.close + path = @tempfile.path + @tempfile.delete + File.should_not.exist?(path) + end end diff --git a/spec/ruby/library/tempfile/length_spec.rb b/spec/ruby/library/tempfile/length_spec.rb index bc622b9a70..924c12942b 100644 --- a/spec/ruby/library/tempfile/length_spec.rb +++ b/spec/ruby/library/tempfile/length_spec.rb @@ -1,7 +1,8 @@ require_relative '../../spec_helper' -require_relative 'shared/length' require 'tempfile' describe "Tempfile#length" do - it_behaves_like :tempfile_length, :length + it "is an alias of Tempfile#size" do + Tempfile.instance_method(:length).should == Tempfile.instance_method(:size) + end end diff --git a/spec/ruby/library/tempfile/shared/length.rb b/spec/ruby/library/tempfile/shared/length.rb deleted file mode 100644 index 1a89ff7b4d..0000000000 --- a/spec/ruby/library/tempfile/shared/length.rb +++ /dev/null @@ -1,21 +0,0 @@ -describe :tempfile_length, shared: true do - before :each do - @tempfile = Tempfile.new("specs") - end - - after :each do - @tempfile.close! - end - - it "returns the size of self" do - @tempfile.send(@method).should.eql?(0) - @tempfile.print("Test!") - @tempfile.send(@method).should.eql?(5) - end - - it "returns the size of self even if self is closed" do - @tempfile.print("Test!") - @tempfile.close - @tempfile.send(@method).should.eql?(5) - end -end diff --git a/spec/ruby/library/tempfile/shared/unlink.rb b/spec/ruby/library/tempfile/shared/unlink.rb deleted file mode 100644 index e821228d70..0000000000 --- a/spec/ruby/library/tempfile/shared/unlink.rb +++ /dev/null @@ -1,12 +0,0 @@ -describe :tempfile_unlink, shared: true do - before :each do - @tempfile = Tempfile.new("specs") - end - - it "unlinks self" do - @tempfile.close - path = @tempfile.path - @tempfile.send(@method) - File.should_not.exist?(path) - end -end diff --git a/spec/ruby/library/tempfile/size_spec.rb b/spec/ruby/library/tempfile/size_spec.rb index f4824601c7..5a7edf8e4b 100644 --- a/spec/ruby/library/tempfile/size_spec.rb +++ b/spec/ruby/library/tempfile/size_spec.rb @@ -1,7 +1,24 @@ require_relative '../../spec_helper' -require_relative 'shared/length' require 'tempfile' describe "Tempfile#size" do - it_behaves_like :tempfile_length, :size + before :each do + @tempfile = Tempfile.new("specs") + end + + after :each do + @tempfile.close! + end + + it "returns the size of self" do + @tempfile.size.should.eql?(0) + @tempfile.print("Test!") + @tempfile.size.should.eql?(5) + end + + it "returns the size of self even if self is closed" do + @tempfile.print("Test!") + @tempfile.close + @tempfile.size.should.eql?(5) + end end diff --git a/spec/ruby/library/tempfile/unlink_spec.rb b/spec/ruby/library/tempfile/unlink_spec.rb index eac7df8472..c03fc34a54 100644 --- a/spec/ruby/library/tempfile/unlink_spec.rb +++ b/spec/ruby/library/tempfile/unlink_spec.rb @@ -1,7 +1,8 @@ require_relative '../../spec_helper' -require_relative 'shared/unlink' require 'tempfile' describe "Tempfile#unlink" do - it_behaves_like :tempfile_unlink, :unlink + it "is an alias of Tempfile#delete" do + Tempfile.instance_method(:unlink).should == Tempfile.instance_method(:delete) + end end |
