Permalink
Browse files

Merge pull request #8 from ged/master

A fix+specs for Diff::LCS::ChangeTypeTests predicates
  • Loading branch information...
halostatue committed Mar 21, 2012
2 parents 84b5236 + 7f6f229 commit 652cc334c6189fe639c5f54abecdcef2a2833b35
Showing with 73 additions and 3 deletions.
  1. +3 −3 lib/diff/lcs/change.rb
  2. +70 −0 spec/change_spec.rb
View
@@ -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
View
@@ -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

0 comments on commit 652cc33

Please sign in to comment.