Sha256: 1f2e7d163df220126ea083760ddafec88fb72686f78fa4f69ba4246aca2c3dc1
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
require 'spec_helper' describe TextInjector do before(:each) do @file = "tmp/test.txt" FileUtils.cp("spec/fixtures/test.txt", @file) @content = "added content" end after(:each) do FileUtils.rm_f(@file) end let(:injector) do TextInjector.new( :mute => true, :file => @file, :tmp_file => @tmp_file, :identifier => @identifier, :content => @content ) end describe "new file" do it "should create new file with markers" do @file = "tmp/new-file.txt" injector.run data = IO.read(@file) data.should include "added content" data.should match(/Begin TextInjector marker for/) data.should match(/End TextInjector marker for/) end end describe "existing file" do it "should update text" do injector.run data = IO.read(@file) data.should include('added content') injector.content = "updated content" injector.run data = IO.read(@file) data.should_not include("added content") data.should include("updated content") end it "should include markers" do injector.run data = IO.read(@file) data.should match(/Begin TextInjector marker for/) data.should match(/End TextInjector marker for/) end it "should use custom-id for markers" do @identifier = "custom-id" injector.run data = IO.read(@file) data.should match(/Begin TextInjector marker for custom-id/) data.should match(/End TextInjector marker for custom-id/) puts data if ENV['DEBUG'] data.should == <<-EOL test file # Begin TextInjector marker for custom-id added content # End TextInjector marker for custom-id EOL end it "should create temp file" do @tmp_file = true injector.run File.exist?(injector.tmp_path).should be_true FileUtils.rm_f(injector.tmp_path) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
text_injector-0.0.4 | spec/lib/text_injector_spec.rb |