Sha256: 3669b6dc97ae03ddfc17e960adb9a31dc3eaa26c5d46777373487ee08c95c50e

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper.rb'

describe SyntaxFix::Checker do
  before(:each) do
    @path = "#{File.expand_path('.')}/spec/fixtures"
  end

  it "fixes hash syntax when a directory is passed as path argument" do
    fixed_content = File.open("#{@path}/test/fixed_test.txt") {|f| f.read}
    checker = SyntaxFix::Checker.new
    SyntaxFix::DirFile.any_instance.should_receive(:write_file).with(fixed_content)
    checker.fix_code("#{@path}/test")
  end

  it "fixes hash syntax when a file is passed as path argument" do
    fixed_content = File.open("#{@path}/test/fixed_test.txt") {|f| f.read}
    checker = SyntaxFix::Checker.new
    SyntaxFix::DirFile.any_instance.should_receive(:write_file).with(fixed_content)
    checker.fix_code("#{@path}/test.rb")
  end

  it "does nothing when a wrong filename is passed as path argument" do
    fixed_content = File.open("#{@path}/test/fixed_test.txt") {|f| f.read}
    checker = SyntaxFix::Checker.new
    SyntaxFix::DirFile.any_instance.should_not_receive(:write_file).with(fixed_content)
    checker.fix_code("#{@path}/wrong.rb")
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
syntax_fix-0.0.4 spec/specs/checker_spec.rb