Skip to content

Commit 5a55a08

Browse files
authored
Merge pull request #6 from yuri-zubov/master
Fixes tests: - Add Ruby 2.1 - 2.6 and Rails 5, 6 to Travis matrix - Add Rails 5, 6 to Appraisals config - Fixes implementation for form helper tests
2 parents e4eb09e + d6e9e4c commit 5a55a08

File tree

18 files changed

+148
-15
lines changed

18 files changed

+148
-15
lines changed

.travis.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
rvm:
2-
- 1.9.2
32
- 1.9.3
4-
- 2.0.0
3+
- 2.0
4+
- 2.1
5+
- 2.2
6+
- 2.3
7+
- 2.4
8+
- 2.5
9+
- 2.6
510
env:
611
- "RAILS_VERSION=3.1.0"
712
- "RAILS_VERSION=3.2.0"
813
- "RAILS_VERSION=4.0.0"
14+
- "RAILS_VERSION=4.1.0"
15+
- "RAILS_VERSION=4.3.0"
16+
- "RAILS_VERSION=5.0.0"
17+
- "RAILS_VERSION=5.1.0"
18+
- "RAILS_VERSION=5.2.0"
19+
- "RAILS_VERSION=6.0.0"
920
matrix:
1021
exclude:
1122
- rvm: 1.9.2
12-
env: "RAILS_VERSION=4.0.0"
23+
env: "RAILS_VERSION=3.1.0"
1324
branches:
1425
only:
1526
- master

Appraisals

+8
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ end
55
appraise "rails-4" do
66
gem "rails", "~> 4.0"
77
end
8+
9+
appraise "rails-5" do
10+
gem "rails", "~> 5.0"
11+
end
12+
13+
appraise "rails-6" do
14+
gem "rails", "~> 6.0"
15+
end

Gemfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ source "http://rubygems.org"
22

33
gemspec
44

5-
gem 'appraisal', "1.0.0.beta3"
6-
gem "debugger"
5+
gem 'appraisal', "2.2.0"

test/carmen/action_view/helpers/form_helper_test.rb test/carmen/action_view/helpers/carmen_view_helper_test.rb

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
require 'test_helper'
22

3-
class CarmenViewHelperTest < MiniTest::Unit::TestCase
3+
class CarmenViewHelperTest < MiniTest::Test
44
include ActionView::Helpers::FormOptionsHelper
55
include ActionView::Helpers::FormTagHelper
6-
include ActionDispatch::Assertions::SelectorAssertions
6+
7+
if ::Rails.const_defined?(:Dom)
8+
include ::Rails::Dom::Testing::Assertions::SelectorAssertions
9+
else
10+
include ActionDispatch::Assertions::SelectorAssertions
11+
end
712

813
def setup
914
@object = OpenStruct.new
15+
1016
def @object.to_s; 'object'; end
1117
end
1218

@@ -27,6 +33,10 @@ def test_basic_country_select
2733
assert_equal_markup(expected, html)
2834
end
2935

36+
def document_root_element
37+
Nokogiri.parse(@html)
38+
end
39+
3040
def test_country_selected_value
3141
@html = country_select(:object, :country_code, :selected => 'OC')
3242
assert_select('option[selected="selected"][value="OC"]')
@@ -123,6 +133,7 @@ def test_basic_subregion_select
123133
expected = <<-HTML
124134
<select id="object_subregion_code" name="object[subregion_code]">
125135
<option value="AO">Airstrip One</option>
136+
<option value="AT">Airstrip-Two</option>
126137
</select>
127138
HTML
128139

@@ -135,6 +146,7 @@ def test_subregion_select_using_parent_code
135146
expected = <<-HTML
136147
<select id="object_subregion_code" name="object[subregion_code]">
137148
<option value="AO">Airstrip One</option>
149+
<option value="AT">Airstrip-Two</option>
138150
</select>
139151
HTML
140152

@@ -181,6 +193,7 @@ def test_basic_subregion_select_tag
181193
expected = <<-HTML
182194
<select id="subregion_code" name="subregion_code">
183195
<option value="AO">Airstrip One</option>
196+
<option value="AT">Airstrip-Two</option>
184197
</select>
185198
HTML
186199

@@ -196,6 +209,7 @@ def test_subregion_select_tag_with_priority
196209
<option value="AO">Airstrip One</option>
197210
<option disabled>-------------</option>
198211
<option value="AO">Airstrip One</option>
212+
<option value="AT">Airstrip-Two</option>
199213
</select>
200214
HTML
201215

@@ -210,6 +224,7 @@ def test_subregion_select_tag_with_prompt
210224
<select id="subregion_code" name="subregion_code">
211225
<option value="">Please select</option>
212226
<option value="AO">Airstrip One</option>
227+
<option value="AT">Airstrip-Two</option>
213228
</select>
214229
HTML
215230

@@ -252,7 +267,7 @@ def test_region_options_for_select_with_array_of_regions_and_priority
252267
end
253268

254269
def test_form_builder_country_select
255-
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {}, lambda{})
270+
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {})
256271

