Sha256: aadb72f01882715cb805726fca04e628fad621aa1a6fe80790c7d95fa2be9f5c

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

RSpec.describe SubDiff::Diff do
  let(:diff)                   { described_class.new(value, value_was) }
  let(:diff_without_value_was) { described_class.new(value) }
  let(:diff_with_empty_values) { described_class.new('', '') }

  let(:value)     { 'test' }
  let(:value_was) { 'testing' }

  describe '#changed?' do
    it 'should return true if value does not match value_was' do
      expect(diff).to be_changed
    end

    it 'should return false if value matches value_was' do
      expect(diff_without_value_was).not_to be_changed
      expect(diff_with_empty_values).not_to be_changed
    end
  end

  describe '#empty?' do
    it 'should return false if the diff was changed' do
      expect(diff).not_to be_empty
    end

    it 'should return false if the diff value is not empty' do
      expect(diff_without_value_was).not_to be_empty
    end

    it 'should return true if the diff was not changed and is empty' do
      expect(diff_with_empty_values).to be_empty
    end
  end

  describe '#value' do
    it 'should return the diff value' do
      expect(diff.value).to eq(value)
    end
  end

  describe '#value_was' do
    it 'should accept value_was' do
      expect(diff.value_was).to eq(value_was)
    end

    it 'should set value_was to value if it is not specified' do
      expect(diff_without_value_was.value_was).to eq(value)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sub_diff-1.1.1 spec/sub_diff/diff_spec.rb
sub_diff-1.1.0 spec/sub_diff/diff_spec.rb
sub_diff-1.0.7 spec/sub_diff/diff_spec.rb
sub_diff-1.0.6 spec/sub_diff/diff_spec.rb
sub_diff-1.0.5 spec/sub_diff/diff_spec.rb
sub_diff-1.0.4 spec/sub_diff/diff_spec.rb
sub_diff-1.0.3 spec/sub_diff/diff_spec.rb
sub_diff-1.0.2 spec/sub_diff/diff_spec.rb