Skip to content

Commit

Permalink
Tests set up for moving rendering to Liquid
Browse files Browse the repository at this point in the history
In preparation for working on #57, I set up a couple tests that look at
the output of rendering a page. This'll be useful.
  • Loading branch information
irisfofs committed Jan 15, 2016
1 parent a841362 commit 493e259
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions jekyll-rp_logs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.8"
spec.add_development_dependency "nokogiri", "~> 1.6"
spec.add_development_dependency "rspec", "~> 3"
spec.add_development_dependency "simplecov", "~> 0.9"
spec.add_development_dependency "codeclimate-test-reporter"
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/rp_logs/rp_log_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def convert_all_pages(site, main_index, arc_index, rp_pages)
# Skip if something goes wrong
next unless convert_rp(site, page)

key = page[:canon] ? "canon" : "noncanon"
key = page.canon
# Add key for canon/noncanon
main_index.data["rps"][key] << page
# Add tag for canon/noncanon
Expand Down
4 changes: 4 additions & 0 deletions lib/jekyll/rp_logs/rp_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def tag_strings
tags.map(&:to_s)
end

def canon
self[:canon] ? "canon" : "noncanon"
end

def convert_rp(parsers)
compiled_lines = convert_all_lines(parsers)

Expand Down
26 changes: 24 additions & 2 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "jekyll/rp_logs"
require "jekyll/rp_logs/rp_log_converter"

require "nokogiri"
require "rake"
require "yaml"

Expand All @@ -12,9 +13,9 @@

module Jekyll
module RpLogs
DEFAULT_CONFIGURATION = Util.gross_setup_stuff

RSpec.describe "Integration Tests" do
DEFAULT_CONFIGURATION = Util.gross_setup_stuff

before(:all) do
Dir.chdir("dev_site") do
site = Jekyll::Site.new(DEFAULT_CONFIGURATION)
Expand Down Expand Up @@ -45,6 +46,27 @@ module RpLogs
end
end
end

describe "a rendered RP" do
subject do
fn = File.join("dev_site", "_site", "test_disable_liquid", "index.html")
content = File.open(fn) { |f| Nokogiri::HTML(f) }
content.at_css("p.rp > a")
end

it "has the correct timestamp attributes" do
name = "2015-07-08_01:55:00"
title = "01:55:00 July 8, 2015"
expect(subject.attributes["name"].value).to eq name
expect(subject.attributes["title"].value).to eq title
expect(subject.attributes["href"].value).to eq "##{name}"
end

it "has the right text" do
text = " * Alice lorem ipsum dolor sit amet, consectetur adipisicing elit. Sequi voluptatibus, quis ratione sit porro vitae, placeat, quos rem quaerat autem voluptates tempore officiis praesentium ipsum distinctio tempora voluptatum veritatis unde."
expect(subject.next_sibling.text).to eq text
end
end
end

describe "the existing rp pages" do
Expand Down
4 changes: 2 additions & 2 deletions spec/rp_log_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

module Jekyll
module RpLogs
DEFAULT_CONFIGURATION = Util.gross_setup_stuff

RSpec.describe RpLogGenerator do
DEFAULT_CONFIGURATION = Util.gross_setup_stuff

let(:site) do
Dir.chdir("dev_site") do
site = Jekyll::Site.new(DEFAULT_CONFIGURATION)
Expand Down

0 comments on commit 493e259

Please sign in to comment.