china_city_spec.rb 1.8 KB

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