lebowski 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/History.md +3 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +84 -0
  4. data/README.md +146 -0
  5. data/Rakefile +42 -0
  6. data/bin/lebowski +26 -0
  7. data/bin/lebowski-spec +29 -0
  8. data/bin/lebowski-start-server +24 -0
  9. data/lib/lebowski.rb +15 -0
  10. data/lib/lebowski/core.rb +35 -0
  11. data/lib/lebowski/foundation.rb +52 -0
  12. data/lib/lebowski/foundation/application.rb +315 -0
  13. data/lib/lebowski/foundation/core.rb +61 -0
  14. data/lib/lebowski/foundation/core_query.rb +231 -0
  15. data/lib/lebowski/foundation/dom_element.rb +114 -0
  16. data/lib/lebowski/foundation/errors/argument_invalid_type.rb +31 -0
  17. data/lib/lebowski/foundation/errors/unexpected_type.rb +30 -0
  18. data/lib/lebowski/foundation/mixins/collection_item_view_support.rb +87 -0
  19. data/lib/lebowski/foundation/mixins/delegate_support.rb +22 -0
  20. data/lib/lebowski/foundation/mixins/inline_text_field_support.rb +29 -0
  21. data/lib/lebowski/foundation/mixins/key_check.rb +35 -0
  22. data/lib/lebowski/foundation/mixins/list_item_view_support.rb +36 -0
  23. data/lib/lebowski/foundation/mixins/positioned_element.rb +20 -0
  24. data/lib/lebowski/foundation/mixins/stall_support.rb +79 -0
  25. data/lib/lebowski/foundation/mixins/user_actions.rb +302 -0
  26. data/lib/lebowski/foundation/mixins/wait_actions.rb +44 -0
  27. data/lib/lebowski/foundation/object_array.rb +305 -0
  28. data/lib/lebowski/foundation/panes/alert.rb +117 -0
  29. data/lib/lebowski/foundation/panes/main.rb +20 -0
  30. data/lib/lebowski/foundation/panes/menu.rb +100 -0
  31. data/lib/lebowski/foundation/panes/modal.rb +21 -0
  32. data/lib/lebowski/foundation/panes/palette.rb +21 -0
  33. data/lib/lebowski/foundation/panes/pane.rb +24 -0
  34. data/lib/lebowski/foundation/panes/panel.rb +25 -0
  35. data/lib/lebowski/foundation/panes/picker.rb +43 -0
  36. data/lib/lebowski/foundation/panes/sheet.rb +21 -0
  37. data/lib/lebowski/foundation/proxy_factory.rb +87 -0
  38. data/lib/lebowski/foundation/proxy_object.rb +670 -0
  39. data/lib/lebowski/foundation/sc_object.rb +38 -0
  40. data/lib/lebowski/foundation/views/button.rb +20 -0
  41. data/lib/lebowski/foundation/views/checkbox.rb +63 -0
  42. data/lib/lebowski/foundation/views/collection.rb +304 -0
  43. data/lib/lebowski/foundation/views/container.rb +32 -0
  44. data/lib/lebowski/foundation/views/disclosure.rb +59 -0
  45. data/lib/lebowski/foundation/views/grid.rb +21 -0
  46. data/lib/lebowski/foundation/views/label.rb +30 -0
  47. data/lib/lebowski/foundation/views/list.rb +67 -0
  48. data/lib/lebowski/foundation/views/list_item.rb +280 -0
  49. data/lib/lebowski/foundation/views/menu_item.rb +27 -0
  50. data/lib/lebowski/foundation/views/radio.rb +32 -0
  51. data/lib/lebowski/foundation/views/segmented.rb +97 -0
  52. data/lib/lebowski/foundation/views/select_field.rb +139 -0
  53. data/lib/lebowski/foundation/views/support/simple_item_array.rb +249 -0
  54. data/lib/lebowski/foundation/views/text_field.rb +108 -0
  55. data/lib/lebowski/foundation/views/view.rb +108 -0
  56. data/lib/lebowski/runtime.rb +7 -0
  57. data/lib/lebowski/runtime/errors/remote_control_command_execution_error.rb +9 -0
  58. data/lib/lebowski/runtime/errors/remote_control_command_timeout_error.rb +9 -0
  59. data/lib/lebowski/runtime/errors/remote_control_error.rb +9 -0
  60. data/lib/lebowski/runtime/errors/selenium_server_error.rb +9 -0
  61. data/lib/lebowski/runtime/object_encoder.rb +123 -0
  62. data/lib/lebowski/runtime/sprout_core_driver.rb +14 -0
  63. data/lib/lebowski/runtime/sprout_core_extensions.rb +600 -0
  64. data/lib/lebowski/scui.rb +18 -0
  65. data/lib/lebowski/scui/mixins/node_item_view_support.rb +136 -0
  66. data/lib/lebowski/scui/mixins/terminal_view_support.rb +25 -0
  67. data/lib/lebowski/scui/views/combo_box.rb +119 -0
  68. data/lib/lebowski/scui/views/date_picker.rb +148 -0
  69. data/lib/lebowski/scui/views/linkit.rb +36 -0
  70. data/lib/lebowski/spec.rb +17 -0
  71. data/lib/lebowski/spec/core.rb +21 -0
  72. data/lib/lebowski/spec/matchers/be.rb +63 -0
  73. data/lib/lebowski/spec/matchers/has.rb +40 -0
  74. data/lib/lebowski/spec/matchers/match_supporters/has_object_function.rb +67 -0
  75. data/lib/lebowski/spec/matchers/match_supporters/has_predicate_with_no_prefix.rb +50 -0
  76. data/lib/lebowski/spec/matchers/match_supporters/has_predicate_with_prefix_has.rb +50 -0
  77. data/lib/lebowski/spec/matchers/match_supporters/match_supporter.rb +29 -0
  78. data/lib/lebowski/spec/matchers/method_missing.rb +24 -0
  79. data/lib/lebowski/spec/operators/operator.rb +20 -0
  80. data/lib/lebowski/spec/operators/that.rb +116 -0
  81. data/lib/lebowski/spec/util.rb +26 -0
  82. data/lib/lebowski/version.rb +17 -0
  83. data/resources/selenium-server.jar +0 -0
  84. data/resources/user-extensions.js +1421 -0
  85. metadata +198 -0
