Skip to content
This repository has been archived by the owner on Dec 28, 2017. It is now read-only.

Commit

Permalink
renamed CheckEpub class/file to EpubCheck (echoing the tool) - this s…
Browse files Browse the repository at this point in the history
…eems to make more sense
  • Loading branch information
Mike Cook committed Nov 1, 2011
1 parent 4eb1ee0 commit 149a429
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/epub_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module EpubValidator
def self.check_file(filename)
CheckEpub.new(filename)
EpubCheck.new(filename)
end
end

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module EpubValidator
class CheckEpub
class EpubCheck
attr_accessor :message

def initialize(filename)
Expand Down
15 changes: 10 additions & 5 deletions spec/epub_validator/check_epub_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
require 'spec_helper'

module EpubValidator
describe CheckEpub do
describe EpubCheck do
context "when initialized" do
it "will return an instance of EpubCheck" do
EpubCheck.new('test.epub').should be_kind_of(EpubCheck)
end
end
context "when it tries to process a missing file" do
it "should return missing file error message" do
failed_message = 'FAILED!\n\nNo .epub file to check was specified in arguments!\n\nThe tool will EXIT!'
ce = CheckEpub.new('test.epub')
CheckEpub.any_instance.stub(:process_epub).and_return(failed_message)
ce = EpubCheck.new('test.epub')
EpubCheck.any_instance.stub(:process_epub).and_return(failed_message)
ce.process_epub.should eq(failed_message)
end
end
context "when it processes a valid file" do
it "should return 'Passed.' message as an array" do
success_message = "Epubcheck Version 1.2\n\nNo errors or warnings detected\n"
ce = CheckEpub.new('test.epub')
ce = EpubCheck.new('test.epub')
ce.format_epubcheck_message(success_message).should eq(['Passed.'])
end
end
context "when it processes an invalid file" do
it "should return error message as an array" do
failed_message = "Epubcheck Version 1.2\n\nERROR: book.epub: resource OEBPS/stylesheets/handbookish.css is missing\n\nCheck finished with warnings or errors!"
formatted_failed_message = ["FAILED!", "ERROR: book.epub: resource OEBPS/stylesheets/handbookish.css is missing"]
ce = CheckEpub.new('test.epub')
ce = EpubCheck.new('test.epub')
ce.format_epubcheck_message(failed_message).should eq(formatted_failed_message)
end
end
Expand Down

0 comments on commit 149a429

Please sign in to comment.