-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathmarriage_abroad_calculator_test.rb
765 lines (614 loc) · 33 KB
/
marriage_abroad_calculator_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
require_relative "../../test_helper"
module SmartAnswer
module Calculators
class MarriageAbroadCalculatorTest < ActiveSupport::TestCase
context '#partner_british?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if partner is british' do
@calculator.partner_nationality = 'partner_british'
assert @calculator.partner_british?
end
should 'be false if partner is not british' do
@calculator.partner_nationality = 'not-partner_british'
refute @calculator.partner_british?
end
end
context '#partner_not_british?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if partner is not british' do
@calculator.partner_nationality = 'not-partner_british'
assert @calculator.partner_not_british?
end
should 'be false if partner is british' do
@calculator.partner_nationality = 'partner_british'
refute @calculator.partner_not_british?
end
end
context '#partner_is_national_of_ceremony_country?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if partner is a national of the ceremony country' do
@calculator.partner_nationality = 'partner_local'
assert @calculator.partner_is_national_of_ceremony_country?
end
should 'be false if partner is not a national of the ceremony country' do
@calculator.partner_nationality = 'not-partner_local'
refute @calculator.partner_is_national_of_ceremony_country?
end
end
context '#partner_is_not_national_of_ceremony_country?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if partner is not a national of the ceremony country' do
@calculator.partner_nationality = 'not-partner_local'
assert @calculator.partner_is_not_national_of_ceremony_country?
end
should 'be false if partner is a national of the ceremony country' do
@calculator.partner_nationality = 'partner_local'
refute @calculator.partner_is_not_national_of_ceremony_country?
end
end
context '#partner_is_neither_british_nor_a_national_of_ceremony_country?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if partner is a national of a country other than britain or the ceremony country' do
@calculator.partner_nationality = 'partner_other'
assert @calculator.partner_is_neither_british_nor_a_national_of_ceremony_country?
end
should 'be false if partner is not a national of a country other than britain or the ceremony country' do
@calculator.partner_nationality = 'not-partner_other'
refute @calculator.partner_is_neither_british_nor_a_national_of_ceremony_country?
end
end
context '#resident_of_uk?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if resident of uk' do
@calculator.resident_of = 'uk'
assert @calculator.resident_of_uk?
end
should 'be false if not a resident of uk' do
@calculator.resident_of = 'not-uk'
refute @calculator.resident_of_uk?
end
end
context '#resident_outside_of_uk?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if not resident of uk' do
@calculator.resident_of = 'not-uk'
assert @calculator.resident_outside_of_uk?
end
should 'be false if resident of uk' do
@calculator.resident_of = 'uk'
refute @calculator.resident_outside_of_uk?
end
end
context '#resident_of_ceremony_country?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if resident of ceremony country' do
@calculator.resident_of = 'ceremony_country'
assert @calculator.resident_of_ceremony_country?
end
should 'be false if not resident of ceremony country' do
@calculator.resident_of = 'not-ceremony_country'
refute @calculator.resident_of_ceremony_country?
end
end
context '#resident_outside_of_ceremony_country?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if not resident of ceremony country' do
@calculator.resident_of = 'not-ceremony_country'
assert @calculator.resident_outside_of_ceremony_country?
end
should 'be false if resident of ceremony country' do
@calculator.resident_of = 'ceremony_country'
refute @calculator.resident_outside_of_ceremony_country?
end
end
context '#resident_of_third_country?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if resident of third country' do
@calculator.resident_of = 'third_country'
assert @calculator.resident_of_third_country?
end
should 'be false if not resident of third country' do
@calculator.resident_of = 'not-third_country'
refute @calculator.resident_of_third_country?
end
end
context '#resident_outside_of_third_country?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true if resident_of != "third_country"' do
@calculator.resident_of = 'not-third_country'
assert @calculator.resident_outside_of_third_country?
end
should 'be false if resident_of == "third_country"' do
@calculator.resident_of = 'third_country'
refute @calculator.resident_outside_of_third_country?
end
end
context '#partner_is_opposite_sex?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true when partner is of the opposite sex' do
@calculator.sex_of_your_partner = 'opposite_sex'
assert @calculator.partner_is_opposite_sex?
end
should 'be false when partner is not of the opposite sex' do
@calculator.sex_of_your_partner = 'not-opposite_sex'
refute @calculator.partner_is_opposite_sex?
end
end
context '#partner_is_same_sex?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true when partner is of the same sex' do
@calculator.sex_of_your_partner = 'same_sex'
assert @calculator.partner_is_same_sex?
end
should 'be false when partner is not of the same sex' do
@calculator.sex_of_your_partner = 'not-same_sex'
refute @calculator.partner_is_same_sex?
end
end
context '#want_to_get_married?' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'be true when the couple want to get married' do
@calculator.marriage_or_pacs = 'marriage'
assert @calculator.want_to_get_married?
end
should "be false when the couple don't want to get married" do
@calculator.marriage_or_pacs = 'not-marriage'
refute @calculator.want_to_get_married?
end
end
context '#world_location' do
setup do
@calculator = MarriageAbroadCalculator.new
@calculator.ceremony_country = 'ceremony-country'
end
should 'return the world location for the given ceremony country' do
WorldLocation.stubs(:find).with('ceremony-country').returns('world-location')
assert_equal 'world-location', @calculator.world_location
end
should 'raise an InvalidResponse exception if the world location cannot be found for the ceremony country' do
WorldLocation.stubs(:find).with('ceremony-country').returns(nil)
assert_raise(InvalidResponse) do
@calculator.world_location
end
end
end
context '#fco_organisation' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'return the fco organisation for the world location' do
fco_organisation = stub.quacks_like(WorldwideOrganisation.new({}))
world_location = stub.quacks_like(WorldLocation.new({}))
world_location.stubs(fco_organisation: fco_organisation)
WorldLocation.stubs(:find).with('ceremony-country-with-fco-organisation').returns(world_location)
@calculator.ceremony_country = 'ceremony-country-with-fco-organisation'
assert_equal fco_organisation, @calculator.fco_organisation
end
should "return nil if the world location doesn't have an fco organisation" do
world_location = stub.quacks_like(WorldLocation.new({}))
world_location.stubs(fco_organisation: nil)
WorldLocation.stubs(:find).with('ceremony-country-without-fco-organisation').returns(world_location)
@calculator.ceremony_country = 'ceremony-country-without-fco-organisation'
assert_nil @calculator.fco_organisation
end
end
context '#overseas_passports_embassies' do
setup do
@calculator = MarriageAbroadCalculator.new
end
should 'return the offices that offer registrations of marriage and civil partnerships' do
world_office = stub('World Office')
organisation = stub.quacks_like(WorldwideOrganisation.new({}))
organisation.stubs(:offices_with_service).with('Registrations of Marriage and Civil Partnerships').returns([world_office])
@calculator.stubs(fco_organisation: organisation)
assert_equal [world_office], @calculator.overseas_passports_embassies
end
should 'return an empty array when there is no fco organisation' do
@calculator.stubs(fco_organisation: nil)
assert_equal [], @calculator.overseas_passports_embassies
end
end
context '#marriage_and_partnership_phrases' do
setup do
@data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
@data_query.stubs(
ss_marriage_countries?: false,
ss_marriage_countries_when_couple_british?: false,
ss_marriage_and_partnership?: false
)
@calculator = MarriageAbroadCalculator.new(data_query: @data_query)
end
should 'return ss_marriage when the ceremony country is in the list of same sex marriage countries' do
@calculator.ceremony_country = 'same-sex-marriage-country'
@data_query.stubs(:ss_marriage_countries?).with('same-sex-marriage-country').returns(true)
assert_equal 'ss_marriage', @calculator.marriage_and_partnership_phrases
end
should 'return ss_marriage when the ceremony country is in the list of same sex marriage countries for british couples' do
@calculator.ceremony_country = 'same-sex-marriage-country-for-british-couple'
@data_query.stubs(:ss_marriage_countries_when_couple_british?).with('same-sex-marriage-country-for-british-couple').returns(true)
assert_equal 'ss_marriage', @calculator.marriage_and_partnership_phrases
end
should 'return ss_marriage_and_partnership when the ceremony country is in the list of same sex marriage and partnership countries' do
@calculator.ceremony_country = 'same-sex-marriage-and-partnership-country'
@data_query.stubs(:ss_marriage_and_partnership?).with('same-sex-marriage-and-partnership-country').returns(true)
assert_equal 'ss_marriage_and_partnership', @calculator.marriage_and_partnership_phrases
end
end
context '#ceremony_country_name' do
should 'return the name of the world location associated with the ceremony country' do
world_location = stub.quacks_like(WorldLocation.new({}))
world_location.stubs(name: 'world-location-name')
calculator = MarriageAbroadCalculator.new
calculator.stubs(world_location: world_location)
assert_equal 'world-location-name', calculator.ceremony_country_name
end
end
context '#country_name_lowercase_prefix' do
setup do
@country_name_formatter = stub.quacks_like(CountryNameFormatter.new)
@calculator = MarriageAbroadCalculator.new(country_name_formatter: @country_name_formatter)
@calculator.ceremony_country = 'country-slug'
end
should 'return the definitive article if ceremony country is in the list of countries with definitive article' do
@country_name_formatter.stubs(:requires_definite_article?).with('country-slug').returns(true)
@country_name_formatter.stubs(:definitive_article).with('country-slug').returns('the-country-name')
assert_equal 'the-country-name', @calculator.country_name_lowercase_prefix
end
should 'return the friendly country name if definitive article not required and friendly country name found' do
@country_name_formatter.stubs(:requires_definite_article?).with('country-slug').returns(false)
@country_name_formatter.stubs(:has_friendly_name?).with('country-slug').returns(true)
@country_name_formatter.stubs(:friendly_name).with('country-slug').returns('friendly-country-name')
assert_equal 'friendly-country-name', @calculator.country_name_lowercase_prefix
end
should 'return an html safe version of the friendly country name' do
@country_name_formatter.stubs(:requires_definite_article?).with('country-slug').returns(false)
@country_name_formatter.stubs(:has_friendly_name?).with('country-slug').returns(true)
@country_name_formatter.stubs(:friendly_name).with('country-slug').returns('friendly-country-name')
assert @calculator.country_name_lowercase_prefix.html_safe?
end
should 'return the ceremony country name if not in the list of definitive articles or friendly country names' do
@country_name_formatter.stubs(:requires_definite_article?).with('country-slug').returns(false)
@country_name_formatter.stubs(:has_friendly_name?).with('country-slug').returns(false)
@calculator.stubs(ceremony_country_name: 'country-name')
assert_equal 'country-name', @calculator.country_name_lowercase_prefix
end
end
context '#country_name_uppercase_prefix' do
setup do
@country_name_formatter = stub.quacks_like(CountryNameFormatter.new)
@calculator = MarriageAbroadCalculator.new(country_name_formatter: @country_name_formatter)
@calculator.ceremony_country = 'country-slug'
end
should 'return the ceremony country with upper case definite article' do
@country_name_formatter.stubs(:definitive_article).with('country-slug', true).returns('The-country-name')
assert_equal 'The-country-name', @calculator.country_name_uppercase_prefix
end
end
context '#country_name_partner_residence' do
setup do
@data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
@data_query.stubs(
british_overseas_territories?: false,
french_overseas_territories?: false,
dutch_caribbean_islands?: false
)
@calculator = MarriageAbroadCalculator.new(data_query: @data_query)
@calculator.ceremony_country = 'country-slug'
end
should 'return "British (overseas territories citizen)" when ceremony country is British overseas territory' do
@data_query.stubs(:british_overseas_territories?).with('country-slug').returns(true)
assert_equal 'British (overseas territories citizen)', @calculator.country_name_partner_residence
end
should 'return "French" when ceremony country is French overseas territory' do
@data_query.stubs(:french_overseas_territories?).with('country-slug').returns(true)
assert_equal 'French', @calculator.country_name_partner_residence
end
should 'return "Dutch" when ceremony country is in the Dutch Caribbean islands' do
@data_query.stubs(:dutch_caribbean_islands?).with('country-slug').returns(true)
assert_equal 'Dutch', @calculator.country_name_partner_residence
end
should 'return "Chinese" when ceremony country is Hong Kong' do
@calculator.ceremony_country = 'hong-kong'
assert_equal 'Chinese', @calculator.country_name_partner_residence
end
should 'return "Chinese" when ceremony country is Macao' do
@calculator.ceremony_country = 'macao'
assert_equal 'Chinese', @calculator.country_name_partner_residence
end
should 'return "National of <country_name_lowercase_prefix>" in all other cases' do
@calculator.stubs(country_name_lowercase_prefix: 'country-name-lowercase-prefix')
assert_equal 'National of country-name-lowercase-prefix', @calculator.country_name_partner_residence
end
end
context '#embassy_or_consulate_ceremony_country' do
setup do
@registrations_data_query = stub.quacks_like(RegistrationsDataQuery.new)
@registrations_data_query.stubs(
has_consulate?: false,
has_consulate_general?: false
)
@calculator = MarriageAbroadCalculator.new(registrations_data_query: @registrations_data_query)
@calculator.ceremony_country = 'country-slug'
end
should 'return "consulate" if ceremony country has consulate' do
@registrations_data_query.stubs(:has_consulate?).with('country-slug').returns(true)
assert_equal 'consulate', @calculator.embassy_or_consulate_ceremony_country
end
should 'return "consulate" if ceremony country has consulate general' do
@registrations_data_query.stubs(:has_consulate_general?).with('country-slug').returns(true)
assert_equal 'consulate', @calculator.embassy_or_consulate_ceremony_country
end
should 'return "embassy" if ceremony country has neither consulate nor consulate general' do
assert_equal 'embassy', @calculator.embassy_or_consulate_ceremony_country
end
end
context '#ceremony_country_is_french_overseas_territory?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:french_overseas_territories?).with('ceremony-country').returns('french-overseas-territory')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'french-overseas-territory', calculator.ceremony_country_is_french_overseas_territory?
end
end
context '#opposite_sex_consular_cni_country' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_consular_cni_countries?).with('ceremony-country').returns('opposite-sex-consular-cni-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'opposite-sex-consular-cni-country', calculator.opposite_sex_consular_cni_country?
end
end
context '#opposite_sex_consular_cni_in_nearby_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_consular_cni_in_nearby_country?).with('ceremony-country').returns('opposite-sex-consular-cni-in-nearby-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'opposite-sex-consular-cni-in-nearby-country', calculator.opposite_sex_consular_cni_in_nearby_country?
end
end
context '#opposite_sex_no_marriage_related_consular_services_in_ceremony_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_no_marriage_related_consular_services?).with('ceremony-country').returns('opposite-sex-no-marriage-related-consular-servies')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'opposite-sex-no-marriage-related-consular-servies', calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country?
end
end
context '#opposite_sex_affirmation_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_affirmation_countries?).with('ceremony-country').returns('opposite-sex-affirmation-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'opposite-sex-affirmation-country', calculator.opposite_sex_affirmation_country?
end
end
context '#ceremony_country_in_the_commonwealth' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:commonwealth_country?).with('ceremony-country').returns('commonwealth-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'commonwealth-country', calculator.ceremony_country_in_the_commonwealth?
end
end
context '#ceremony_country_is_british_overseas_territory?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:british_overseas_territories?).with('ceremony-country').returns('british-overseas-territory')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'british-overseas-territory', calculator.ceremony_country_is_british_overseas_territory?
end
end
context '#opposite_sex_no_consular_cni_country' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_no_consular_cni_countries?).with('ceremony-country').returns('opposite-sex-no-consular-cni-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'opposite-sex-no-consular-cni-country', calculator.opposite_sex_no_consular_cni_country?
end
end
context '#opposite_sex_marriage_via_local_authorities?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_marriage_via_local_authorities?).with('ceremony-country').returns('opposite-sex-marriage-via-local-authorities')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'opposite-sex-marriage-via-local-authorities', calculator.opposite_sex_marriage_via_local_authorities?
end
end
context '#opposite_sex_in_other_countries?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_other_countries?).with('ceremony-country').returns('opposite-sex-in-other-countries')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'opposite-sex-in-other-countries', calculator.opposite_sex_in_other_countries?
end
end
context '#same_sex_ceremony_country_unknown_or_has_no_embassies?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:ss_unknown_no_embassies?).with('ceremony-country').returns('unknown-or-no-embassies')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'unknown-or-no-embassies', calculator.same_sex_ceremony_country_unknown_or_has_no_embassies?
end
end
context '#same_sex_marriage_not_possible?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
calculator = MarriageAbroadCalculator.new(data_query: data_query)
data_query.stubs(:ss_marriage_not_possible?).with('ceremony-country', calculator).returns('same-sex-marriage-not-possible')
calculator.ceremony_country = 'ceremony-country'
assert_equal 'same-sex-marriage-not-possible', calculator.same_sex_marriage_not_possible?
end
end
context '#same_sex_marriage_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:ss_marriage_countries?).with('ceremony-country').returns('same-sex-marriage-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'same-sex-marriage-country', calculator.same_sex_marriage_country?
end
end
context '#same_sex_marriage_country_when_couple_british?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:ss_marriage_countries_when_couple_british?).with('ceremony-country').returns('same-sex-marriage-country-when-couple-british')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'same-sex-marriage-country-when-couple-british', calculator.same_sex_marriage_country_when_couple_british?
end
end
context '#same_sex_marriage_and_civil_partnership?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:ss_marriage_and_partnership?).with('ceremony-country').returns('same-sex-marriage-and-civil-partnership')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'same-sex-marriage-and-civil-partnership', calculator.same_sex_marriage_and_civil_partnership?
end
end
context 'civil_partnership_equivalent_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:cp_equivalent_countries?).with('ceremony-country').returns('civil-partnership-equivalent-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'civil-partnership-equivalent-country', calculator.civil_partnership_equivalent_country?
end
end
context 'civil_partnership_cni_not_required_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:cp_cni_not_required_countries?).with('ceremony-country').returns('civil-partnership-cni-not-required-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'civil-partnership-cni-not-required-country', calculator.civil_partnership_cni_not_required_country?
end
end
context 'civil_partnership_consular_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:cp_consular_countries?).with('ceremony-country').returns('civil-partnership-consular-country')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'civil-partnership-consular-country', calculator.civil_partnership_consular_country?
end
end
context 'country_without_consular_facilities?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:countries_without_consular_facilities?).with('ceremony-country').returns('country-without-consular-facilities')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'country-without-consular-facilities', calculator.country_without_consular_facilities?
end
end
context 'opposite_sex_21_days_residency_required?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:os_21_days_residency_required_countries?).with('ceremony-country').returns('21-days-residency-required')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal '21-days-residency-required', calculator.opposite_sex_21_days_residency_required?
end
end
context 'ceremony_country_is_dutch_caribbean_island?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:dutch_caribbean_islands?).with('ceremony-country').returns('dutch-caribbean-island')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'dutch-caribbean-island', calculator.ceremony_country_is_dutch_caribbean_island?
end
end
context 'requires_7_day_notice?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
data_query.stubs(:requires_7_day_notice?).with('ceremony-country').returns('requires-7-day-notice')
calculator = MarriageAbroadCalculator.new(data_query: data_query)
calculator.ceremony_country = 'ceremony-country'
assert_equal 'requires-7-day-notice', calculator.requires_7_day_notice?
end
end
context 'same_sex_alt_fees_table_country?' do
should 'delegate to the data query' do
data_query = stub.quacks_like(MarriageAbroadDataQuery.new)
calculator = MarriageAbroadCalculator.new(data_query: data_query)
data_query.stubs(:ss_alt_fees_table_country?).with('ceremony-country', calculator).returns('same-sex-alt-fees-table')
calculator.ceremony_country = 'ceremony-country'
assert_equal 'same-sex-alt-fees-table', calculator.same_sex_alt_fees_table_country?
end
end
context '#civil_partnership_institution_name' do
should 'return "High Commission" if the ceremony country is cyprus' do
calculator = MarriageAbroadCalculator.new
calculator.ceremony_country = 'cyprus'
assert_equal 'High Commission', calculator.civil_partnership_institution_name
end
should 'return "British embassy or consulate" if the ceremony country is not cyprus' do
calculator = MarriageAbroadCalculator.new
calculator.ceremony_country = 'not-cyprus'
assert_equal 'British embassy or consulate', calculator.civil_partnership_institution_name
end
end
context '#outcome_path_when_resident_in_uk' do
should 'build the path' do
calculator = MarriageAbroadCalculator.new
calculator.ceremony_country = 'ceremony-country'
calculator.partner_nationality = 'partner-nationality'
calculator.sex_of_your_partner = 'sex-of-your-partner'
expected_path = '/marriage-abroad/y/ceremony-country/uk/partner-nationality/sex-of-your-partner'
assert_equal expected_path, calculator.outcome_path_when_resident_in_uk
end
end
context '#outcome_path_when_resident_in_ceremony_country' do
should 'build the path' do
calculator = MarriageAbroadCalculator.new
calculator.ceremony_country = 'ceremony-country'
calculator.partner_nationality = 'partner-nationality'
calculator.sex_of_your_partner = 'sex-of-your-partner'
expected_path = '/marriage-abroad/y/ceremony-country/ceremony_country/partner-nationality/sex-of-your-partner'
assert_equal expected_path, calculator.outcome_path_when_resident_in_ceremony_country
end
end
end
end
end