Class: WebTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
app/models/web_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



5
6
7
# File 'app/models/web_test.rb', line 5

def setup
  @web = Web.new "Pimki", "pimki"
end

#test_deleteObject



41
42
43
44
45
46
# File 'app/models/web_test.rb', line 41

def test_delete
  add_sample_pages
  assert_equal 2, @web.pages.length
  @web.remove_pages([ @web.pages["EverBeenInLove"] ])
  assert_equal 1, @web.pages.length
end

#test_pages_by_matchObject



28
29
30
31
32
33
# File 'app/models/web_test.rb', line 28

def test_pages_by_match
  add_sample_pages
  assert_equal 2, @web.select { |page| page.content =~ /me/i }.length
  assert_equal 1, @web.select { |page| page.content =~ /Who/i }.length
  assert_equal 0, @web.select { |page| page.content =~ /none/i }.length
end

#test_pages_by_revisionObject



23
24
25
26
# File 'app/models/web_test.rb', line 23

def test_pages_by_revision
  add_sample_pages
  assert_equal "EverBeenHated", @web.select.by_revision.first.name
end

#test_referencesObject



35
36
37
38
39
# File 'app/models/web_test.rb', line 35

def test_references
  add_sample_pages
  assert_equal 1, @web.select.pages_that_reference("EverBeenHated").length
  assert_equal 0, @web.select.pages_that_reference("EverBeenInLove").length
end

#test_wiki_word_linkingObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/web_test.rb', line 9

def test_wiki_word_linking
  @web.add_page(Page.new(@web, "SecondPage", "Yo, yo. Have you EverBeenHated", Time.now, "DavidHeinemeierHansson"))
  assert_equal(
    "<p>Yo, yo. Have you <span class=\"newWikiWord\">Ever Been Hated<a href=\"../show/EverBeenHated\">?</a></span></p>",
    @web.pages["SecondPage"].display_content
  )
  
  @web.add_page(Page.new(@web, "EverBeenHated", "Yo, yo. Have you EverBeenHated", Time.now, "DavidHeinemeierHansson"))
  assert_equal(
    "<p>Yo, yo. Have you <a class=\"existingWikiWord\" href=\"../show/EverBeenHated\">Ever Been Hated</a></p>", 
    @web.pages["SecondPage"].display_content
  )
end