From 38db0dd000fd62b77be6fdc0b66014bf3e238ebd Mon Sep 17 00:00:00 2001 From: Nemo Date: Tue, 30 Jun 2020 16:50:49 +0530 Subject: [PATCH] Adds tests for page detection --- spec/issue_spec.cr | 24 ++++++++++++++++++++++++ src/article.cr | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/spec/issue_spec.cr b/spec/issue_spec.cr index 2809dd1..5a42f69 100644 --- a/spec/issue_spec.cr +++ b/spec/issue_spec.cr @@ -57,5 +57,29 @@ describe Muse::Dl::Issue do issue.info["Open Access"].should eq "Yes" issue.title.should eq "Volume 1, Issue 2, 2016" issue.journal_title.should eq "Constitutional Studies" + + expected_pages = [ + [1, 22], + [23, 40], + [41, 58], + [59, 80], + [81, 95], + [97, 116], + ] + + expected_titles = [ + "The Limits of Veneration: Public Support for a New Constitutional Convention", + "Secession and Nullification as a Global Trend", + "Challenging Constitutionalism in Post-Apartheid South Africa", + "Democracy by Lawsuit: Or, Can Litigation Alleviate the European Union’s “Democratic Deficit?”", + "Private Enforcement of Constitutional Guarantees in the Ku Klux Act of 1871", + "Sober Second Thoughts: Evaluating the History of Horizontal Judicial Review by the U.S. Supreme Court", + ] + + issue.articles.each_with_index do |a, i| + a.start_page.should eq expected_pages[i][0] + a.end_page.should eq expected_pages[i][1] + a.title.should eq expected_titles[i] + end end end diff --git a/src/article.cr b/src/article.cr index ef9377f..64a7c39 100644 --- a/src/article.cr +++ b/src/article.cr @@ -3,7 +3,7 @@ require "./issue.cr" module Muse::Dl class Article - getter id : String + getter id : String, :start_page, :end_page, :title setter title : String | Nil, start_page : Int32 | Nil, end_page : Int32 | Nil def initialize(id : String)