capybara-ui 0.10.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/capybara/ui.rb +33 -0
  3. data/lib/capybara/ui/assertions.rb +21 -0
  4. data/lib/{capybara-ui → capybara/ui}/capybara.rb +0 -0
  5. data/lib/capybara/ui/checkpoint.rb +113 -0
  6. data/lib/capybara/ui/conversions.rb +33 -0
  7. data/lib/capybara/ui/cucumber.rb +5 -0
  8. data/lib/capybara/ui/dsl.rb +109 -0
  9. data/lib/capybara/ui/instance_conversions.rb +21 -0
  10. data/lib/{capybara-ui → capybara/ui}/matchers.rb +4 -4
  11. data/lib/capybara/ui/optional_dependencies.rb +7 -0
  12. data/lib/capybara/ui/rails.rb +5 -0
  13. data/lib/capybara/ui/rails/role.rb +11 -0
  14. data/lib/capybara/ui/role.rb +21 -0
  15. data/lib/capybara/ui/text_table.rb +109 -0
  16. data/lib/capybara/ui/text_table/cell_text.rb +9 -0
  17. data/lib/capybara/ui/text_table/mapping.rb +42 -0
  18. data/lib/capybara/ui/text_table/transformations.rb +15 -0
  19. data/lib/capybara/ui/text_table/void_mapping.rb +10 -0
  20. data/lib/capybara/ui/version.rb +5 -0
  21. data/lib/capybara/ui/widgets.rb +63 -0
  22. data/lib/capybara/ui/widgets/check_box.rb +28 -0
  23. data/lib/capybara/ui/widgets/cucumber_methods.rb +75 -0
  24. data/lib/capybara/ui/widgets/document.rb +21 -0
  25. data/lib/capybara/ui/widgets/dsl.rb +49 -0
  26. data/lib/capybara/ui/widgets/field.rb +24 -0
  27. data/lib/capybara/ui/widgets/field_group.rb +331 -0
  28. data/lib/capybara/ui/widgets/form.rb +28 -0
  29. data/lib/capybara/ui/widgets/list.rb +202 -0
  30. data/lib/capybara/ui/widgets/list_item.rb +24 -0
  31. data/lib/capybara/ui/widgets/parts/container.rb +48 -0
  32. data/lib/capybara/ui/widgets/parts/struct.rb +119 -0
  33. data/lib/capybara/ui/widgets/radio_button.rb +64 -0
  34. data/lib/capybara/ui/widgets/select.rb +59 -0
  35. data/lib/capybara/ui/widgets/string_value.rb +45 -0
  36. data/lib/capybara/ui/widgets/table.rb +78 -0
  37. data/lib/capybara/ui/widgets/text_field.rb +29 -0
  38. data/lib/capybara/ui/widgets/widget.rb +394 -0
  39. data/lib/capybara/ui/widgets/widget/node_filter.rb +50 -0
  40. data/lib/capybara/ui/widgets/widget_class.rb +13 -0
  41. data/lib/capybara/ui/widgets/widget_name.rb +58 -0
  42. metadata +47 -43
  43. data/lib/capybara-ui.rb +0 -31
  44. data/lib/capybara-ui/assertions.rb +0 -19
  45. data/lib/capybara-ui/checkpoint.rb +0 -111
  46. data/lib/capybara-ui/conversions.rb +0 -31
  47. data/lib/capybara-ui/cucumber.rb +0 -5
  48. data/lib/capybara-ui/dsl.rb +0 -107
  49. data/lib/capybara-ui/instance_conversions.rb +0 -19
  50. data/lib/capybara-ui/optional_dependencies.rb +0 -5
  51. data/lib/capybara-ui/rails.rb +0 -5
  52. data/lib/capybara-ui/rails/role.rb +0 -9
  53. data/lib/capybara-ui/role.rb +0 -19
  54. data/lib/capybara-ui/text_table.rb +0 -107
  55. data/lib/capybara-ui/text_table/cell_text.rb +0 -7
  56. data/lib/capybara-ui/text_table/mapping.rb +0 -40
  57. data/lib/capybara-ui/text_table/transformations.rb +0 -13
  58. data/lib/capybara-ui/text_table/void_mapping.rb +0 -8
  59. data/lib/capybara-ui/version.rb +0 -3
  60. data/lib/capybara-ui/widgets.rb +0 -61
  61. data/lib/capybara-ui/widgets/check_box.rb +0 -26
  62. data/lib/capybara-ui/widgets/cucumber_methods.rb +0 -73
  63. data/lib/capybara-ui/widgets/document.rb +0 -19
  64. data/lib/capybara-ui/widgets/dsl.rb +0 -47
  65. data/lib/capybara-ui/widgets/field.rb +0 -22
  66. data/lib/capybara-ui/widgets/field_group.rb +0 -329
  67. data/lib/capybara-ui/widgets/form.rb +0 -26
  68. data/lib/capybara-ui/widgets/list.rb +0 -200
  69. data/lib/capybara-ui/widgets/list_item.rb +0 -22
  70. data/lib/capybara-ui/widgets/parts/container.rb +0 -46
  71. data/lib/capybara-ui/widgets/parts/struct.rb +0 -117
  72. data/lib/capybara-ui/widgets/radio_button.rb +0 -62
  73. data/lib/capybara-ui/widgets/select.rb +0 -57
  74. data/lib/capybara-ui/widgets/string_value.rb +0 -43
  75. data/lib/capybara-ui/widgets/table.rb +0 -76
  76. data/lib/capybara-ui/widgets/text_field.rb +0 -27
  77. data/lib/capybara-ui/widgets/widget.rb +0 -392
  78. data/lib/capybara-ui/widgets/widget/node_filter.rb +0 -48
  79. data/lib/capybara-ui/widgets/widget_class.rb +0 -11
  80. data/lib/capybara-ui/widgets/widget_name.rb +0 -56
