Skip to content

Commit

Permalink
updated minitest and minitest-reporter gems and removed deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Oct 6, 2019
1 parent 6a62de5 commit af0f189
Show file tree
Hide file tree
Showing 29 changed files with 774 additions and 821 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -4,7 +4,7 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# test
gem 'rake'
gem 'minitest'
gem 'minitest', '~> 5.12'
gem 'minitest-reporters'
gem 'rack'
gem 'i18n'
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Expand Up @@ -213,8 +213,8 @@ GEM
jekyll (~> 3.5)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.11.3)
minitest-reporters (1.3.6)
minitest (5.12.2)
minitest-reporters (1.4.0)
ansi
builder
minitest (>= 5.0)
Expand Down Expand Up @@ -283,7 +283,7 @@ DEPENDENCIES
codecov
github-pages (= 198)
i18n
minitest
minitest (~> 5.12)
minitest-reporters
oj
rack
Expand Down
32 changes: 16 additions & 16 deletions test/locales/utils/p11n_test.rb
Expand Up @@ -12,29 +12,29 @@
describe :one_other do

it "detects that 1 belongs to 'one'" do
p11n[:one_other].call(1).must_equal 'one'
_(p11n[:one_other].call(1)).must_equal 'one'
end

[0, 0.3, 1.2, 2, 3, 5, 10, 11, 21, 23, 31, 50, 81, 99, 100].each do |count|
it "detects that #{count} belongs to 'other'" do
p11n[:one_other].call(count).must_equal 'other'
_(p11n[:one_other].call(count)).must_equal 'other'
end
end

end

describe :one_two_other do
it "detects that 1 belongs to 'one'" do
p11n[:one_two_other].call(1).must_equal 'one'
_(p11n[:one_two_other].call(1)).must_equal 'one'
end

it "detects that 2 belongs to 'two'" do
p11n[:one_two_other].call(2).must_equal 'two'
_(p11n[:one_two_other].call(2)).must_equal 'two'
end

[0, 0.3, 1.2, 3, 5, 10, 11, 21, 23, 31, 50, 81, 99, 100].each do |count|
it "detects that #{count} belongs to 'other'" do
p11n[:one_two_other].call(count).must_equal 'other'
_(p11n[:one_two_other].call(count)).must_equal 'other'
end
end

Expand All @@ -44,13 +44,13 @@

[0, 0.5, 1, 1.2, 1.8].each do |count|
it "detects that #{count} belongs to 'one'" do
p11n[:one_upto_two_other].call(count).must_equal 'one'
_(p11n[:one_upto_two_other].call(count)).must_equal 'one'
end
end

[2, 2.1, 5, 11, 21, 22, 37, 40, 900.5].each do |count|
it "detects that #{count} belongs to 'other'" do
p11n[:one_upto_two_other].call(count).must_equal 'other'
_(p11n[:one_upto_two_other].call(count)).must_equal 'other'
end
end
end
Expand All @@ -59,7 +59,7 @@

[0, 1, 1.2, 2, 5, 11, 21, 22, 27, 99, 1000].each do |count|
it "detects that #{count} belongs to 'other'" do
p11n[:other].call(count).must_equal 'other'
_(p11n[:other].call(count)).must_equal 'other'
end
end

Expand All @@ -69,25 +69,25 @@

[1, 21, 51, 71, 101, 1031].each do |count|
it "detects that #{count} belongs to 'one'" do
p11n[:east_slavic].call(count).must_equal 'one'
_(p11n[:east_slavic].call(count)).must_equal 'one'
end
end

[2, 3, 4, 22, 23, 24, 92, 93, 94].each do |count|
it "detects that #{count} belongs to 'few'" do
p11n[:east_slavic].call(count).must_equal 'few'
_(p11n[:east_slavic].call(count)).must_equal 'few'
end
end

[0, 5, 8, 10, 11, 18, 20, 25, 27, 30, 35, 38, 40].each do |count|
it "detects that #{count} belongs to 'many'" do
p11n[:east_slavic].call(count).must_equal 'many'
_(p11n[:east_slavic].call(count)).must_equal 'many'
end
end

[1.2, 3.7, 11.5, 20.8, 1004.3].each do |count|
it "detects that #{count} in ru is 'other'" do
p11n[:east_slavic].call(count).must_equal 'other'
_(p11n[:east_slavic].call(count)).must_equal 'other'
end
end

Expand All @@ -96,24 +96,24 @@
describe :polish do

it "detects that 1 belongs to 'one'" do
p11n[:polish].call(1).must_equal 'one'
_(p11n[:polish].call(1)).must_equal 'one'
end

[2, 3, 4, 22, 23, 24, 92, 93, 94].each do |count|
it "detects that #{count} belongs to 'few'" do
p11n[:polish].call(count).must_equal 'few'
_(p11n[:polish].call(count)).must_equal 'few'
end
end

[0, 5, 8, 10, 11, 18, 20, 21, 25, 27, 30, 31, 35, 38, 40, 41, 114].each do |count|
it "detects that #{count} belongs to 'many'" do
p11n[:polish].call(count).must_equal 'many'
_(p11n[:polish].call(count)).must_equal 'many'
end
end

[1.2, 3.7, 11.5, 20.8, 1004.3].each do |count|
it "detects that #{count} belongs to 'other'" do
p11n[:polish].call(count).must_equal 'other'
_(p11n[:polish].call(count)).must_equal 'other'
end
end
end
Expand Down
76 changes: 38 additions & 38 deletions test/pagy/backend_test.rb
Expand Up @@ -15,23 +15,23 @@

it 'paginates with defaults' do
pagy, records = controller.send(:pagy, @collection)
pagy.must_be_instance_of Pagy
pagy.count.must_equal 1000
pagy.items.must_equal Pagy::VARS[:items]
pagy.page.must_equal controller.params[:page]
records.count.must_equal Pagy::VARS[:items]
records.must_equal [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.items).must_equal Pagy::VARS[:items]
_(pagy.page).must_equal controller.params[:page]
_(records.count).must_equal Pagy::VARS[:items]
_(records).must_equal [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]
end

