Skip to content

Commit 2614b86

Browse files
committed
Refactor further, getting rid of the concern
1 parent ab11707 commit 2614b86

6 files changed

Lines changed: 12 additions & 26 deletions

File tree

lib/us_news_rankings/annual_list.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
module UsNewsRankings
44
class AnnualList
5-
attr_reader :category, :year
5+
attr_reader :year
66

7-
def initialize(category:, year:)
8-
@category = category
7+
def initialize(year)
98
@year = year
109
end
1110

11+
def category
12+
self.class.name.gsub("AnnualList","Category").constantize.new
13+
end
14+
1215
def html_dir
1316
File.join("./web/#{category.namespace_path}", year.to_s)
1417
end

lib/us_news_rankings/category_awareness.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

lib/us_news_rankings/education/graduate_schools/law/annual_list.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Education
33
module GraduateSchools
44
module Law
55
class AnnualList < UsNewsRankings::AnnualList
6-
include CategoryAwareness
76
end
87
end
98
end

lib/us_news_rankings/education/graduate_schools/law_clinical/annual_list.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Education
33
module GraduateSchools
44
module LawClinical
55
class AnnualList < UsNewsRankings::AnnualList
6-
include CategoryAwareness
76
end
87
end
98
end

lib/us_news_rankings/education/graduate_schools/law_part_time/annual_list.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Education
33
module GraduateSchools
44
module LawPartTime
55
class AnnualList < UsNewsRankings::AnnualList
6-
include CategoryAwareness
76
end
87
end
98
end

spec/annual_list_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
RSpec.describe UsNewsRankings::AnnualList do
2+
let(:category){ UsNewsRankings::Education::GraduateSchools::LawClinical::Category.new }
23
let(:annual_list){ UsNewsRankings::Education::GraduateSchools::LawClinical::AnnualList.new(2017) }
34

45
describe "#source_urls" do
56
before(:each) do
6-
allow(annual_list.category).to receive(:source_urls).and_return(
7+
allow(category).to receive(:source_urls).and_return(
78
{
8-
2017=>["www.google.com/2017"],
9-
2016=>["www.google.com/2016"]
9+
2017=>["www.google.com/2017", "www.google.com/2017?page=2", "www.google.com/2017?page=3"],
10+
2016=>["www.google.com/2016", "www.google.com/2016?page=2"]
1011
}
1112
)
13+
allow(annual_list).to receive(:category).and_return(category)
1214
end
1315

1416
it "should return an array of urls for the given year" do
15-
expect(annual_list.source_urls).to eql(["www.google.com/2017"])
17+
expect(annual_list.source_urls).to match_array(["www.google.com/2017", "www.google.com/2017?page=2", "www.google.com/2017?page=3"])
1618
end
1719
end
1820

0 commit comments

Comments
 (0)