Sha256: a7fdc2936b94a5b4f7b626001f363360bf74e98e878deae6c89ec26815902e2a

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

# -*- encoding: utf-8 -*-

require './spec/helper'

describe PagesFinder do

  before :each do
    @project = ProjectCreator.new('spec/project-name', 'html_5', false)
    @project.create
    @finder = PagesFinder.new 'spec/project-name'
  end
  
  after :each do
    clean_test_repository
  end
  
  def write_file name, content
    File.open(File.join('spec/project-name', name), "w") do |file| 
      file.puts content
    end
  end

  it "should retrieve the right number of pages" do
    write_file 'pages/a.html', '<h1>a</h1>'
    write_file 'pages/b.html', '<h1>b</h1>'
    @finder.find.size.should == 3
  end
  
  it "should name the pages from the root" do
    write_file 'pages/a.html', '<h1>a</h1>'
    write_file 'pages/b.html', '<h1>b</h1>'
    list = @finder.find
    list.include?("index.html").should be_true
    list.include?("a.html").should be_true
    list.include?("b.html").should be_true
  end
  
  it "should take care of markdown files" do
    write_file 'pages/a.markdown', '#a'
    write_file 'pages/b.markdown', '#b'
    list = @finder.find
    list.size.should == 3
    list.include?("index.html").should be_true
    list.include?("a.html").should be_true
    list.include?("b.html").should be_true
  end
  
  it "should transform an array of pagenames into an array of URL strings" do
    pagenames = ['a.html', 'b.html', 'c/d.html']
    url = 'http://www.example.com'
    result = PagesFinder.pagenames2urls(pagenames, url)
    result.size.should == 3
    result.include?('http://www.example.com/a.html').should be_true
    result.include?('http://www.example.com/b.html').should be_true
    result.include?('http://www.example.com/c/d.html').should be_true
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
genit-1.0.1 spec/pages_finder_spec.rb
genit-1.0 spec/pages_finder_spec.rb