rsel 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
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,5 +0,0 @@
1
- module TestModule
2
- class TestSlimWithNoSut
3
-
4
- end
5
- end
@@ -1,22 +0,0 @@
1
-
2
- Gem::Specification.new do |s|
3
- s.name = "rubyslim"
4
- s.version = "0.1.1"
5
- s.summary = "Ruby SliM protocol for FitNesse"
6
- s.description = <<-EOS
7
- RubySliM implements the SliM protocol for the FitNesse
8
- acceptance testing framework.
9
- EOS
10
- s.authors = ["Robert C. Martin", "Doug Bradbury"]
11
- s.email = "unclebob@cleancoder.com"
12
- s.platform = Gem::Platform::RUBY
13
-
14
- s.add_development_dependency 'rspec', '~> 1.3.0'
15
- s.add_development_dependency 'rcov'
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.require_path = 'lib'
19
-
20
- s.executables = ['rubyslim']
21
- end
22
-
@@ -1,40 +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
- @caller = StatementExecutor.new
7
- end
8
-
9
- it "can create an instance" do
10
- response = @caller.create("x", "TestModule::TestSlim", [])
11
- response.should == "OK"
12
- x = @caller.instance("x")
13
- x.class.name.should == "TestModule::TestSlim"
14
- end
15
-
16
- it "can create an instance with arguments" do
17
- response = @caller.create("x", "TestModule::TestSlimWithArguments", ["3"])
18
- response.should == "OK"
19
- x = @caller.instance("x")
20
- x.arg.should == "3"
21
- end
22
-
23
- it "can create an instance with arguments that are symbols" do
24
- @caller.set_symbol("X", "3")
25
- response = @caller.create("x", "TestModule::TestSlimWithArguments", ["$X"])
26
- response.should == "OK"
27
- x = @caller.instance("x")
28
- x.arg.should == "3"
29
- end
30
-
31
- it "can't create an instance with the wrong number of arguments" do
32
- result = @caller.create("x", "TestModule::TestSlim", ["1", "noSuchArgument"])
33
- result.should include(Statement::EXCEPTION_TAG + "message:<<COULD_NOT_INVOKE_CONSTRUCTOR TestModule::TestSlim[2]>>")
34
- end
35
-
36
- it "can't create an instance if there is no class" do
37
- result = @caller.create("x", "TestModule::NoSuchClass", [])
38
- result.should include(Statement::EXCEPTION_TAG + "message:<<COULD_NOT_INVOKE_CONSTRUCTOR TestModule::NoSuchClass failed to find in []>>")
39
- end
40
- end
@@ -1,8 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
-
3
- describe "characters" do
4
- it "should be able to deal with it8f chars" do
5
- "Köln".should == "Köln"
6
- "Köln".size.should == 5
7
- end
8
- end
@@ -1,66 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require "list_serializer"
3
- require "list_deserializer"
4
-
5
- describe ListDeserializer do
6
- before do
7
- @list = []
8
- end
9
-
10
- it "can't deserialize a null string" do
11
- proc {ListDeserializer.deserialize(nil)}.should raise_error(ListDeserializer::SyntaxError)
12
- end
13
-
14
- it "can't deserialize empty string" do
15
- proc {ListDeserializer.deserialize("")}.should raise_error(ListDeserializer::SyntaxError)
16
- end
17
-
18
- it "can't deserialize string that doesn't start with an open bracket" do
19
- proc {ListDeserializer.deserialize("hello")}.should raise_error(ListDeserializer::SyntaxError)
20
- end
21
-
22
- it "can't deserialize string that doesn't end with a bracket" do
23
- proc {ListDeserializer.deserialize("[000000:")}.should raise_error(ListDeserializer::SyntaxError)
24
- end
25
-
26
- def check()
27
- serialized = ListSerializer.serialize(@list)
28
- deserialized = ListDeserializer.deserialize(serialized)
29
- deserialized.should == @list
30
- end
31
-
32
- it "can deserialize and empty list" do
33
- check
34
- end
35
-
36
- it "can deserialize a list with one element" do
37
- @list = ["hello"]
38
- check
39
- end
40
-
41
- it "can deserialize a list with two elements" do
42
- @list = ["hello", "bob"]
43
- check
44
- end
45
-
46
- it "can deserialize sublists" do
47
- @list = ["hello", ["bob", "micah"], "today"]
48
- check
49
- end
50
-
51
- it "can deserialize lists with multibyte strings" do
52
- @list = ["Köln"]
53
- check
54
- end
55
-
56
- it "can deserialize lists of strings that end with multibyte chars" do
57
- @list = ["Kö"]
58
- check
59
- end
60
-
61
- it "can deserialize lists with utf8" do
62
- @list = ["123456789012345", "Espa\357\277\275ol"]
63
- check
64
- end
65
-
66
- end
@@ -1,187 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require "statement_executor"
3
- require "list_executor"
4
-
5
- describe ListExecutor do
6
- before do
7
- @executor = ListExecutor.new
8
- @statements = []
9
- @table = "<table><tr><td>name</td><td>bob</td></tr><tr><td>addr</td><td>here</td></tr></table>"
10
- add_statement "i1", "import", "TestModule"
11
- add_statement "m1", "make", "test_slim", "TestSlim"
12
- end
13
-
14
- def get_result(id, result_list)
15
- pairs_to_map(result_list)[id]
16
- end
17
-
18
- def pairs_to_map(pairs)
19
- map = {}
20
- pairs.each {|pair| map[pair[0]] = pair[1]}
21
- map
22
- end
23
-
24
- def add_statement(*args)
25
- @statements << args
26
- end
27
-
28
- def check_results expectations
29
- results = @executor.execute(@statements)
30
- expectations.each_pair {|id, expected|
31
- get_result(id, results).should == expected
32
- }
33
- end
34
-
35
- it "can respond with OK to import" do
36
- check_results "i1"=>"OK"
37
- end
38
-
39
- it "can't execute an invalid operation" do
40
- add_statement "inv1", "invalidOperation"
41
- results = @executor.execute(@statements)
42
- get_result("inv1", results).should include(Statement::EXCEPTION_TAG+"message:<<INVALID_STATEMENT: [\"inv1\", \"invalidOperation\"].")
43
- end
44
-
45
- it "can't execute a malformed instruction" do
46
- add_statement "id", "call", "notEnoughArguments"
47
- message = "message:<<MALFORMED_INSTRUCTION [\"id\", \"call\", \"notEnoughArguments\"].>>"
48
- results = @executor.execute(@statements)
49
- get_result("id", results).should include(Statement::EXCEPTION_TAG+message)
50
- end
51
-
52
- it "can't call a method on an instance that doesn't exist" do
53
- add_statement "id", "call", "no_such_instance", "no_such_method"
54
- results = @executor.execute(@statements)
55
- get_result("id", results).should include(Statement::EXCEPTION_TAG+"message:<<NO_INSTANCE no_such_instance>>")
56
- end
57
-
58
- it "should respond to an empty set of instructions with an empty set of results" do
59
- @executor.execute([]).length.should == 0
60
- end
61
-
62
- it "can make an instance given a fully qualified name in dot format" do
63
- @executor.execute([["m1", "make", "instance", "testModule.TestSlim"]]).should == [["m1", "OK"]]
64
- end
65
-
66
- it "can call a simple method in ruby form" do
67
- add_statement "id", "call", "test_slim", "return_string"
68
-
69
- check_results "m1" => "OK", "id"=>"string"
70
- end
71
-
72
- it "can call a simple method in ruby form" do
73
- add_statement "id", "call", "test_slim", "utf8"
74
-
75
- check_results "m1" => "OK", "id"=>"Espa\357\277\275ol"
76
- end
77
-
78
-
79
- it "can call a simple method in FitNesse form" do
80
- add_statement "id", "call", "test_slim", "returnString"
81
-
82
- check_results "m1"=>"OK", "id"=>"string"
83
- end
84
-
85
- it "will allow later imports to take precendence over early imports" do
86
- @statements.insert(0, ["i2", "import", "TestModule.ShouldNotFindTestSlimInHere"])
87
- add_statement "id", "call", "test_slim", "return_string"
88
- check_results "m1"=>"OK", "id"=>"string"
89
- end
90
-
91
- it "can pass arguments to constructor" do
92
- add_statement "m2", "make", "test_slim_2", "TestSlimWithArguments", "3"
93
- add_statement "c1", "call", "test_slim_2", "arg"
94
-
95
- check_results "m2"=>"OK", "c1"=>"3"
96
- end
97
-
98
- it "can pass tables to constructor" do
99
- add_statement "m2", "make", "test_slim_2", "TestSlimWithArguments", @table
100
- add_statement "c1", "call", "test_slim_2", "name"
101
- add_statement "c2", "call", "test_slim_2", "addr"
102
-
103
- check_results "m2"=>"OK", "c1"=>"bob", "c2"=>"here"
104
- end
105
-
106
- it "can pass tables to functions" do
107
- add_statement "m2", "make", "test_slim_2", "TestSlimWithArguments", "nil"
108
- add_statement "c0", "call", "test_slim_2", "set_arg", @table
109
- add_statement "c1", "call", "test_slim_2", "name"
110
- add_statement "c2", "call", "test_slim_2", "addr"
111
-
112
- check_results "m2"=>"OK", "c1"=>"bob", "c2"=>"here"
113
- end
114
-
115
- it "can call a function more than once" do
116
- add_statement "c1", "call", "test_slim", "add", "x", "y"
117
- add_statement "c2", "call", "test_slim", "add", "a", "b"
118
-
119
- check_results "c1" => "xy", "c2" => "ab"
120
- end
121
-
122
- it "can assign the return value to a symbol" do
123
- add_statement "id1", "callAndAssign", "v", "test_slim", "add", "x", "y"
124
- add_statement "id2", "call", "test_slim", "echo", "$v"
125
- check_results "id1" => "xy", "id2" => "xy"
126
- end
127
-
128
- it "can replace multiple symbols in a single argument" do
129
- add_statement "id1", "callAndAssign", "v1", "test_slim", "echo", "Bob"
130
- add_statement "id2", "callAndAssign", "v2", "test_slim", "echo", "Martin"
131
- add_statement "id3", "call", "test_slim", "echo", "name: $v1 $v2"
132
- check_results "id3" => "name: Bob Martin"
133
- end
134
-
135
- it "should ignore '$' if what follows is not a symbol" do
136
- add_statement "id3", "call", "test_slim", "echo", "$v1"
137
- check_results "id3" => "$v1"
138
- end
139
-
140
- it "can pass and return a list" do
141
- l = ["1", "2"]
142
- add_statement "id", "call", "test_slim", "echo", l
143
- check_results "id"=> l
144
- end
145
-
146
- it "can pass a symbol in a list" do
147
- add_statement "id1", "callAndAssign", "v", "test_slim", "echo", "x"
148
- add_statement "id2", "call", "test_slim", "echo", ["$v"]
149
- check_results "id2" => ["x"]
150
- end
151
-
152
- it "can return null" do
153
- add_statement "id", "call", "test_slim", "null"
154
- check_results "id" => nil
155
- end
156
-
157
- it "can survive executing a syntax error" do
158
- add_statement "id", "call", "test_slim", "syntax_error"
159
- results = @executor.execute(@statements)
160
- get_result("id", results).should include(Statement::EXCEPTION_TAG)
161
- end
162
-
163
- it "can make a fixture from the name in a symbol" do
164
- add_statement "id1", "callAndAssign", "test_system", "test_slim", "echo", "TestChain"
165
- add_statement "id2", "make", "fixture_instance1", "$test_system"
166
- check_results "id2"=>"OK"
167
- end
168
-
169
- it "can make a fixture from a concatonated symbol" do
170
- add_statement "id1", "callAndAssign", "test_system", "test_slim", "echo", "Chain"
171
- add_statement "id2", "make", "fixture_instance1", "Test$test_system"
172
- check_results "id2"=>"OK"
173
- end
174
-
175
- it "can use a fixture method that returns a fixture object" do
176
- add_statement "id1", "callAndAssign", "object", "test_slim", "echo_object", "let_me_see", "Boogaloo"
177
- add_statement "id2", "call", "test_slim", "call_on", "let_me_see", "$object"
178
- check_results "id2" => "Boogaloo"
179
- end
180
-
181
- it "can use an instance that was stored as a symbol" do
182
- add_statement "id1", "callAndAssign", "test_slim_instance", "test_slim", "create_test_slim_with_string", "Boogaloo"
183
- add_statement "m2", "make", "test_slim", "$test_slim_instance"
184
- check_results "m2" => "OK"
185
- end
186
-
187
- end
@@ -1,38 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
- require "list_serializer"
3
-
4
- describe ListSerializer do
5
- it "can serialize and empty list" do
6
- ListSerializer.serialize([]).should == "[000000:]"
7
- end
8
-
9
- it "can serialize a one item list" do
10
- ListSerializer.serialize(["hello"]).should == "[000001:000005:hello:]"
11
- end
12
-
13
- it "can serialize a two item list" do
14
- ListSerializer.serialize(["hello", "world"]).should == "[000002:000005:hello:000005:world:]"
15
- end
16
-
17
- it "can serialize a nested list" do
18
- ListSerializer.serialize([["element"]]).should == "[000001:000024:[000001:000007:element:]:]"
19
- end
20
-
21
- it "can serialize a list with a non-string" do
22
- ListSerializer.serialize([1]).should == "[000001:000001:1:]"
23
- end
24
-
25
- it "can serialize a null element" do
26
- ListSerializer.serialize([nil]).should == "[000001:000004:null:]"
27
- end
28
-
29
- it "can serialize a string with multibyte chars" do
30
- ListSerializer.serialize(["Köln"]).should == "[000001:000004:Köln:]"
31
- end
32
-
33
- it "can serialize a string with UTF8" do
34
- ListSerializer.serialize(["Español"]).should == "[000001:000007:Espa\xc3\xb1ol:]"
35
- end
36
-
37
-
38
- end
@@ -1,127 +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
- context "Simple Method Invocations" do
9
- before do
10
- @executor.create("test_slim", "TestModule::TestSlim", [])
11
- @test_slim = @executor.instance("test_slim")
12
- end
13
-
14
- it "can call a method with no arguments" do
15
- @test_slim.should_receive(:no_args).with()
16
- @executor.call("test_slim", "no_args")
17
- end
18
-
19
- it "can't call a method that doesn't exist" do
20
- result = @executor.call("test_slim", "no_such_method")
21
- result.should include(Statement::EXCEPTION_TAG + "message:<<NO_METHOD_IN_CLASS no_such_method[0] TestModule::TestSlim.>>")
22
- end
23
-
24
- it "can call a method that returns a value" do
25
- @test_slim.should_receive(:return_value).and_return("arg")
26
- @executor.call("test_slim", "return_value").should == "arg"
27
- end
28
-
29
- it "can call a method that returns a value" do
30
- @test_slim.should_receive(:return_value).and_return("Español")
31
- val = @executor.call("test_slim", "return_value")
32
- val.should == "Español"
33
- val.jlength.should == 7
34
- end
35
-
36
-
37
- it "can call a method that takes an argument" do
38
- @test_slim.should_receive(:one_arg).with("arg")
39
- @executor.call("test_slim", "one_arg", "arg")
40
- end
41
-
42
- it "can't call a method on an instance that doesn't exist" do
43
- result = @executor.call("no_such_instance", "no_such_method")
44
- result.should include(Statement::EXCEPTION_TAG + "message:<<NO_INSTANCE no_such_instance>>")
45
- end
46
-
47
- it "can replace symbol expressions with their values" do
48
- @executor.set_symbol("v", "bob")
49
- @executor.call("test_slim", "echo", "hi $v.").should == "hi bob."
50
- end
51
-
52
- it "can call a method on the @sut" do
53
- @test_slim.sut.should_receive(:sut_method).with()
54
- @executor.call("test_slim", "sut_method")
55
- end
56
-
57
- it "should call attributes on sut" do
58
- @executor.call("test_slim", "set_attribute", "a")
59
- @executor.call("test_slim", "attribute").should == "a"
60
- end
61
- end
62
-
63
- context "Method invocations using fixture with no sut" do
64
- before do
65
- @executor.create("test_slim", "TestModule::TestSlimWithNoSut", []);
66
- @test_slim = @executor.instance("test_slim")
67
- end
68
-
69
- it "can't call method that doesn't exist if no 'sut' exists" do
70
- result = @executor.call("test_slim", "no_such_method")
71
- result.should include(Statement::EXCEPTION_TAG + "message:<<NO_METHOD_IN_CLASS no_such_method[0] TestModule::TestSlimWithNoSut.>>")
72
- end
73
- end
74
-
75
- context "Method invocations when library instances have been created." do
76
- before do
77
- @executor.create("library_old", "TestModule::LibraryOld", [])
78
- @executor.create("library_new", "TestModule::LibraryNew", [])
79
- @library_old = @executor.instance("library_old")
80
- @library_new = @executor.instance("library_new")
81
- @executor.create("test_slim", "TestModule::TestSlim", [])
82
- @test_slim = @executor.instance("test_slim")
83
- end
84
-
85
- it "should throw normal exception if no such method is found." do
86
- result = @executor.call("test_slim", "no_such_method")
87
- result.should include(Statement::EXCEPTION_TAG + "message:<<NO_METHOD_IN_CLASS no_such_method[0] TestModule::TestSlim.>>")
88
- end
89
-
90
- it "should still call normal methods in fixture" do
91
- @test_slim.should_receive(:no_args).with()
92
- @executor.call("test_slim", "no_args")
93
- end
94
-
95
- it "should still call methods on the sut" do
96
- @test_slim.sut.should_receive(:sut_method).with()
97
- @executor.call("test_slim", "sut_method")
98
- end
99
-
100
- it "should call a specific method on library_old" do
101
- @library_old.should_receive(:method_on_library_old).with()
102
- @executor.call("test_slim", "method_on_library_old")
103
- end
104
-
105
- it "should call a specific method on library_new" do
106
- @library_new.should_receive(:method_on_library_new).with()
107
- @executor.call("test_slim", "method_on_library_new")
108
- end
109
-
110
- it "should call method on library_new but not on library_old" do
111
- @library_new.should_receive(:a_method).with()
112
- @library_old.should_not_receive(:a_method).with()
113
- @executor.call("test_slim", "a_method")
114
- end
115
-
116
- it "should call built-in library methods" do
117
- @executor.call("test_slim", "push_fixture").should == nil
118
- @executor.call("test_slim", "pop_fixture").should == nil
119
- end
120
-
121
- it "should translate getters and setters" do
122
- @executor.call("test_slim", "set_lib_attribute", "lemon")
123
- @executor.call("test_slim", "lib_attribute").should == "lemon"
124
- end
125
-
126
- end
127
- end