Sha256: 92dccc64d86ae043b5880714aa67b1284e16766cf973f6e542218dfea8c5ca7d

Contents?: true

Size: 926 Bytes

Versions: 1

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

require "stashify/properties"

RSpec.shared_context "file setup" do |property_count|
  around(:each) do |s|
    property_of { [path, string] }.check(property_count) do |path, contents|
      @path = path
      @contents = contents
      s.run
    end
  end

  let(:path) { @path }
  let(:contents) { @contents }
  let(:property_count) { property_count }
end

RSpec.shared_examples "a file" do
  it "sets the name" do
    expect(subject.name).to eq(File.basename(path))
  end

  it "reads the contents" do
    expect(subject.contents).to eq(contents)
  end

  it "writes new contents" do
    property_of { file_name }.check(property_count) do |new_contents|
      subject.write(new_contents)
      expect(subject.contents).to eq(new_contents)
    end
  end

  it "deletes the file" do
    expect(subject.exists?).to be_truthy
    subject.delete
    expect(subject.exists?).to be_falsey
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stashify-contract-1.0.0 lib/stashify/contract/file_contract.rb