257272
html = form.country_select('attribute_name')
258273
expected = <<-HTML
@@ -268,14 +283,14 @@ def test_form_builder_country_select
268283

269284
def test_form_builder_selected_country
270285
@object.country_code = 'OC'
271-
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {}, lambda{})
286+
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {})
272287
@html = form.country_select('country_code')
273288

274289
assert_select('option[selected="selected"][value="OC"]')
275290
end
276291

277292
def test_form_builder_country_select_deprecated_api
278-
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {}, lambda{})
293+
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {})
279294

280295
html = form.country_select('attribute_name', ['ES'])
281296
expected = <<-HTML
@@ -292,11 +307,12 @@ def test_form_builder_country_select_deprecated_api
292307
end
293308

294309
def test_form_builder_subregion_select
295-
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {}, lambda{})
310+
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {})
296311
html = form.subregion_select(:subregion_code, 'OC')
297312
expected = <<-HTML
298313
<select id="object_subregion_code" name="object[subregion_code]">
299314
<option value="AO">Airstrip One</option>
315+
<option value="AT">Airstrip-Two</option>
300316
</select>
301317
HTML
302318

@@ -305,7 +321,7 @@ def test_form_builder_subregion_select
305321

306322
def test_form_builder_selected_subregion
307323
@object.subregion_code = 'AO'
308-
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {}, lambda{})
324+
form = ActionView::Helpers::FormBuilder.new(:object, @object, self, {})
309325
@html = form.subregion_select(:subregion_code, 'OC')
310326

311327
assert_select('option[selected="selected"][value="AO"]')

test/spec_data/data/world.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- alpha_2_code: OC
3+
alpha_3_code: OCE
4+
numeric_code: "001"
5+
type: country
6+
- alpha_2_code: EU
7+
alpha_3_code: EUR
8+
numeric_code: "002"
9+
type: country
10+
- alpha_2_code: ES
11+
alpha_3_code: EST
12+
numeric_code: "003"
13+
type: country

test/spec_data/data/world/oc.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- code: AO
3+
type: province
4+
- code: AT
5+
type: province

test/spec_data/data/world/oc/ao.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- code: LO
3+
type: city

test/spec_data/locale/de/world.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
de:
3+
world:
4+
eu:
5+
common_name: Eurasia
6+
name: Das großartige Staat von Eurasia
7+
official_name: Das großartige Staat von Eurasia

test/spec_data/locale/en/world.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
en:
3+
world:
4+
oc:
5+
common_name: Oceania
6+
name: Oceania
7+
official_name: The Superstate of Oceania
8+
eu:
9+
common_name: Eurasia
10+
name: Eurasia
11+
official_name: The Superstate of Eurasia
12+
es:
13+
common_name: Eastasia
14+
name: Eastasia
15+
official_name: The Superstate of Eastasia

test/spec_data/locale/en/world/oc.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
en:
3+
world:
4+
oc:
5+
ao:
6+
name: Airstrip One
7+
at:
8+
name: Airstrip-Two
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
en:
3+
world:
4+
oc:
5+
ao:
6+
lo:
7+
name: London

test/spec_data/overlay/data/world.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- alpha_2_code: SE
3+
alpha_3_code: SEA
4+
numeric_code: "004"
5+
common_name: Sealand
6+
name: Sealand
7+
official_name: The Principality of Sealand
8+
type: fort
9+
- alpha_2_code: EU
10+
_enabled: false
11+
- alpha_2_code: ES
12+
official_name: The Wonderous Country of Eastasia
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
de:
3+
world:
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
en:
3+
world:
4+
es:
5+
official_name: The Wonderous Country of Eastasia
6+
se:
7+
common_name: Sealand
8+
name: Sealand
9+
official_name: The Principality of Sealand
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
en:
3+
world:
4+
oc:
5+
ao:
6+
name: Airstrip Uno
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
zz:
3+
world:
4+
es:
5+
official_name: The Zonderous Zountry of Zeastasia
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
zz:
3+
world:
4+
oc:
5+
ao:
6+
name: Zairstrip Zuno

test/test_helper.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@
99
require 'rails'
1010
require 'carmen-rails'
1111
require 'ostruct'
12-
require 'debugger'
1312

1413
MiniTest::Spec.register_spec_type(/.*/, ActionView::TestCase)
1514

1615
Carmen.clear_data_paths
1716

18-
carmen_path = File.expand_path('../../../carmen', __FILE__)
17+
carmen_path = File.expand_path('..', __FILE__)
1918

2019
Carmen.append_data_path(carmen_path + '/spec_data/data')
2120

2221
locale_path = carmen_path + '/spec_data/locale'
2322
Carmen.i18n_backend = Carmen::I18n::Simple.new(locale_path)
2423

25-
class MiniTest::Unit::TestCase
24+
class MiniTest::Test
2625
def assert_equal_markup(expected, actual, message=nil)
2726
assert_equal(clean_markup(expected), clean_markup(actual), message)
2827
end

0 commit comments

Comments
 (0)