require 'rails_helper'

describe TargetFile::FileWithBuilder do
  it "works without resource" do
    file = described_class.generate!
    file.should_not have_log_entries /ERROR/
    file.original_file.read.should eq "one,two\n"
  end

  it "allows to add a resource to the generate command" do
    user = create :user
    file1 = described_class.generate! user
    file1.should_not have_log_entries /ERROR/
    file1.original_file.read.should eq "one,two\nUser,#{user.id}\n"

    wi = create 'workflow_instance/scenario2'
    file2 = described_class.generate! wi
    file2.should_not have_log_entries /ERROR/
    file2.original_file.read.should eq "one,two\nWorkflowInstance::Scenario2,#{wi.id}\n"
  end
end
