china_city_spec.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. expect(all('.city-city option').size).to eql 1
  32. expect(all('.city-district option').size).to eql 1
  33. end
  34. end
  35. scenario 'district' do
  36. within '.rails-helper' do
  37. select '--城市--'
  38. expect(find('.city-district').value).to be_blank
  39. expect(all('.city-district option').size).to eql 1
  40. end
  41. end
  42. end
  43. context 'select other parent' do
  44. scenario 'city and district' do
  45. within '.rails-helper' do
  46. select '江苏省'
  47. expect(find('.city-city').value).to be_blank
  48. expect(find('.city-district').value).to be_blank
  49. expect(all('.city-city option').size).to eql 14
  50. expect(all('.city-district option').size).to eql 1
  51. end
  52. end
  53. scenario 'district' do
  54. within '.rails-helper' do
  55. select '广州市'
  56. expect(find('.city-district').value).to be_blank
  57. expect(all('.city-district option').size).to eql 14
  58. end
  59. end
  60. end
  61. end
  62. end