rsel 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/docs/development.md +8 -3
  2. data/docs/examples.md +119 -0
  3. data/docs/history.md +9 -0
  4. data/docs/index.md +3 -1
  5. data/docs/locators.md +72 -0
  6. data/docs/scoping.md +19 -5
  7. data/docs/todo.md +4 -2
  8. data/docs/usage.md +2 -2
  9. data/lib/rsel/exceptions.rb +1 -1
  10. data/lib/rsel/selenium_test.rb +37 -132
  11. data/lib/rsel/support.rb +138 -0
  12. data/rsel.gemspec +1 -1
  13. data/spec/selenium_test_spec.rb +103 -12
  14. data/spec/spec_helper.rb +1 -10
  15. data/spec/support_spec.rb +48 -0
  16. data/test/app.rb +6 -6
  17. metadata +8 -39
  18. data/vendor/rubyslim-0.1.1/.gitignore +0 -7
  19. data/vendor/rubyslim-0.1.1/README.md +0 -159
  20. data/vendor/rubyslim-0.1.1/Rakefile +0 -21
  21. data/vendor/rubyslim-0.1.1/bin/rubyslim +0 -10
  22. data/vendor/rubyslim-0.1.1/lib/rubyslim/list_deserializer.rb +0 -69
  23. data/vendor/rubyslim-0.1.1/lib/rubyslim/list_executor.rb +0 -12
  24. data/vendor/rubyslim-0.1.1/lib/rubyslim/list_serializer.rb +0 -45
  25. data/vendor/rubyslim-0.1.1/lib/rubyslim/ruby_slim.rb +0 -61
  26. data/vendor/rubyslim-0.1.1/lib/rubyslim/slim_error.rb +0 -3
  27. data/vendor/rubyslim-0.1.1/lib/rubyslim/slim_helper_library.rb +0 -23
  28. data/vendor/rubyslim-0.1.1/lib/rubyslim/socket_service.rb +0 -53
  29. data/vendor/rubyslim-0.1.1/lib/rubyslim/statement.rb +0 -79
  30. data/vendor/rubyslim-0.1.1/lib/rubyslim/statement_executor.rb +0 -174
  31. data/vendor/rubyslim-0.1.1/lib/rubyslim/table_to_hash_converter.rb +0 -32
  32. data/vendor/rubyslim-0.1.1/lib/test_module/library_new.rb +0 -13
  33. data/vendor/rubyslim-0.1.1/lib/test_module/library_old.rb +0 -12
  34. data/vendor/rubyslim-0.1.1/lib/test_module/should_not_find_test_slim_in_here/test_slim.rb +0 -7
  35. data/vendor/rubyslim-0.1.1/lib/test_module/simple_script.rb +0 -9
  36. data/vendor/rubyslim-0.1.1/lib/test_module/test_chain.rb +0 -5
  37. data/vendor/rubyslim-0.1.1/lib/test_module/test_slim.rb +0 -86
  38. data/vendor/rubyslim-0.1.1/lib/test_module/test_slim_with_arguments.rb +0 -23
  39. data/vendor/rubyslim-0.1.1/lib/test_module/test_slim_with_no_sut.rb +0 -5
  40. data/vendor/rubyslim-0.1.1/rubyslim.gemspec +0 -22
  41. data/vendor/rubyslim-0.1.1/spec/instance_creation_spec.rb +0 -40
  42. data/vendor/rubyslim-0.1.1/spec/it8f_spec.rb +0 -8
  43. data/vendor/rubyslim-0.1.1/spec/list_deserializer_spec.rb +0 -66
  44. data/vendor/rubyslim-0.1.1/spec/list_executor_spec.rb +0 -187
  45. data/vendor/rubyslim-0.1.1/spec/list_serialzer_spec.rb +0 -38
  46. data/vendor/rubyslim-0.1.1/spec/method_invocation_spec.rb +0 -127
  47. data/vendor/rubyslim-0.1.1/spec/slim_helper_library_spec.rb +0 -80
  48. data/vendor/rubyslim-0.1.1/spec/socket_service_spec.rb +0 -98
  49. data/vendor/rubyslim-0.1.1/spec/spec_helper.rb +0 -6
  50. data/vendor/rubyslim-0.1.1/spec/statement_executor_spec.rb +0 -50
  51. data/vendor/rubyslim-0.1.1/spec/statement_spec.rb +0 -17
  52. data/vendor/rubyslim-0.1.1/spec/table_to_hash_converter_spec.rb +0 -31
@@ -1,80 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require 'slim_helper_library'
3
- require 'statement_executor'
4
-
5
- SLIM_HELPER_LIBRARY_INSTANCE_NAME = "SlimHelperLibrary"
6
- ACTOR_INSTANCE_NAME = "scriptTableActor"
7
-
8
- describe SlimHelperLibrary do
9
- before() do
10
- @executor = StatementExecutor.new
11
- @executor.add_module("TestModule")
12
- @executor.create(ACTOR_INSTANCE_NAME, "TestSlim", ["0"]).should == "OK"
13
- @instance = @executor.instance(ACTOR_INSTANCE_NAME)
14
- @helper = SlimHelperLibrary.new(@executor)
15
- end
16
-
17
- it "can get current scriptTableActor" do
18
- @helper.get_fixture.should be @instance
19
- end
20
-
21
- it "can push and pop" do
22
- @helper.push_fixture
23
- @executor.create(ACTOR_INSTANCE_NAME, "TestSlim", ["1"])
24
- @helper.get_fixture.should_not be @instance
25
- @helper.pop_fixture
26
- @helper.get_fixture.should be @instance
27
- end
28
-
29
- it "can push and pop many" do
30
- @helper.push_fixture
31
- @executor.create(ACTOR_INSTANCE_NAME, "TestChain", []).should == "OK"
32
- one = @executor.instance(ACTOR_INSTANCE_NAME)
33
- one.should_not be_nil
34
- @helper.push_fixture
35
-
36
- @executor.create(ACTOR_INSTANCE_NAME, "SimpleScript", [])
37
- two = @executor.instance(ACTOR_INSTANCE_NAME)
38
- one.should_not be two
39
- @helper.get_fixture.should be two
40
-
41
- @helper.pop_fixture
42
- @helper.get_fixture.should be one
43
-
44
- @helper.pop_fixture
45
- @helper.get_fixture.should be @instance
46
-
47
- end
48
-
49
- end
50
-
51
-
52
- #@Test
53
- #public void testSlimHelperLibraryIsStoredInSlimExecutor() throws Exception {
54
- # Object helperLibrary = caller.getInstance(SLIM_HELPER_LIBRARY_INSTANCE_NAME);
55
- # assertTrue(helperLibrary instanceof SlimHelperLibrary);
56
- #}
57
- #
58
- #@Test
59
- #public void testSlimHelperLibraryHasStatementExecutor() throws Exception {
60
- # SlimHelperLibrary helperLibrary = (SlimHelperLibrary) caller.getInstance(SLIM_HELPER_LIBRARY_INSTANCE_NAME);
61
- # assertSame(caller, helperLibrary.getStatementExecutor());
62
- #}
63
- #
64
- #@Test
65
- #public void testSlimHelperLibraryCanPushAndPopFixture() throws Exception {
66
- # SlimHelperLibrary helperLibrary = (SlimHelperLibrary) caller.getInstance(SLIM_HELPER_LIBRARY_INSTANCE_NAME);
67
- # Object response = caller.create(ACTOR_INSTANCE_NAME, getTestClassName(), new Object[0]);
68
- # Object firstActor = caller.getInstance(ACTOR_INSTANCE_NAME);
69
- #
70
- # helperLibrary.pushFixture();
71
- #
72
- # response = caller.create(ACTOR_INSTANCE_NAME, getTestClassName(), new Object[] {"1"});
73
- # assertEquals("OK", response);
74
- # assertNotSame(firstActor, caller.getInstance(ACTOR_INSTANCE_NAME));
75
- #
76
- # helperLibrary.popFixture();
77
- #
78
- # assertSame(firstActor, caller.getInstance(ACTOR_INSTANCE_NAME));
79
- #}
80
- #
@@ -1,98 +0,0 @@
1
- require 'test/unit'
2
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
3
- require 'socket_service'
4
-
5
- class SocketServiceTest < Test::Unit::TestCase
6
- def setup
7
- @port = 12345
8
- @ss = SocketService.new()
9
- @connections = 0
10
- end
11
-
12
- def testOneConnection
13
- @ss.serve(@port) {@connections += 1}
14
- connect(@port)
15
- @ss.close()
16
- assert_equal(1, @connections)
17
- end
18
-
19
- def testManyConnections
20
- @ss.serve(@port) {@connections += 1}
21
- 10.times {connect(@port)}
22
- @ss.close()
23
- assert_equal(10, @connections)
24
- assert_equal(0, @ss.pendingSessions)
25
- end
26
-
27
- def testSocketSend
28
- @ss.serve(@port) do |serverSocket|
29
- serverSocket.write("hi")
30
- end
31
-
32
- clientSocket = TCPSocket.open("localhost", @port)
33
- answer = clientSocket.gets
34
- clientSocket.close
35
- assert_equal("hi", answer)
36
- @ss.close()
37
- end
38
-
39
- # TEST FREEZES!!!
40
- # We should not be able to keep the service alive by hitting
41
- # it with connections after we close it?
42
- def _testCantKeepAliveByConnectingAfterClose
43
- #set up a service that waits for a message and then dies.
44
- @ss.serve(@port) do |serverSocket|
45
- message = serverSocket.gets
46
- end
47
-
48
- #s1 is a connection to that service.
49
- s1 = TCPSocket.open("localhost", @port)
50
- sleep(0.1)
51
-
52
- #now start closing the server in a separate thread. It cannot
53
- #finish closing until s1 completes.
54
- Thread.start {@ss.close}
55
- sleep(0.1)
56
-
57
- #try to connect to the dying server.
58
- s2=nil
59
- Thread.start {s2 = TCPSocket.open("localhost", @port)}
60
- sleep(0.1)
61
- assert_equal(nil, s2, "shouldn't have connected")
62
- assert_not_equal(nil, s1, "Should have connected")
63
-
64
- #Complete the s1 session.
65
- s1.write("testCloseRaceCondition");
66
- s1.close
67
-
68
- #collect the pending s2 connection
69
- testThread = Thread.current
70
- @ss.serve(@port) {testThread.wakeup}
71
- Thread.stop
72
- assert_not_equal(nil, s2)
73
- s2.close
74
- @ss.close
75
- end
76
-
77
- def testSessionCount
78
- @ss.serve(@port) do |serverSocket|
79
- message = serverSocket.gets
80
- end
81
-
82
- s1 = nil;
83
- Thread.start {s1 = TCPSocket.open("localhost", @port)}
84
- sleep(0.2)
85
- assert_equal(1, @ss.pendingSessions);
86
- s1.write("testSessionCount");
87
- s1.close
88
- sleep(0.2)
89
- assert_equal(0, @ss.pendingSessions)
90
- @ss.close
91
- end
92
-
93
- def connect(port)
94
- s = TCPSocket.open("localhost", @port)
95
- sleep(0.1)
96
- s.close
97
- end
98
- end
@@ -1,6 +0,0 @@
1
- $: << File.expand_path(File.dirname(__FILE__) + "/../lib/rubyslim")
2
- require "rubygems"
3
- require "spec"
4
- require 'jcode'
5
- $KCODE="UTF8"
6
- require 'timeout'
@@ -1,50 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require "statement_executor"
3
-
4
- describe StatementExecutor do
5
- before do
6
- @executor = StatementExecutor.new
7
- end
8
-
9
- it "can split class names" do
10
- @executor.split_class_name("a::b::c").should == ["a", "b", "c"]
11
- end
12
-
13
- it "can convert module names to file names" do
14
- @executor.to_file_name("MyModuleName").should == "my_module_name"
15
- end
16
-
17
- it "can build the path name to a class" do
18
- @executor.make_path_to_class("ModuleOne::ModuleTwo::MyClass").should == "module_one/module_two/my_class"
19
- end
20
-
21
- it "can require a class" do
22
- @executor.add_module("MyModule")
23
- proc = proc {@executor.require_class("MyModule::MyClass")}
24
- proc.should raise_error(SlimError, /message:<<COULD_NOT_INVOKE_CONSTRUCTOR MyModule::MyClass failed to find in/)
25
- end
26
-
27
- it "can handle symbols whose values are objects" do
28
- @executor.set_symbol("foo", OpenStruct.new(:foo => "bar"))
29
- @executor.get_symbol("foo").foo.should == "bar"
30
- @executor.replace_symbol("$foo").foo.should == "bar"
31
- end
32
-
33
- describe "accessor translation" do
34
- class TestInstance
35
- attr_accessor :foo
36
- end
37
-
38
- before(:each) do
39
- @instance = TestInstance.new
40
- @executor.set_instance("test_instance", @instance)
41
- end
42
-
43
- it "should translate setters" do
44
- @executor.call("test_instance", "set_foo", "123")
45
- @instance.foo.should == "123"
46
- end
47
-
48
- end
49
-
50
- end
@@ -1,17 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require "statement"
3
-
4
- describe Statement do
5
- before do
6
- @statement = Statement.new("")
7
- end
8
-
9
- it "can translate slim class names to ruby class names" do
10
- @statement.slim_to_ruby_class("myPackage.MyClass").should == "MyPackage::MyClass"
11
- @statement.slim_to_ruby_class("this.that::theOther").should == "This::That::TheOther"
12
- end
13
-
14
- it "can translate slim method names to ruby method names" do
15
- @statement.slim_to_ruby_method("myMethod").should == "my_method"
16
- end
17
- end
@@ -1,31 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require 'table_to_hash_converter'
3
-
4
- def shouldNotChange(string)
5
- TableToHashConverter.convert(string).should == string
6
- end
7
-
8
- describe TableToHashConverter do
9
- [
10
- ["some string", "not a table"],
11
- ["<table>blah", "incomplete table"],
12
- ["<table><tr><td>hi</td></tr></table>", "too few columns"],
13
- ["<table><tr><td>hi</td><td>med</td><td>lo</td></tr></table>", "too many columns"]
14
- ].each do |string, reason|
15
- it "#{reason}: should not change '#{string}'" do
16
- shouldNotChange(string)
17
- end
18
- end
19
- end
20
-
21
- describe TableToHashConverter do
22
- [
23
- ["<table><tr><td>name</td><td>bob</td></tr></table>", {:name=>"bob"}],
24
- [" <table> <tr> <td> name </td> <td> bob </td> </tr> </table> ", {:name=>"bob"}],
25
- ["<table><tr><td>name</td><td>bob</td></tr><tr><td>addr</td><td>here</td></tr></table>", {:name=>'bob', :addr=>'here'}]
26
- ].each do |table, hash|
27
- it "should match #{table} to #{hash}" do
28
- TableToHashConverter.convert(table).should == hash
29
- end
30
- end
31
- end