Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A fix+specs for Diff::LCS::ChangeTypeTests predicates #8

Merged
merged 1 commit into from
Mar 21, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/diff/lcs/change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def unchanged?
end

def changed?
@changed == '!'
@action == '!'
end

def finished_a?
@changed == '>'
@action == '>'
end

def finished_b?
@changed == '<'
@action == '<'
end
end

Expand Down
70 changes: 70 additions & 0 deletions spec/change_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# -*- ruby encoding: utf-8 -*-

require 'spec_helper'

describe Diff::LCS::Change do

describe "an add" do
subject { described_class.new('+', 0, 'element') }
it { should_not be_deleting() }
it { should be_adding() }
it { should_not be_unchanged() }
it { should_not be_changed() }
it { should_not be_finished_a() }
it { should_not be_finished_b() }
end

describe "a delete" do
subject { described_class.new('-', 0, 'element') }
it { should be_deleting() }
it { should_not be_adding() }
it { should_not be_unchanged() }
it { should_not be_changed() }
it { should_not be_finished_a() }
it { should_not be_finished_b() }
end

describe "an unchanged" do
subject { described_class.new('=', 0, 'element') }
it { should_not be_deleting() }
it { should_not be_adding() }
it { should be_unchanged() }
it { should_not be_changed() }
it { should_not be_finished_a() }
it { should_not be_finished_b() }
end

describe "a changed" do
subject { described_class.new('!', 0, 'element') }
it { should_not be_deleting() }
it { should_not be_adding() }
it { should_not be_unchanged() }
it { should be_changed() }
it { should_not be_finished_a() }
it { should_not be_finished_b() }
end

describe "a finished_a" do
subject { described_class.new('>', 0, 'element') }
it { should_not be_deleting() }
it { should_not be_adding() }
it { should_not be_unchanged() }
it { should_not be_changed() }
it { should be_finished_a() }
it { should_not be_finished_b() }
end

describe "a finished_b" do
subject { described_class.new('<', 0, 'element') }
it { should_not be_deleting() }
it { should_not be_adding() }
it { should_not be_unchanged() }
it { should_not be_changed() }
it { should_not be_finished_a() }
it { should be_finished_b() }
end


end

# vim: ft=ruby