Renamed "mocks" to "stubs", cause these things are stubs, not mocks.
This commit is contained in:
parent
9b30ec0811
commit
f559a17ba4
|
@ -2,30 +2,30 @@ require "web"
|
||||||
require "test/unit"
|
require "test/unit"
|
||||||
require "revision"
|
require "revision"
|
||||||
|
|
||||||
class MockWeb < Web;
|
class WebStub < Web;
|
||||||
attr_accessor :markup
|
attr_accessor :markup
|
||||||
def pages() MockPages.new end
|
def pages() PagesStub.new end
|
||||||
def safe_mode() false end
|
def safe_mode() false end
|
||||||
end
|
end
|
||||||
class MockPages
|
class PagesStub
|
||||||
def [](wiki_word) %w( MyWay ThatWay SmartEngine ).include?(wiki_word) end
|
def [](wiki_word) %w( MyWay ThatWay SmartEngine ).include?(wiki_word) end
|
||||||
end
|
end
|
||||||
class MockPage
|
class PageStub
|
||||||
attr_accessor :web, :revisions
|
attr_accessor :web, :revisions
|
||||||
def name() "page" end
|
def name() 'page' end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RevisionTest < Test::Unit::TestCase
|
class RevisionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@mock_page = MockPage.new
|
@page = PageStub.new
|
||||||
@mock_web = MockWeb.new
|
@web = WebStub.new
|
||||||
@mock_page.web = @mock_web
|
@page.web = @web
|
||||||
|
|
||||||
@mock_web.markup = :textile
|
@web.markup = :textile
|
||||||
|
|
||||||
@revision = Revision.new(
|
@revision = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI",
|
"HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -33,7 +33,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_auto_links = Revision.new(
|
@revision_with_auto_links = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"http://www.loudthinking.com/ points to ThatWay from david@loudthinking.com",
|
"http://www.loudthinking.com/ points to ThatWay from david@loudthinking.com",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -41,7 +41,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_aliased_links = Revision.new(
|
@revision_with_aliased_links = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"Would a [[SmartEngine|clever motor]] go by any other name?",
|
"Would a [[SmartEngine|clever motor]] go by any other name?",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -49,7 +49,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_wiki_word_in_em = Revision.new(
|
@revision_with_wiki_word_in_em = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"_should we go ThatWay or ThisWay _",
|
"_should we go ThatWay or ThisWay _",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -57,7 +57,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_pre_blocks = Revision.new(
|
@revision_with_pre_blocks = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"A <code>class SmartEngine end</code> would not mark up <pre>CodeBlocks</pre>",
|
"A <code>class SmartEngine end</code> would not mark up <pre>CodeBlocks</pre>",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -65,7 +65,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_wikiword_in_tag = Revision.new(
|
@revision_with_wikiword_in_tag = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"That is some <em style=\"WikiWord\">Stylish Emphasis</em>",
|
"That is some <em style=\"WikiWord\">Stylish Emphasis</em>",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -73,7 +73,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_autolink_in_parentheses = Revision.new(
|
@revision_with_autolink_in_parentheses = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
'The W3C body (http://www.w3c.org) sets web standards',
|
'The W3C body (http://www.w3c.org) sets web standards',
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -81,7 +81,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_link_in_parentheses = Revision.new(
|
@revision_with_link_in_parentheses = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
'Instiki is a "Wiki Clone":http://www.c2.com/cgi/wiki?WikiWikiClones ("What is a wiki?":http://wiki.org/wiki.cgi?WhatIsWiki) that\'s so easy to setup',
|
'Instiki is a "Wiki Clone":http://www.c2.com/cgi/wiki?WikiWikiClones ("What is a wiki?":http://wiki.org/wiki.cgi?WhatIsWiki) that\'s so easy to setup',
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -89,7 +89,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_image_link = Revision.new(
|
@revision_with_image_link = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
'This !http://hobix.com/sample.jpg! is a Textile image link.',
|
'This !http://hobix.com/sample.jpg! is a Textile image link.',
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -97,7 +97,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_nowiki_text = Revision.new(
|
@revision_with_nowiki_text = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
'Do not mark up <nowiki>[[this text]]</nowiki> or <nowiki>http://www.thislink.com</nowiki>.',
|
'Do not mark up <nowiki>[[this text]]</nowiki> or <nowiki>http://www.thislink.com</nowiki>.',
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -105,7 +105,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_bracketted_wiki_word = Revision.new(
|
@revision_with_bracketted_wiki_word = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
'This is a WikiWord and a tricky name [[Sperberg-McQueen]].',
|
'This is a WikiWord and a tricky name [[Sperberg-McQueen]].',
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -131,10 +131,10 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_bluecloth
|
def test_bluecloth
|
||||||
@mock_web.markup = :markdown
|
@web.markup = :markdown
|
||||||
|
|
||||||
@revision = Revision.new(
|
@revision = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"My Headline\n===========\n\n that SmartEngineGUI",
|
"My Headline\n===========\n\n that SmartEngineGUI",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -142,7 +142,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
)
|
)
|
||||||
|
|
||||||
@revision_with_code_block = Revision.new(
|
@revision_with_code_block = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
[ 'This is a code block:',
|
[ 'This is a code block:',
|
||||||
'',
|
'',
|
||||||
|
@ -164,10 +164,10 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rdoc
|
def test_rdoc
|
||||||
@mock_web.markup = :rdoc
|
@web.markup = :rdoc
|
||||||
|
|
||||||
@revision = Revision.new(
|
@revision = Revision.new(
|
||||||
@mock_page,
|
@page,
|
||||||
1,
|
1,
|
||||||
"+hello+ that SmartEngineGUI",
|
"+hello+ that SmartEngineGUI",
|
||||||
Time.local(2004, 4, 4, 16, 50),
|
Time.local(2004, 4, 4, 16, 50),
|
||||||
|
@ -214,7 +214,7 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_content_with_bracketted_wiki_word
|
def test_content_with_bracketted_wiki_word
|
||||||
@mock_web.brackets_only = true
|
@web.brackets_only = true
|
||||||
assert_equal '<p>This is a WikiWord and a tricky name <span class="newWikiWord">Sperberg-McQueen<a href="../show/Sperberg-McQueen">?</a></span>.</p>', @revision_with_bracketted_wiki_word.display_content
|
assert_equal '<p>This is a WikiWord and a tricky name <span class="newWikiWord">Sperberg-McQueen<a href="../show/Sperberg-McQueen">?</a></span>.</p>', @revision_with_bracketted_wiki_word.display_content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -247,8 +247,8 @@ class RevisionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_revisions_diff
|
def test_revisions_diff
|
||||||
page = MockPage.new
|
page = PageStub.new
|
||||||
web = MockWeb.new
|
web = WebStub.new
|
||||||
web.markup = :textile
|
web.markup = :textile
|
||||||
page.web = web
|
page.web = web
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue