Skip to content

Commit 7b2a52d

Browse files
authored
Merge pull request #486 from trailblazer/upMinitest
update minitest syntax
2 parents e29d693 + 4501202 commit 7b2a52d

15 files changed

+136
-146
lines changed

.travis.yml

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
language: ruby
2+
before_install: gem install bundler
23
rvm:
3-
#- ruby-head
4-
- 2.5.1
5-
- 2.4.4
6-
- 2.3.7
7-
- 2.2.10
4+
- 2.7
5+
- 2.6
6+
- 2.5
87

98
cache: bundler
10-
11-
matrix:
12-
fast_finish: true
13-
allow_failures:
14-
- rvm: ruby-head
15-
16-
before_install:
17-
- gem update --system
18-
- gem install bundler

test/builder_test.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,28 @@ class EvergreenCell < SongCell
3636
end
3737

3838
# the original class is used when no builder matches.
39-
it { SongCell.(Song.new("Nation States"), {}).must_be_instance_of SongCell }
39+
it { _(SongCell.(Song.new("Nation States"), {})).must_be_instance_of SongCell }
4040

4141
it do
4242
cell = SongCell.(Hit.new("New York"), {})
43-
cell.must_be_instance_of HitCell
44-
cell.options.must_equal({})
43+
_(cell).must_be_instance_of HitCell
44+
_(cell.options).must_equal({})
4545
end
4646

4747
it do
4848
cell = SongCell.(Song.new("San Francisco"), evergreen: true)
49-
cell.must_be_instance_of EvergreenCell
50-
cell.options.must_equal({evergreen:true})
49+
_(cell).must_be_instance_of EvergreenCell
50+
_(cell.options).must_equal({evergreen:true})
5151
end
5252

5353
# without arguments.
54-
it { SongCell.(Hit.new("Frenzy")).must_be_instance_of HitCell }
54+
it { _(SongCell.(Hit.new("Frenzy"))).must_be_instance_of HitCell }
5555

5656
# with collection.
57-
it { SongCell.(collection: [Song.new("Nation States"), Hit.new("New York")]).().must_equal "* Nation States* **New York**" }
57+
it { _(SongCell.(collection: [Song.new("Nation States"), Hit.new("New York")]).()).must_equal "* Nation States* **New York**" }
5858

5959
# with Concept
6060
class Track < Cell::Concept
6161
end
62-
it { Track.().must_be_instance_of Track }
62+
it { _(Track.()).must_be_instance_of Track }
6363
end

test/cache_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class Index < Cell::ViewModel
2525
end
2626

2727
it do
28-
Index.new(1).().must_equal("1")
29-
Index.new(2).().must_equal("1")
28+
_(Index.new(1).()).must_equal("1")
29+
_(Index.new(2).()).must_equal("1")
3030
end
3131
end
3232

test/cell_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def show_with_block(&block)
1313
end
1414

1515
# #options
16-
it { SongCell.new(nil, genre: "Punkrock").send(:options)[:genre].must_equal "Punkrock" }
16+
it { _(SongCell.new(nil, genre: "Punkrock").send(:options)[:genre]).must_equal "Punkrock" }
1717

1818
# #block
19-
it { SongCell.new(nil, genre: "Punkrock").(:show_with_block) { "hello" }.must_equal "<b>hello</b>\n" }
19+
it { _(SongCell.new(nil, genre: "Punkrock").(:show_with_block) { "hello" }).must_equal "<b>hello</b>\n" }
2020
end

test/concept_test.rb

+15-15
Original file line numberDiff line numberDiff line change
@@ -48,40 +48,40 @@ class Song < ::Cell::Concept
4848

4949
class ConceptTest < MiniTest::Spec
5050
describe "::controller_path" do
51-
it { Record::Cell.new.class.controller_path.must_equal "record" }
52-
it { Record::Cell::Song.new.class.controller_path.must_equal "record/song" }
53-
it { Record::Cells::Cell.new.class.controller_path.must_equal "record/cells" }
54-
it { Record::Cells::Cell::Song.new.class.controller_path.must_equal "record/cells/song" }
51+
it { _(Record::Cell.new.class.controller_path).must_equal "record" }
52+
it { _(Record::Cell::Song.new.class.controller_path).must_equal "record/song" }
53+
it { _(Record::Cells::Cell.new.class.controller_path).must_equal "record/cells" }
54+
it { _(Record::Cells::Cell::Song.new.class.controller_path).must_equal "record/cells/song" }
5555
end
5656

5757

5858
describe "#_prefixes" do
59-
it { Record::Cell.new._prefixes.must_equal ["test/fixtures/concepts/record/views"] }
60-
it { Record::Cell::Song.new._prefixes.must_equal ["test/fixtures/concepts/record/song/views", "test/fixtures/concepts/record/views"] }
61-
it { Record::Cell::Hit.new._prefixes.must_equal ["test/fixtures/concepts/record/hit/views", "test/fixtures/concepts/record/views"] } # with inherit_views.
59+
it { _(Record::Cell.new._prefixes).must_equal ["test/fixtures/concepts/record/views"] }
60+
it { _(Record::Cell::Song.new._prefixes).must_equal ["test/fixtures/concepts/record/song/views", "test/fixtures/concepts/record/views"] }
61+
it { _(Record::Cell::Hit.new._prefixes).must_equal ["test/fixtures/concepts/record/hit/views", "test/fixtures/concepts/record/views"] } # with inherit_views.
6262
end
6363

64-
it { Record::Cell.new("Wayne").call(:show).must_equal "Party on, Wayne!" }
64+
it { _(Record::Cell.new("Wayne").call(:show)).must_equal "Party on, Wayne!" }
6565

6666

6767
describe "::cell" do
68-
it { Cell::Concept.cell("record/cell").must_be_instance_of( Record::Cell) }
69-
it { Cell::Concept.cell("record/cell/song").must_be_instance_of Record::Cell::Song }
68+
it { _(Cell::Concept.cell("record/cell")).must_be_instance_of( Record::Cell) }
69+
it { _(Cell::Concept.cell("record/cell/song")).must_be_instance_of Record::Cell::Song }
7070
# cell("song", concept: "record/compilation") # record/compilation/cell/song
7171
end
7272

7373
describe "#render" do
74-
it { Cell::Concept.cell("record/cell/song").show.must_equal "Lalala" }
74+
it { _(Cell::Concept.cell("record/cell/song").show).must_equal "Lalala" }
7575
end
7676

7777
describe "#cell (in state)" do
7878
# test with controller, but remove tests when we don't need it anymore.
79-
it { Cell::Concept.cell("record/cell", nil, context: { controller: Object }).cell("record/cell", nil).must_be_instance_of Record::Cell }
80-
it { Cell::Concept.cell("record/cell", nil, context: { controller: Object }).concept("record/cell", nil, tracks: 24).(:description).must_equal "A Tribute To Rancid, with 24 songs! [{:controller=>Object}]" }
79+
it { _(Cell::Concept.cell("record/cell", nil, context: { controller: Object }).cell("record/cell", nil)).must_be_instance_of Record::Cell }
80+
it { _(Cell::Concept.cell("record/cell", nil, context: { controller: Object }).concept("record/cell", nil, tracks: 24).(:description)).must_equal "A Tribute To Rancid, with 24 songs! [{:controller=>Object}]" }
8181
# concept(.., collection: ..)
8282
it do
83-
Cell::Concept.cell("record/cell", nil, context: { controller: Object }).
84-
concept("record/cell", collection: [1,2], tracks: 24).(:description).must_equal "A Tribute To Rancid, with 24 songs! [{:controller=>Object}]A Tribute To Rancid, with 24 songs! [{:controller=>Object}]"
83+
_(Cell::Concept.cell("record/cell", nil, context: { controller: Object }).
84+
concept("record/cell", collection: [1,2], tracks: 24).(:description)).must_equal "A Tribute To Rancid, with 24 songs! [{:controller=>Object}]A Tribute To Rancid, with 24 songs! [{:controller=>Object}]"
8585
end
8686
end
8787
end

test/context_test.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ def controller
1818
let (:parent) { ParentCell.(model, admin: true, context: { user: user, controller: controller }) }
1919

2020
it do
21-
parent.model.must_equal model
22-
parent.controller.must_equal controller
23-
parent.user.must_equal user
21+
_(parent.model).must_equal model
22+
_(parent.controller).must_equal controller
23+
_(parent.user).must_equal user
2424

2525
# nested cell
2626
child = parent.cell("context_test/parent", "")
2727

28-
child.model.must_equal ""
29-
child.controller.must_equal controller
30-
child.user.must_equal user
28+
_(child.model).must_equal ""
29+
_(child.controller).must_equal controller
30+
_(child.user).must_equal user
3131
end
3232

3333
# child can add to context
@@ -37,8 +37,8 @@ def controller
3737
assert_nil(parent.context["is_child?"])
3838

3939
assert_nil(child.model)
40-
child.controller.must_equal controller
41-
child.user.must_equal user
42-
child.context["is_child?"].must_equal true
40+
_(child.controller).must_equal controller
41+
_(child.user).must_equal user
42+
_(child.context["is_child?"]).must_equal true
4343
end
4444
end

test/inspect_test.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ def build_model
1616

1717
inspection_s = cell.inspect
1818

19-
inspection_s.must_match '#<Cell::ViewModel:'
20-
inspection_s.must_match "@model=#{model_obj.inspect}"
21-
inspection_s.must_match "@title=\"Title\""
22-
inspection_s.must_match "@options=#{options.inspect}"
19+
_(inspection_s).must_match '#<Cell::ViewModel:'
20+
_(inspection_s).must_match "@model=#{model_obj.inspect}"
21+
_(inspection_s).must_match "@title=\"Title\""
22+
_(inspection_s).must_match "@options=#{options.inspect}"
2323
end
2424
it do
2525
inspection_s = Cell::ViewModel.().inspect
2626

27-
inspection_s.must_match '#<Cell::ViewModel:'
28-
inspection_s.must_match "@model=nil"
29-
inspection_s.must_match "@options={}"
27+
_(inspection_s).must_match '#<Cell::ViewModel:'
28+
_(inspection_s).must_match "@model=nil"
29+
_(inspection_s).must_match "@options={}"
3030
end
3131

3232
# black list ivars
@@ -36,9 +36,9 @@ def build_model
3636
cell.stub(:inspect_blacklist, ['model']) do
3737
inspection_s = cell.inspect
3838

39-
inspection_s.must_match '#<Cell::ViewModel:'
40-
inspection_s.must_match "@model=#<InspectTest::FakeModel:#{model_obj.object_id}>"
41-
inspection_s.must_match "@options=#{options.inspect}"
39+
_(inspection_s).must_match '#<Cell::ViewModel:'
40+
_(inspection_s).must_match "@model=#<InspectTest::FakeModel:#{model_obj.object_id}>"
41+
_(inspection_s).must_match "@options=#{options.inspect}"
4242
end
4343
end
4444
end

test/layout_test.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def show_with_layout
4242
class LayoutTest < MiniTest::Spec
4343
# render show.haml calling method.
4444
# same context as content view as layout call method.
45-
it { SongWithLayoutCell.new(nil).show.must_equal "Merry Xmas, <b>Papertiger</b>" }
45+
it { _(SongWithLayoutCell.new(nil).show).must_equal "Merry Xmas, <b>Papertiger</b>\n" }
4646

4747
# raises exception when layout not found!
4848

@@ -51,10 +51,10 @@ class LayoutTest < MiniTest::Spec
5151
it { }
5252

5353
# with ::layout.
54-
it { SongWithLayoutOnClassCell.new(nil).show.must_equal "Merry Xmas, <b>Papertiger</b>" }
54+
it { _(SongWithLayoutOnClassCell.new(nil).show).must_equal "Merry Xmas, <b>Papertiger</b>\n" }
5555

5656
# with ::layout and :layout, :layout wins.
57-
it { SongWithLayoutOnClassCell.new(nil).show_with_layout.must_equal "Happy Friday!" }
57+
it { _(SongWithLayoutOnClassCell.new(nil).show_with_layout).must_equal "Happy Friday!" }
5858
end
5959

6060
module Comment
@@ -74,15 +74,15 @@ class LayoutCell < Cell::ViewModel
7474

7575
class ExternalLayoutTest < Minitest::Spec
7676
it do
77-
Comment::ShowCell.new(nil, layout: Comment::LayoutCell, context: { beer: true }).
78-
().must_equal "$layout.erb{$show.erb, {:beer=>true}$show.erb, {:beer=>true}, {:beer=>true}}
77+
_(Comment::ShowCell.new(nil, layout: Comment::LayoutCell, context: { beer: true }).
78+
()).must_equal "$layout.erb{$show.erb, {:beer=>true}\n$show.erb, {:beer=>true}\n, {:beer=>true}}
7979
"
8080
end
8181

8282
# collection :layout
8383
it do
84-
Cell::ViewModel.cell("comment/show", collection: [Object, Module], layout: Comment::LayoutCell).().
85-
must_equal "$layout.erb{$show.erb, nil$show.erb, nil$show.erb, nil$show.erb, nil, nil}
84+
_(Cell::ViewModel.cell("comment/show", collection: [Object, Module], layout: Comment::LayoutCell).()).
85+
must_equal "$layout.erb{$show.erb, nil\n$show.erb, nil\n$show.erb, nil\n$show.erb, nil\n, nil}
8686
"
8787
end
8888
end

test/partial_test.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class WithPartialAndManyViewPaths < WithPartial
2525
self.view_paths << ['app/views']
2626
end
2727

28-
it { WithPartial.new(nil).show.must_equal "I Am Wrong And I Am Right" }
29-
it { WithPartial.new(nil).show_with_format.must_equal "<xml>I Am Wrong And I Am Right</xml>" }
30-
it { WithPartial.new(nil).show_without_partial.must_equal "Adenosine Breakdown" }
28+
it { _(WithPartial.new(nil).show).must_equal "I Am Wrong And I Am Right" }
29+
it { _(WithPartial.new(nil).show_with_format).must_equal "<xml>I Am Wrong And I Am Right</xml>" }
30+
it { _(WithPartial.new(nil).show_without_partial).must_equal "Adenosine Breakdown" }
3131

32-
it { WithPartialAndManyViewPaths.new(nil).show.must_equal "I Am Wrong And I Am Right" }
33-
it { WithPartialAndManyViewPaths.new(nil).show_with_format.must_equal "<xml>I Am Wrong And I Am Right</xml>" }
34-
it { WithPartialAndManyViewPaths.new(nil).show_without_partial.must_equal "Adenosine Breakdown" }
32+
it { _(WithPartialAndManyViewPaths.new(nil).show).must_equal "I Am Wrong And I Am Right" }
33+
it { _(WithPartialAndManyViewPaths.new(nil).show_with_format).must_equal "<xml>I Am Wrong And I Am Right</xml>" }
34+
it { _(WithPartialAndManyViewPaths.new(nil).show_without_partial).must_equal "Adenosine Breakdown" }
3535
end

test/prefixes_test.rb

+23-23
Original file line numberDiff line numberDiff line change
@@ -42,39 +42,39 @@ def self._local_prefixes
4242

4343

4444
describe "::controller_path" do
45-
it { ::BassistCell.new(@controller).class.controller_path.must_equal "bassist" }
46-
it { SingerCell.new(@controller).class.controller_path.must_equal "prefixes_test/singer" }
45+
it { _(::BassistCell.new(@controller).class.controller_path).must_equal "bassist" }
46+
it { _(SingerCell.new(@controller).class.controller_path).must_equal "prefixes_test/singer" }
4747
end
4848

4949
describe "#_prefixes" do
50-
it { ::BassistCell.new(@controller)._prefixes.must_equal ["test/fixtures/bassist"] }
51-
it { ::BassistCell::FenderCell.new(@controller)._prefixes.must_equal ["app/cells/bassist_cell/fender"] }
52-
it { ::BassistCell::IbanezCell.new(@controller)._prefixes.must_equal ["test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"] }
50+
it { _(::BassistCell.new(@controller)._prefixes).must_equal ["test/fixtures/bassist"] }
51+
it { _(::BassistCell::FenderCell.new(@controller)._prefixes).must_equal ["app/cells/bassist_cell/fender"] }
52+
it { _(::BassistCell::IbanezCell.new(@controller)._prefixes).must_equal ["test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"] }
5353

54-
it { SingerCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/singer"] }
55-
it { BackgroundVocalsCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/background_vocals", "app/cells/prefixes_test/singer"] }
56-
it { ChorusCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/chorus", "app/cells/prefixes_test/background_vocals", "app/cells/prefixes_test/singer"] }
54+
it { _(SingerCell.new(@controller)._prefixes).must_equal ["app/cells/prefixes_test/singer"] }
55+
it { _(BackgroundVocalsCell.new(@controller)._prefixes).must_equal ["app/cells/prefixes_test/background_vocals", "app/cells/prefixes_test/singer"] }
56+
it { _(ChorusCell.new(@controller)._prefixes).must_equal ["app/cells/prefixes_test/chorus", "app/cells/prefixes_test/background_vocals", "app/cells/prefixes_test/singer"] }
5757

58-
it { GuitaristCell.new(@controller)._prefixes.must_equal ["stringer", "app/cells/prefixes_test/singer"] }
59-
it { BassistCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/bassist", "basser", "app/cells/prefixes_test/singer"] }
58+
it { _(GuitaristCell.new(@controller)._prefixes).must_equal ["stringer", "app/cells/prefixes_test/singer"] }
59+
it { _(BassistCell.new(@controller)._prefixes).must_equal ["app/cells/prefixes_test/bassist", "basser", "app/cells/prefixes_test/singer"] }
6060
# it { DrummerCell.new(@controller)._prefixes.must_equal ["drummer", "stringer", "prefixes_test/singer"] }
6161

6262
# multiple view_paths.
63-
it { EngineCell.prefixes.must_equal ["app/cells/engine", "/var/engine/app/cells/engine"] }
63+
it { _(EngineCell.prefixes).must_equal ["app/cells/engine", "/var/engine/app/cells/engine"] }
6464
it do
65-
InheritingFromEngineCell.prefixes.must_equal [
65+
_(InheritingFromEngineCell.prefixes).must_equal [
6666
"app/cells/inheriting_from_engine", "/var/engine/app/cells/inheriting_from_engine",
6767
"app/cells/engine", "/var/engine/app/cells/engine"]
6868
end
6969

7070
# ::_prefixes is cached.
7171
it do
72-
WannabeCell.prefixes.must_equal ["test/fixtures/wannabe", "test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"]
72+
_(WannabeCell.prefixes).must_equal ["test/fixtures/wannabe", "test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"]
7373
WannabeCell.instance_eval { def _local_prefixes; ["more"] end }
7474
# _prefixes is cached.
75-
WannabeCell.prefixes.must_equal ["test/fixtures/wannabe", "test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"]
75+
_(WannabeCell.prefixes).must_equal ["test/fixtures/wannabe", "test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"]
7676
# superclasses don't get disturbed.
77-
::BassistCell.prefixes.must_equal ["test/fixtures/bassist"]
77+
_(::BassistCell.prefixes).must_equal ["test/fixtures/bassist"]
7878
end
7979
end
8080

@@ -96,12 +96,12 @@ def play
9696
class FunkerCell < SlapperCell
9797
end
9898

99-
it { SlapperCell.new(nil)._prefixes.must_equal ["test/fixtures/inherit_views_test/slapper", "test/fixtures/bassist"] }
100-
it { FunkerCell.new(nil)._prefixes.must_equal ["test/fixtures/inherit_views_test/funker", "test/fixtures/inherit_views_test/slapper", "test/fixtures/bassist"] }
99+
it { _(SlapperCell.new(nil)._prefixes).must_equal ["test/fixtures/inherit_views_test/slapper", "test/fixtures/bassist"] }
100+
it { _(FunkerCell.new(nil)._prefixes).must_equal ["test/fixtures/inherit_views_test/funker", "test/fixtures/inherit_views_test/slapper", "test/fixtures/bassist"] }
101101

102102
# test if normal cells inherit views.
103-
it { cell('inherit_views_test/slapper').play.must_equal 'Doo' }
104-
it { cell('inherit_views_test/funker').play.must_equal 'Doo' }
103+
it { _(cell('inherit_views_test/slapper').play).must_equal 'Doo' }
104+
it { _(cell('inherit_views_test/funker').play).must_equal 'Doo' }
105105

106106

107107
# TapperCell
@@ -122,12 +122,12 @@ class PopperCell < TapperCell
122122
end
123123

124124
# Tapper renders its play
125-
it { cell('inherit_views_test/tapper').call(:play).must_equal 'Dooom!' }
125+
it { _(cell('inherit_views_test/tapper').call(:play)).must_equal 'Dooom!' }
126126
# Tapper renders its tap
127-
it { cell('inherit_views_test/tapper').call(:tap).must_equal 'Tap tap tap!' }
127+
it { _(cell('inherit_views_test/tapper').call(:tap)).must_equal 'Tap tap tap!' }
128128

129129
# Popper renders Tapper's play
130-
it { cell('inherit_views_test/popper').call(:play).must_equal 'Dooom!' }
130+
it { _(cell('inherit_views_test/popper').call(:play)).must_equal 'Dooom!' }
131131
# Popper renders its tap
132-
it { cell('inherit_views_test/popper').call(:tap).must_equal "TTttttap I'm not good enough!" }
132+
it { _(cell('inherit_views_test/popper').call(:tap)).must_equal "TTttttap I'm not good enough!" }
133133
end

test/property_test.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def title
1111

1212
let (:song) { Struct.new(:title).new("<b>She Sells And Sand Sandwiches") }
1313
# ::property creates automatic accessor.
14-
it { SongCell.(song).title.must_equal "<b>She Sells And Sand Sandwiches</b>" }
14+
it { _(SongCell.(song).title).must_equal "<b>She Sells And Sand Sandwiches</b>" }
1515
end
1616

1717

@@ -38,11 +38,11 @@ def raw_title
3838
end
3939

4040
# ::property escapes, everywhere.
41-
it { SongCell.(song).title.must_equal "&lt;b&gt;She Sells And Sand Sandwiches</b>" }
42-
it { SongCell.(song).copyright.must_equal "&lt;a&gt;Copy&lt;/a&gt;" }
43-
it { SongCell.(song).lyrics.must_equal "&lt;i&gt;Words&lt;/i&gt;" }
41+
it { _(SongCell.(song).title).must_equal "&lt;b&gt;She Sells And Sand Sandwiches</b>" }
42+
it { _(SongCell.(song).copyright).must_equal "&lt;a&gt;Copy&lt;/a&gt;" }
43+
it { _(SongCell.(song).lyrics).must_equal "&lt;i&gt;Words&lt;/i&gt;" }
4444
# no escaping for non-strings.
45-
it { SongCell.(song).artist.must_equal Object }
45+
it { _(SongCell.(song).artist).must_equal Object }
4646
# no escaping when escape: false
47-
it { SongCell.(song).raw_title.must_equal "<b>She Sells And Sand Sandwiches</b>" }
47+
it { _(SongCell.(song).raw_title).must_equal "<b>She Sells And Sand Sandwiches</b>" }
4848
end

0 commit comments

Comments
 (0)