Sha256: 3ca21762f9e63ca889636baf6f4aa3ddaad0c1c1e26aa26056158cf561662e13
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
require 'spec_helper' def expect_to_replace input, output [ "#{ input }", "blah #{ input }", "#{ input } blah", "blah\n#{ input }\nblah", ].each do |str| expect( Cmds.replace_shortcuts input ).to eq output end end describe 'Cmds::replace_shortcuts' do it "should replace %s with <%= arg %>" do expect_to_replace "%s", "<%= arg %>" end it "should replace %%s with %s (escaping)" do expect_to_replace "%%s", "%s" end it "should replace %%%s with %%s (escaping)" do expect_to_replace "%%%s", "%%s" end it "should replace %{key} with <%= key %>" do expect_to_replace "%{key}", "<%= key %>" end it "should replace %%{key} with %{key} (escaping)" do expect_to_replace '%%{key}', '%{key}' end it "should replace %%%{key} with %%{key} (escaping)" do expect_to_replace '%%%{key}', '%%{key}' end it "should replace %{key?} with <%= key? %>" do expect_to_replace "%{key?}", "<%= key? %>" end it "should replace %%{key?} with %{key?} (escaping)" do expect_to_replace '%%{key?}', '%{key?}' end it "should replace %%%{key?} with %%{key?} (escaping)" do expect_to_replace '%%%{key?}', '%%{key?}' end it "should replace %<key>s with <%= key %>" do expect_to_replace "%<key>s", "<%= key %>" end it "should replace %%<key>s with %<key>s (escaping)" do expect_to_replace "%%<key>s", "%<key>s" end it "should replace %%%<key>s with %%<key>s (escaping)" do expect_to_replace "%%%<key>s", "%%<key>s" end it "should replace %<key?>s with <%= key? %>" do expect_to_replace '%<key?>s', '<%= key? %>' end it "should replace %%<key?>s with %<key?>s (escaping)" do expect_to_replace '%%<key?>s', '%<key?>s' end it "should replace %%%<key?>s with %%<key?>s (escaping)" do expect_to_replace '%%%<key?>s', '%%<key?>s' end it "should not touch % that don't fit the shortcut sytax" do expect( Cmds.replace_shortcuts "50%" ).to eq "50%" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cmds-0.0.3 | spec/cmds/replace_shortcuts_spec.rb |
cmds-0.0.2 | spec/cmds/replace_shortcuts_spec.rb |
cmds-0.0.1 | spec/cmds/replace_shortcuts_spec.rb |