Skip to content
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
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: ruby
sudo: false
cache: bundler
rvm:
- 2.0.0
- 2.1.10
script: bundle exec rspec
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ gemspec
gem "pry"
gem "yard"
gem "redcarpet"
gem "rspec", "~> 3.5.0"
gem "rake", "~> 12.0"
8 changes: 2 additions & 6 deletions hyp_diff.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ HypDiff compares HTML snippets. It generates a diff between two input snippets.
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency "nokogiri", "~> 1.6.5"
spec.add_dependency "diff-lcs", "~> 1.2.5"

spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "rspec", "~> 2.14.1"
spec.add_development_dependency "rake", "~> 10.1"
spec.add_dependency "nokogiri", "~> 1.6", ">= 1.6.5"
spec.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.5"
end
17 changes: 10 additions & 7 deletions spec/hyp_diff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe HypDiff do

def expect_diff(old, new, expected)
HypDiff.compare(old, new).should == expected
expect(HypDiff.compare(old, new)).to eq(expected)
end

it "diffs two texts, applying tags to indicate changes" do
Expand Down Expand Up @@ -69,33 +69,36 @@ def expect_diff(old, new, expected)

describe "with callbacks for custom markup" do
it "uses them to generate the insertions and deletions" do
HypDiff.compare(
expect(HypDiff.compare(
"byebye world",
"hello world",
render_insertion: proc { |html| "<new>#{html}</new>" },
render_deletion: proc { |html| "<old>#{html}</old>" }
).should ==
)).to eq(
"<old>byebye</old><new>hello</new> world"
)
end
end

describe "choosing which markup to use" do
it "allows to choose 'after'" do
HypDiff.compare(
expect(HypDiff.compare(
"<b>byebye world</b>",
"<i>hello world</i>",
markup_from: "after"
).should ==
)).to eq(
"<i><del>byebye</del><ins>hello</ins> world</i>"
)
end

it "allows to choose 'before'" do
HypDiff.compare(
expect(HypDiff.compare(
"<b>byebye world</b>",
"<i>hello world</i>",
markup_from: "before"
).should ==
)).to eq(
"<b><del>byebye</del><ins>hello</ins> world</b>"
)
end
end

Expand Down
12 changes: 6 additions & 6 deletions spec/text_from_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ module HypDiff
let(:other_text_same_node) { TextFromNode.new("eggs", node) }

it "equals other instance when text is equal" do
subject.should == same_text_other_node
subject.should be_eql(same_text_other_node)
expect(subject).to eq(same_text_other_node)
expect(subject).to be_eql(same_text_other_node)

subject.should_not == other_text_same_node
subject.should_not be_eql(other_text_same_node)
expect(subject).not_to eq(other_text_same_node)
expect(subject).not_to be_eql(other_text_same_node)
end

it "provides a sane hash implementation" do
subject.hash.should == same_text_other_node.hash
subject.hash.should_not == other_text_same_node.hash
expect(subject.hash).to eq(same_text_other_node.hash)
expect(subject.hash).not_to eq(other_text_same_node.hash)
end

end
Expand Down