@@ -0,0 +1,36 @@
1
+ module Lebowski
2
+ module SCUI
3
+ module Views
4
+
5
+ class CanvasView < Lebowski::Foundation::Views::CollectionView
6
+ representing_sc_class 'LinkIt.CanvasView'
7
+
8
+ def nodes
9
+ return item_views
10
+ end
11
+
12
+ def empty?
13
+ return self['isEmpty']
14
+ end
15
+
16
+ protected
17
+ def create_item_views_object_array()
18
+ return Support::NodeItemViewArray.new self
19
+ end
20
+ end
21
+
22
+ module Support
23
+
24
+ class NodeItemViewArray < Lebowski::Foundation::Views::Support::CollectionItemViewArray
25
+ def mix_in_support_for_object(obj)
26
+ if not obj.class.ancestors.member? Lebowski::SCUI::Mixins::NodeItemViewSupport
27
+ obj.extend Lebowski::SCUI::Mixins::NodeItemViewSupport
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ require File.expand_path(File.dirname(__FILE__) + '/../lebowski')
7
+ require File.expand_path(File.dirname(__FILE__) + '/spec/core')
8
+ require File.expand_path(File.dirname(__FILE__) + '/spec/util')
9
+ require File.expand_path(File.dirname(__FILE__) + '/spec/operators/operator')
10
+ require File.expand_path(File.dirname(__FILE__) + '/spec/operators/that')
11
+ require File.expand_path(File.dirname(__FILE__) + '/spec/matchers/match_supporters/match_supporter')
12
+ require File.expand_path(File.dirname(__FILE__) + '/spec/matchers/match_supporters/has_object_function')
13
+ require File.expand_path(File.dirname(__FILE__) + '/spec/matchers/match_supporters/has_predicate_with_no_prefix')
14
+ require File.expand_path(File.dirname(__FILE__) + '/spec/matchers/match_supporters/has_predicate_with_prefix_has')
15
+ require File.expand_path(File.dirname(__FILE__) + '/spec/matchers/be')
16
+ require File.expand_path(File.dirname(__FILE__) + '/spec/matchers/has')
17
+ require File.expand_path(File.dirname(__FILE__) + '/spec/matchers/method_missing')
@@ -0,0 +1,21 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ #
7
+ # matcher is to only be applied to an object that derives from
8
+ # Lebowksi::Foundation::Object class otherwise an exception will
9
+ # be raised
10
+ #
11
+ # Usage:
12
+ #
13
+ # myobject.should exist_in_app => myobject.exists? == true
14
+ # myobject.should_not exist_in_app => myobject.exists? == false
15
+ #
16
+ Spec::Matchers.define :exist_in_app do
17
+ match do |object|
18
+ object.exists?
19
+ end
20
+ end
21
+
@@ -0,0 +1,63 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Matchers
9
+
10
+ #
11
+ # Create owr own Be class that inherits from RSpec's Be class. This class
12
+ # adds some logic to check for predicates that have a prefix is_. If
13
+ # there is no such prefix then we hand back control to parent class to
14
+ # apply the default pattern matching
15
+ #
16
+ # We are trying to accomplish the following:
17
+ #
18
+ # myobject.should be_orange ==> myobject.is_orange? == true
19
+ #
20
+ # RSpec's default implementation of Be does not support checks for the is_
21
+ # prefix.
22
+ #
23
+ # Ideally, it would've been better if the original class had hooks in it
24
+ # to try custom patterns before ultimately applying the default pattern
25
+ # checks
26
+ #
27
+ class Be < ::Spec::Matchers::BePredicate
28
+
29
+ def matches?(actual)
30
+
31
+ begin
32
+ return @result = actual.__send__("is_#{@expected.to_s}?".to_sym, *@args)
33
+ rescue NoMethodError => nme
34
+ rescue ArgumentError => ae
35
+ end
36
+
37
+ begin
38
+ return @result = actual.__send__("#{@expected.to_s}?".to_sym, *@args)
39
+ rescue NoMethodError => nme
40
+ rescue ArgumentError => ae
41
+ end
42
+
43
+ begin
44
+ return @result = actual.__send__("is_#{@expected.to_s}".to_sym, *@args)
45
+ rescue NoMethodError => nme
46
+ rescue ArgumentError => ae
47
+ end
48
+
49
+ begin
50
+ return @result = actual.__send__(@expected, *@args)
51
+ rescue NoMethodError => nme
52
+ rescue ArgumentError => ae
53
+ end
54
+
55
+ # None of the above options worked. Now we can default back to the
56
+ # parent object's approach
57
+ super
58
+ end
59
+
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,40 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Matchers
9
+
10
+ #
11
+ # Create owr own Has class that inherits from RSpec's Has class. This class
12
+ # adds some logic to check if the given "actual" object has a property with
13
+ # the name extracted from @expected. If not, then pass control back to the
14
+ # parent class.
15
+ #
16
+ # Ideally it would have been better if the original Has class provided hooks
17
+ # to include custom pattern checks that are used before the default pattern
18
+ # checks are performed.
19
+ #
20
+ class Has < ::Spec::Matchers::Has
21
+
22
+ def matches?(actual)
23
+ support = HasPredicateWithPrefixHas.new(actual, @expected, *@args)
24
+ return support.result if support.has_match?
25
+
26
+ support = HasPredicateWithNoPrefix.new(actual, @expected, *@args)
27
+ return support.result if support.has_match?
28
+
29
+ support = HasObjectFunction.new(actual, @expected, *@args)
30
+ return support.result if support.has_match?
31
+
32
+ # None of the above options worked. Now we can default back to the
33
+ # parent object's approach
34
+ super
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,67 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Matchers
9
+
10
+ class HasObjectFunction < MatchSupporter
11
+
12
+ def has_match?()
13
+
14
+ return false if @args.length == 0
15
+
16
+ method_name = obj_property(@expected)
17
+
18
+ ret_val = nil
19
+ invoked_method = false
20
+
21
+ # Try with arguments
22
+ begin
23
+ args = @args.clone; args.pop
24
+ ret_val = @object.__send__(method_name, *args)
25
+ invoked_method = true
26
+ rescue NoMethodError => nme
27
+ rescue ArgumentError => ae
28
+ end
29
+
30
+ # Try with no arguments
31
+ begin
32
+ if not invoked_method
33
+ ret_val = @object.__send__(method_name)
34
+ invoked_method = true
35
+ end
36
+ rescue NoMethodError => nme
37
+ rescue ArgumentError => ae
38
+ end
39
+
40
+ return false if not invoked_method
41
+
42
+ operator = @args[@args.length - 1]
43
+ if operator.kind_of? Lebowski::Spec::Operators::Operator
44
+ @result = operator.evaluate(ret_val)
45
+ return true
46
+ end
47
+
48
+ @result = Lebowski::Spec::Util.match?(@args[@args.length - 1], ret_val)
49
+
50
+ return true
51
+
52
+ end
53
+
54
+ private
55
+
56
+ def obj_property(sym)
57
+ ["has_", "have_"].each do |prefix|
58
+ if sym.to_s =~ /^#{prefix}/
59
+ return sym.to_s.sub(prefix, "").to_sym
60
+ end
61
+ end
62
+ end
63
+
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,50 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Matchers
9
+
10
+ class HasPredicateWithNoPrefix < MatchSupporter
11
+
12
+ def has_match?()
13
+
14
+ executed_method = false
15
+
16
+ method_name = predicate_with_no_prefix(@expected)
17
+
18
+ # Try with arguments
19
+ begin
20
+ @result = @object.__send__(method_name, *@args)
21
+ executed_method = true
22
+ rescue NoMethodError => nme
23
+ rescue ArgumentError => ae
24
+ end
25
+
26
+ return true if executed_method
27
+
28
+ # Try with no arguments
29
+ begin
30
+ @result = @object.__send__(method_name)
31
+ executed_method = true
32
+ rescue NoMethodError => nme
33
+ rescue ArgumentError => ae
34
+ end
35
+
36
+ return executed_method
37
+
38
+ end
39
+
40
+ private
41
+
42
+ def predicate_with_no_prefix(sym)
43
+ return (sym.to_s.sub('have_', '') << '?').to_sym
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Matchers
9
+
10
+ class HasPredicateWithPrefixHas < MatchSupporter
11
+
12
+ def has_match?()
13
+
14
+ executed_method = false
15
+
16
+ method_name = predicate_with_prefix_has(@expected)
17
+
18
+ # Try with arguments
19
+ begin
20
+ @result = @object.__send__(method_name, *@args)
21
+ executed_method = true
22
+ rescue NoMethodError => nme
23
+ rescue ArgumentError => ae
24
+ end
25
+
26
+ return true if executed_method
27
+
28
+ # Try with no arguments
29
+ begin
30
+ @result = @object.__send__(method_name)
31
+ executed_method = true
32
+ rescue NoMethodError => nme
33
+ rescue ArgumentError => ae
34
+ end
35
+
36
+ return executed_method
37
+
38
+ end
39
+
40
+ private
41
+
42
+ def predicate_with_prefix_has(sym)
43
+ return (sym.to_s.sub('have_', 'has_') << '?').to_sym
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,29 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Matchers
9
+
10
+ class MatchSupporter
11
+
12
+ attr_reader :result
13
+
14
+ def initialize(object, expected, *args)
15
+ @object = object
16
+ @expected = expected
17
+ @args = args
18
+ @result = nil
19
+ end
20
+
21
+ def has_match?()
22
+ return false
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Spec
7
+ module Matchers
8
+
9
+ #
10
+ # Replacing RSpec's default method_missing implementation so that we can
11
+ # include our own special default hooks that allows spec tests to look
12
+ # more readable.
13
+ #
14
+ # Ideally it would have been better if RSpec provided some nice hooks to
15
+ # try other default pattern matchers
16
+ #
17
+ def method_missing(sym, *args, &block)
18
+ return Lebowski::Spec::Matchers::Be.new(sym, *args) if sym.to_s =~ /^be_/
19
+ return Lebowski::Spec::Matchers::Has.new(sym, *args) if sym.to_s =~ /^have_/
20
+ return Lebowski::Spec::Operators::That.new(sym, *args) if sym.to_s =~ /^that_/
21
+ super
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Operators
9
+
10
+ class Operator
11
+
12
+ def evaluate(value)
13
+
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,116 @@
1
+ # ==========================================================================
2
+ # Project: Lebowski Framework - The SproutCore Test Automation Framework
3
+ # License: Licensed under MIT license (see License.txt)
4
+ # ==========================================================================
5
+
6
+ module Lebowski
7
+ module Spec
8
+ module Operators
9
+
10
+ class That < Operator
11
+
12
+ def initialize(sym, *args)
13
+ @sym = sym
14
+ @args = args
15
+ end
16
+
17
+ def evaluate(value)
18
+ case operator
19
+ when :not_empty
20
+ return not_empty? value
21
+ when :empty
22
+ return empty? value
23
+ when :between
24
+ return between? value
25
+ when :at_most
26
+ return at_most? value
27
+ when :at_least
28
+ return at_least? value
29
+ when :greater_than
30
+ return greater_than? value
31
+ when :less_than
32
+ return less_than? value
33
+ when :contains
34
+ return contains? value
35
+ when :matches
36
+ return matches? value
37
+ when :equals
38
+ return equals? value
39
+ when :equal_to
40
+ return equals? value
41
+ else
42
+ raise ArgumentError "Invalid that operator: #{operator}"
43
+ end
44
+ end
45
+
46
+ def operator()
47
+ ["that_is_", "that_"].each do |prefix|
48
+ if @sym =~ /^#{prefix}/
49
+ return @sym.to_s.sub(prefix, "").to_sym
50
+ end
51
+ end
52
+ end
53
+
54
+ def method_missing(sym, *args, &block)
55
+ return self
56
+ end
57
+
58
+ private
59
+
60
+ def not_empty?(value)
61
+ return (not empty? value)
62
+ end
63
+
64
+ def empty?(value)
65
+ return true if value.nil?
66
+ return value.length == 0 if value.kind_of?(Array) or value.kind_of?(String)
67
+ return false
68
+ end
69
+
70
+ def between?(value)
71
+ return false if not value.kind_of? Numeric
72
+ min = @args[0]
73
+ max = @args[1]
74
+ return ((value >= min) and (value <= max))
75
+ end
76
+
77
+ def at_least?(value)
78
+ return false if not value.kind_of? Numeric
79
+ return value >= @args[0]
80
+ end
81
+
82
+ def at_most?(value)
83
+ return false if not value.kind_of? Numeric
84
+ return value <= @args[0]
85
+ end
86
+
87
+ def greater_than?(value)
88
+ return false if not value.kind_of? Numeric
89
+ return value > @args[0]
90
+ end
91
+
92
+ def less_than?(value)
93
+ return false if not value.kind_of? Numeric
94
+ return value < @args[0]
95
+ end
96
+
97
+ def contains?(value)
98
+ return false if value.nil?
99
+ @args.all? do |x|
100
+ value.member? x
101
+ end
102
+ end
103
+
104
+ def matches?(value)
105
+ return Lebowski::Spec::Util.match?(@args[0], value)
106
+ end
107
+
108
+ def equals?(value)
109
+ return @args[0] == value
110
+ end
111
+
112
+ end
113
+
114
+ end
115
+ end
116
+ end