-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put all specs under the Treat::Specs module.
- Loading branch information
1 parent
e2b813c
commit 8b8a769
Showing
16 changed files
with
1,269 additions
and
1,231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,56 @@ | ||
describe Treat::Entities::Document do | ||
|
||
describe "Buildable" do | ||
|
||
describe "#build" do | ||
|
||
context "when supplied with a readable file name" do | ||
it "opens the file and reads its " + | ||
"content into a document" do | ||
f = Treat.paths.spec + | ||
'workers/examples/english/mathematicians/leibniz.txt' | ||
d = Treat::Entities::Document.build(f) | ||
d.should be_an_instance_of Treat::Entities::Document | ||
d.to_s.index('Gottfried Leibniz').should_not eql nil | ||
module Treat::Specs::Entities | ||
describe Treat::Entities::Document do | ||
|
||
describe "Buildable" do | ||
|
||
describe "#build" do | ||
|
||
context "when supplied with a readable file name" do | ||
it "opens the file and reads its " + | ||
"content into a document" do | ||
f = Treat.paths.spec + | ||
'workers/examples/english/mathematicians/leibniz.txt' | ||
d = Treat::Entities::Document.build(f) | ||
d.should be_an_instance_of Treat::Entities::Document | ||
d.to_s.index('Gottfried Leibniz').should_not eql nil | ||
end | ||
end | ||
end | ||
|
||
context "when supplied with a url" do | ||
it "downloads the file the URL points to and opens " + | ||
"a document with the contents of the file" do | ||
url = 'http://www.rubyinside.com/nethttp-cheat-sheet-2940.html' | ||
d = Treat::Entities::Document.build(url) | ||
d.format.should eql 'html' | ||
d.should be_an_instance_of Treat::Entities::Document | ||
d.to_s.index('Rubyist').should_not eql nil | ||
context "when supplied with a url" do | ||
it "downloads the file the URL points to and opens " + | ||
"a document with the contents of the file" do | ||
url = 'http://www.rubyinside.com/nethttp-cheat-sheet-2940.html' | ||
d = Treat::Entities::Document.build(url) | ||
d.format.should eql 'html' | ||
d.should be_an_instance_of Treat::Entities::Document | ||
d.to_s.index('Rubyist').should_not eql nil | ||
end | ||
end | ||
end | ||
|
||
context "when supplied with a url with no file extension" do | ||
it "downloads the file the URL points to and opens " + | ||
"a document with the contents of the file, assuming " + | ||
"the downloaded file to be in HTML format" do | ||
url = 'http://www.economist.com/node/21552208' | ||
d = Treat::Entities::Document.build(url) | ||
d.should be_an_instance_of Treat::Entities::Document | ||
d.to_s.index('Ronnie Lupe').should_not eql nil | ||
context "when supplied with a url with no file extension" do | ||
it "downloads the file the URL points to and opens " + | ||
"a document with the contents of the file, assuming " + | ||
"the downloaded file to be in HTML format" do | ||
url = 'http://www.economist.com/node/21552208' | ||
d = Treat::Entities::Document.build(url) | ||
d.should be_an_instance_of Treat::Entities::Document | ||
d.to_s.index('Ronnie Lupe').should_not eql nil | ||
end | ||
end | ||
end | ||
|
||
context "when called with anything else than a " + | ||
"readable file name or url" do | ||
|
||
it "raises an exception" do | ||
lambda do | ||
Treat::Entities::Document.build('nonexistent') | ||
end.should raise_error | ||
|
||
context "when called with anything else than a " + | ||
"readable file name or url" do | ||
|
||
it "raises an exception" do | ||
lambda do | ||
Treat::Entities::Document.build('nonexistent') | ||
end.should raise_error | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
end |
Oops, something went wrong.