Sha256: d058d099fb2097f984d28c9a9e3c3794f4b975a2a2379e7792290a09df1821df

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

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

require './spec/helper'

describe ClassNewsTag do

  after :all do
    clean_test_repository
  end
  
  def create_sample_project
    FileUtils.makedirs('spec/project-name/news')
    File.open('spec/project-name/news/2011-01-01.html', "w") {|out| out.puts '<h1>2011-01-01</h1>' }
    File.open('spec/project-name/news/2011-02-02.html', "w") {|out| out.puts '<h1>2011-02-02</h1>' }
  end

  it "should replace all news" do
    create_sample_project
    template = Nokogiri::XML.fragment '<genit class="news"/>'
    tag = {'class' => 'news'}
    cnt = ClassNewsTag.new 'spec/project-name', template, 'mock', tag
    doc = cnt.process
    doc.css('h1').size.should == 2
  end
  
  it "should replace X news" do
    create_sample_project
    template = Nokogiri::XML.fragment '<genit class="news" number="1"/>'
    tag = {'class' => 'news', 'number' => '1'}
    cnt = ClassNewsTag.new 'spec/project-name', template, 'mock', tag
    doc = cnt.process
    doc.css('h1').size.should == 1
    doc.css('h1').inner_html.should == '2011-02-02'
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
genit-1.0.1 spec/class_news_tag_spec.rb
genit-1.0 spec/class_news_tag_spec.rb
genit-0.99 spec/class_news_tag_spec.rb
genit-0.9 spec/class_news_tag_spec.rb