Sha256: 07f47f932cfad81b4f4e16efb46bd19fab03dbe7b309fdfe8df0c286b222bdf4

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

shared "Clean" do
  
  extend Checked::Clean::DSL

end # === shared 

describe "Clean :chop_ext" do
  
  behaves_like 'Clean'
  
  it "should chop off the extension of a file string: /etc/something.txt" do
    clean("/etc/something.txt", :chop_ext).should == '/etc/something'
  end
  
  it "should chop off the extension of a file string: /etc/something.rb" do
    clean("/etc/something.rb", :chop_rb).should == '/etc/something'
  end
  
  it "should not chop off a non-.rb extension for :chop_rb" do
    clean("/etc/something.rbs", :chop_rb).should == '/etc/something.rbs'
  end
  
  it "should not chop off an extension if it has not" do
    clean("/etc/something", :chop_rb).should == '/etc/something'
  end
  
  it "should not chop off an extension if it includes '.' in a dir: /etc/rc.d/x-something" do
    clean("/etc/rc.d/x-something", :chop_rb).should == '/etc/rc.d/x-something'
  end
  
end # === describe

describe "Clean :ruby_name" do
  
  behaves_like 'Clean'
  
  it 'should return the basename without .rb' do
    clean("/dir/some.path/String.rb", :ruby_name).should.be == 'String'
  end
  
  it 'should be the equivalent to :chop_rb if it is just a filename without a dir' do
    clean("String.rb", :ruby_name).should.be == 'String'
  end
  
end # === describe :ruby_name

describe "Clean :chop_slash_r" do
  
  behaves_like 'Clean'
  
  it "should remove all instances of \\r" do
    string = %@ 
      Hi\r\n
      Ok\r\n
    @
    clean(string, :chop_slash_r).should.be == string.gsub("\r", '')
  end
  
  
end # === describe :chop_slash_r


describe "Clean :os_stardard" do
  
  behaves_like 'Clean'
  
  it "should remove all \\r and strip" do
    string = %@ 
      Hi\r\n
      Ok\r\n
    @
    clean(string, :os_stardard).should.be == string.strip.gsub("\r", '')
  end
  
end # === describe

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
Checked-0.1.4 spec/tests/Clean_Strings.rb
Checked-0.1.3 spec/tests/Clean_Strings.rb
Checked-0.1.2 spec/tests/Clean_Strings.rb
Checked-0.1.1 spec/tests/Clean_Strings.rb
Checked-0.1.0 spec/tests/Clean_Strings.rb