@@ -1,48 +0,0 @@
1
- module CapybaraUI
2
- class Widget
3
- class NodeFilter
4
- attr_reader :selector
5
-
6
- def initialize(*selector)
7
- @selector = selector.flatten
8
- end
9
-
10
- def node(parent_widget, *args)
11
- parent_widget.root.find(*capybara_selector(*args))
12
- end
13
-
14
- def node?(parent_widget, *args)
15
- parent_widget.root.has_selector?(*capybara_selector(*args))
16
- end
17
-
18
- def nodeless?(parent_widget, *args)
19
- parent_widget.root.has_no_selector?(*capybara_selector(*args))
20
- end
21
-
22
- def nodes(parent_widget, *args)
23
- parent_widget.root.all(*capybara_selector(*args))
24
- end
25
-
26
- private
27
-
28
- def capybara_selector(*args)
29
- # TODO detect signature errors (e.g., passing a different arity than the
30
- # one required by the selector proc, etc)
31
- selector = if @selector.first.respond_to?(:call)
32
- @selector.first.call(*args)
33
- else
34
- @selector
35
- end
36
- selector = Array(selector).flatten
37
-
38
- defaults = {:wait => 0}
39
-
40
- if Hash === selector.last
41
- selector + [defaults.merge(selector.pop)]
42
- else
43
- selector + [defaults]
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,11 +0,0 @@
1
- module CapybaraUI
2
- module WidgetClass
3
- def self.new(selector, parent = Widget, &extensions)
4
- klass = Class.new(parent) { root selector }
5
-
6
- klass.class_eval(&extensions) if block_given?
7
-
8
- klass
9
- end
10
- end
11
- end
@@ -1,56 +0,0 @@
1
- module CapybaraUI
2
- # The name of a widget in a format-independent representation.
3
- class WidgetName < String
4
- CAMEL_CASE_FORMAT = /\A([A-Z][a-z]*)+\Z/
5
- SNAKE_CASE_FORMAT = /\A\w+\Z/
6
-
7
- # Constructs the widget name.
8
- #
9
- # @param name [String, Symbol] the name of the widget in primitive form
10
- def initialize(name)
11
- @name = name
12
- @canonical = canonical(@name)
13
- end
14
-
15
- # Returns the class for this widget name, in the given scope.
16
- def to_class(scope = Object)
17
- const = scope.const_get(@canonical)
18
-
19
- raise TypeError, "`#{@canonical}' is not a widget in this scope" \
20
- unless const < Widget
21
-
22
- const
23
- rescue NameError
24
- raise Missing, "couldn't find `#{@name}' widget in this scope"
25
- end
26
-
27
- def to_sym
28
- @canonical.to_sym
29
- end
30
-
31
- private
32
-
33
- def canonical(name)
34
- str = name.to_s
35
-
36
- case str
37
- when SNAKE_CASE_FORMAT
38
- camel_case_from_snake_case(str)
39
- when CAMEL_CASE_FORMAT
40
- str
41
- else
42
- raise ArgumentError, "`#{str.inspect}' is an unrecognized format. Try snake case or camel case."
43
- end
44
- end
45
-
46
- def camel_case_from_snake_case(name)
47
- capitalize_word = ->(word) { word[0].upcase + word[1..-1] }
48
- word_separator = '_'
49
-
50
- name
51
- .split(word_separator)
52
- .map(&capitalize_word)
53
- .join
54
- end
55
- end
56
- end