it 'paginates with vars' do
pagy, records = controller.send(:pagy, @collection, page: 2, items: 10, link_extra: 'X')
pagy.must_be_instance_of Pagy
pagy.count.must_equal 1000
pagy.items.must_equal 10
pagy.page.must_equal 2
pagy.vars[:link_extra].must_equal 'X'
records.count.must_equal 10
records.must_equal [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
_(pagy).must_be_instance_of Pagy
_(pagy.count).must_equal 1000
_(pagy.items).must_equal 10
_(pagy.page).must_equal 2
_(pagy.vars[:link_extra]).must_equal 'X'
_(records.count).must_equal 10
_(records).must_equal [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
end

end
Expand All @@ -45,46 +45,46 @@
it 'gets defaults' do
vars = {}
merged = controller.send :pagy_get_vars, @collection, vars
merged.keys.must_include :count
merged.keys.must_include :page
merged[:count].must_equal 1000
merged[:page].must_equal 3
_(merged.keys).must_include :count
_(merged.keys).must_include :page
_(merged[:count]).must_equal 1000
_(merged[:page]).must_equal 3
end

it 'gets vars' do
vars = {page: 2, items: 10, link_extra: 'X'}
merged = controller.send :pagy_get_vars, @collection, vars
merged.keys.must_include :count
merged.keys.must_include :page
merged.keys.must_include :items
merged.keys.must_include :link_extra
merged[:count].must_equal 1000
merged[:page].must_equal 2
merged[:items].must_equal 10
merged[:link_extra].must_equal 'X'
_(merged.keys).must_include :count
_(merged.keys).must_include :page
_(merged.keys).must_include :items
_(merged.keys).must_include :link_extra
_(merged[:count]).must_equal 1000
_(merged[:page]).must_equal 2
_(merged[:items]).must_equal 10
_(merged[:link_extra]).must_equal 'X'
end

it 'works with grouped collections' do
@collection = MockCollection::Grouped.new((1..1000).to_a)
vars = {page: 2, items: 10, link_extra: 'X'}
merged = controller.send :pagy_get_vars, @collection, vars
merged.keys.must_include :count
merged.keys.must_include :page
merged.keys.must_include :items
merged.keys.must_include :link_extra
merged[:count].must_equal 1000
merged[:page].must_equal 2
merged[:items].must_equal 10
merged[:link_extra].must_equal 'X'
_(merged.keys).must_include :count
_(merged.keys).must_include :page
_(merged.keys).must_include :items
_(merged.keys).must_include :link_extra
_(merged[:count]).must_equal 1000
_(merged[:page]).must_equal 2
_(merged[:items]).must_equal 10
_(merged[:link_extra]).must_equal 'X'
end

it 'overrides count and page' do
vars = {count: 10, page: 32}
merged = controller.send :pagy_get_vars, @collection, vars
merged.keys.must_include :count
merged[:count].must_equal 10
merged.keys.must_include :page
merged[:page].must_equal 32
_(merged.keys).must_include :count
_(merged[:count]).must_equal 10
_(merged.keys).must_include :page
_(merged[:page]).must_equal 32
end

end
Expand All @@ -95,7 +95,7 @@
collection = MockCollection.new
pagy = Pagy.new count: 1000
items = controller.send :pagy_get_items, collection, pagy
items.must_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
_(items).must_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
end

end
Expand Down
80 changes: 40 additions & 40 deletions test/pagy/countless_test.rb
Expand Up @@ -18,71 +18,71 @@
let(:last_page) { 3 }

it 'raises exception with no retrieved items' do
proc { Pagy::Countless.new(page: 2).finalize(0) }.must_raise Pagy::OverflowError
_(proc { Pagy::Countless.new(page: 2).finalize(0) }).must_raise Pagy::OverflowError
end

it 'initializes empty collection' do
pagy, _ = controller.send(:pagy_countless, @empty_collection, page: 1)
pagy.items.must_equal 20
pagy.pages.must_equal 1
pagy.last.must_equal 1
pagy.from.must_equal 0
pagy.to.must_equal 0
pagy.prev.must_be_nil
pagy.next.must_be_nil
_(pagy.items).must_equal 20
_(pagy.pages).must_equal 1
_(pagy.last).must_equal 1
_(pagy.from).must_equal 0
_(pagy.to).must_equal 0
_(pagy.prev).must_be_nil
_(pagy.next).must_be_nil
end

it 'initializes first page' do
pagy, _ = controller.send(:pagy_countless, @collection, page: 1)
pagy.must_be_instance_of Pagy::Countless
pagy.items.must_equal 20
pagy.last.must_equal 2
pagy.pages.must_equal 2 # current + 1. `Countless` does not know real count
pagy.from.must_equal 1
pagy.to.must_equal 20
pagy.prev.must_be_nil
pagy.next.must_equal 2
_(pagy).must_be_instance_of Pagy::Countless
_(pagy.items).must_equal 20
_(pagy.last).must_equal 2
_(pagy.pages).must_equal 2 # current + 1. `Countless` does not know real count
_(pagy.from).must_equal 1
_(pagy.to).must_equal 20
_(pagy.prev).must_be_nil
_(pagy.next).must_equal 2
end

it 'initializes single full page' do
pagy, _ = controller.send(:pagy_countless, MockCollection.new(Array(1..20)), page: 1)
pagy.items.must_equal 20
pagy.pages.must_equal 1
pagy.from.must_equal 1
pagy.to.must_equal 20
pagy.prev.must_be_nil
pagy.next.must_be_nil
_(pagy.items).must_equal 20
_(pagy.pages).must_equal 1
_(pagy.from).must_equal 1
_(pagy.to).must_equal 20
_(pagy.prev).must_be_nil
_(pagy.next).must_be_nil
end

it 'initialize single partial page' do
pagy, _ = controller.send(:pagy_countless, MockCollection.new(Array(1..4)), page: 1)
pagy.items.must_equal 4
pagy.pages.must_equal 1
pagy.from.must_equal 1
pagy.to.must_equal 4
pagy.prev.must_be_nil
pagy.next.must_be_nil
_(pagy.items).must_equal 4
_(pagy.pages).must_equal 1
_(pagy.from).must_equal 1
_(pagy.to).must_equal 4
_(pagy.prev).must_be_nil
_(pagy.next).must_be_nil

end

it 'initializes last partial page' do
pagy, _ = controller.send(:pagy_countless, @collection, page: last_page)
pagy.items.must_equal 19
pagy.pages.must_equal last_page
pagy.from.must_equal 41
pagy.to.must_equal 59
pagy.prev.must_equal(last_page - 1)
pagy.next.must_be_nil
_(pagy.items).must_equal 19
_(pagy.pages).must_equal last_page
_(pagy.from).must_equal 41
_(pagy.to).must_equal 59
_(pagy.prev).must_equal(last_page - 1)
_(pagy.next).must_be_nil
end

it 'handles the :cycle variable' do
pagy, _ = controller.send(:pagy_countless, @collection, page: last_page, cycle: true)
pagy.items.must_equal 19
pagy.pages.must_equal last_page
pagy.from.must_equal 41
pagy.to.must_equal 59
pagy.prev.must_equal(last_page - 1)
pagy.next.must_equal 1
_(pagy.items).must_equal 19
_(pagy.pages).must_equal last_page
_(pagy.from).must_equal 41
_(pagy.to).must_equal 59
_(pagy.prev).must_equal(last_page - 1)
_(pagy.next).must_equal 1
end

end
Expand Down

0 comments on commit af0f189

Please sign in to comment.