taiwan_city_spec.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # encoding: utf-8
  2. require 'spec_helper'
  3. feature 'taiwan city', js: true do
  4. scenario 'select' do
  5. visit '/taiwan_city'
  6. within '.rails-helper' do
  7. select '广东省'
  8. select '深圳市'
  9. select '南山区'
  10. end
  11. within '.html-tag' do
  12. select '广东省'
  13. select '深圳市'
  14. select '南山区'
  15. end
  16. end
  17. describe 'clean' do
  18. before do
  19. visit '/taiwan_city'
  20. within '.rails-helper' do
  21. select '广东省'
  22. select '深圳市'
  23. select '南山区'
  24. end
  25. end
  26. context 'select empty parent' do
  27. scenario 'city and district' do
  28. within '.rails-helper' do
  29. select '--省份--'
  30. expect(find('.city-city').value).to be_blank
  31. expect(find('.city-district').value).to be_blank
  32. sleep 2
  33. expect(all('.city-city option').size).to eql 1
  34. expect(all('.city-district option').size).to eql 1
  35. end
  36. end
  37. scenario 'district' do
  38. within '.rails-helper' do
  39. select '--城市--'
  40. expect(find('.city-district').value).to be_blank
  41. sleep 2
  42. expect(all('.city-district option').size).to eql 1
  43. end
  44. end
  45. end
  46. context 'select other parent' do
  47. scenario 'city and district' do
  48. within '.rails-helper' do
  49. select '江苏省'
  50. expect(find('.city-city').value).to be_blank
  51. expect(find('.city-district').value).to be_blank
  52. sleep 2
  53. expect(all('.city-city option').size).to eql 14
  54. expect(all('.city-district option').size).to eql 1
  55. end
  56. end
  57. scenario 'district' do
  58. within '.rails-helper' do
  59. select '广州市'
  60. expect(find('.city-district').value).to be_blank
  61. sleep 2
  62. expect(all('.city-district option').size).to eql 14
  63. end
  64. end
  65. end
  66. end
  67. end