seleniumrc 0.0.1 → 0.0.2

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 (31) hide show
  1. data/CHANGES +4 -0
  2. data/README +38 -0
  3. data/Rakefile +1 -1
  4. data/lib/seleniumrc.rb +2 -4
  5. data/lib/seleniumrc/dsl/selenium_dsl.rb +8 -143
  6. data/lib/seleniumrc/extensions/testrunnermediator.rb +2 -2
  7. data/lib/seleniumrc/mongrel_selenium_server_runner.rb +9 -7
  8. data/lib/seleniumrc/selenium_configuration.rb +233 -40
  9. data/lib/seleniumrc/selenium_driver.rb +193 -0
  10. data/lib/seleniumrc/selenium_element.rb +31 -37
  11. data/lib/seleniumrc/selenium_page.rb +16 -16
  12. data/lib/seleniumrc/selenium_server_runner.rb +1 -1
  13. data/lib/seleniumrc/selenium_test_case.rb +2 -4
  14. data/lib/seleniumrc/wait_for.rb +3 -10
  15. data/lib/seleniumrc/webrick_selenium_server_runner.rb +11 -11
  16. data/spec/seleniumrc/mongrel_selenium_server_runner_spec.rb +31 -38
  17. data/spec/seleniumrc/selenese_interpreter_spec.rb +12 -12
  18. data/spec/seleniumrc/selenium_configuration_spec.rb +350 -12
  19. data/spec/seleniumrc/selenium_driver_spec.rb +104 -0
  20. data/spec/seleniumrc/selenium_element_spec.rb +78 -76
  21. data/spec/seleniumrc/selenium_page_spec.rb +39 -29
  22. data/spec/seleniumrc/selenium_test_case_spec.rb +631 -673
  23. data/spec/seleniumrc/selenium_test_case_spec_helper.rb +0 -7
  24. data/spec/seleniumrc/webrick_selenium_server_runner_spec.rb +14 -13
  25. data/spec/spec_helper.rb +7 -1
  26. metadata +4 -7
  27. data/lib/seleniumrc/app_server_checker.rb +0 -43
  28. data/lib/seleniumrc/extensions/selenium_driver.rb +0 -33
  29. data/lib/seleniumrc/selenium_context.rb +0 -226
  30. data/spec/seleniumrc/app_server_checker_spec.rb +0 -56
  31. data/spec/seleniumrc/selenium_context_spec.rb +0 -362
@@ -57,7 +57,6 @@ module Seleniumrc
57
57
  setup_once = false
58
58
 
59
59
  raise "Cannot use transactional fixtures if ActiveRecord concurrency is turned on (which is required for Selenium tests to work)." if self.class.use_transactional_fixtures
60
- # @beginning = time_class.now
61
60
  unless setup_once
62
61
  ActiveRecord::Base.connection.update('SET FOREIGN_KEY_CHECKS = 0')
63
62
  super
@@ -68,12 +67,11 @@ module Seleniumrc
68
67
  InstanceMethods.const_set("ALREADY_SETUP_ONCE", true)
69
68
  end
70
69
  end
71
- # puts self.class.to_s + "#" + @method_name
72
- @selenium = configuration.selenese_interpreter
70
+ @selenium_driver = configuration.driver
73
71
  end
74
72
 
75
73
  def teardown
76
- @selenium.stop if should_stop_selenese_interpreter?
74
+ selenium_driver.stop if should_stop_driver?
77
75
  super
78
76
  if @beginning
79
77
  duration = (time_class.now - @beginning).to_f
@@ -9,13 +9,13 @@ module Seleniumrc
9
9
  def wait_for(params={})
10
10
  timeout = params[:timeout] || default_wait_for_time
11
11
  message = params[:message] || "Timeout exceeded"
12
- context = Context.new(message)
12
+ configuration = Context.new(message)
13
13
  begin_time = time_class.now
14
14
  while (time_class.now - begin_time) < timeout
15
- return if yield(context)
15
+ return if yield(configuration)
16
16
  sleep 0.25
17
17
  end
18
- flunk(context.message + " (after #{timeout} sec)")
18
+ flunk(configuration.message + " (after #{timeout} sec)")
19
19
  true
20
20
  end
21
21
 
@@ -27,13 +27,6 @@ module Seleniumrc
27
27
  Time
28
28
  end
29
29
 
30
- def wait_for_page_to_load(timeout=default_timeout)
31
- selenium.wait_for_page_to_load timeout
32
- if selenium.get_title.include?("Exception caught")
33
- flunk "We got a new page, but it was an application exception page.\n\n" + get_html_source
34
- end
35
- end
36
-
37
30
  # The default Selenium Core client side timeout.
38
31
  def default_timeout
39
32
  @default_timeout ||= 20000
@@ -1,33 +1,33 @@
1
1
  module Seleniumrc
2
2
  class WebrickSeleniumServerRunner < SeleniumServerRunner
3
- attr_accessor :socket, :dispatch_servlet, :environment_path
3
+ attr_accessor :socket, :dispatch_servlet, :environment_path, :server
4
4
 
5
5
  protected
6
6
  def start_server
7
- @socket.do_not_reverse_lookup = true # patch for OS X
7
+ socket.do_not_reverse_lookup = true # patch for OS X
8
8
 
9
- @server = @context.create_webrick_server
9
+ @server = configuration.create_webrick_server
10
10
  mount_parameters = {
11
- :port => @context.internal_app_server_port,
12
- :ip => @context.internal_app_server_host,
13
- :environment => @context.rails_env.dup,
14
- :server_root => @context.server_root,
11
+ :port => configuration.internal_app_server_port,
12
+ :ip => configuration.internal_app_server_host,
13
+ :environment => configuration.rails_env.dup,
14
+ :server_root => configuration.server_root,
15
15
  :server_type => WEBrick::SimpleServer,
16
16
  :charset => "UTF-8",
17
17
  :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes,
18
- :working_directory => File.expand_path(@context.rails_root.to_s)
18
+ :working_directory => File.expand_path(configuration.rails_root.to_s)
19
19
  }
20
- @server.mount('/', @dispatch_servlet, mount_parameters)
20
+ server.mount('/', dispatch_servlet, mount_parameters)
21
21
 
22
22
  trap("INT") { stop_server }
23
23
 
24
24
  require @environment_path
25
25
  require "dispatcher"
26
- @server.start
26
+ server.start
27
27
  end
28
28
 
29
29
  def stop_server
30
- @server.shutdown
30
+ server.shutdown
31
31
  end
32
32
  end
33
33
  end
@@ -1,42 +1,35 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
- context "MongrelSeleniumServerRunner instance" do
4
- setup do
5
- @context = Seleniumrc::SeleniumContext.new
6
- end
7
-
8
- specify "starts server" do
9
- runner = create_runner_for_start_server
10
- stub(runner).initialize_server
11
- @runner.start
12
- end
13
-
14
- specify "start_server initializes server" do
15
- @runner = create_runner_for_start_server
16
-
17
- mock(@mock_configurator).listener.yields(@mock_configurator)
18
-
19
- stub(@runner).defaults.returns({:environment => ""})
20
- fake_rails = Object.new
21
-
22
- mock(@mock_configurator).rails.once.returns(fake_rails)
23
- mock(@mock_configurator).uri.with("/", {:handler => fake_rails})
24
- mock(@mock_configurator).load_plugins.once
25
- @runner.start
26
- end
27
-
28
- def create_runner_for_start_server
29
- @mock_configurator = mock_configurator = "mock_configurator"
30
- stub(@context).create_mongrel_configurator.returns(mock_configurator)
31
- @runner = @context.create_mongrel_runner
32
-
33
- mock(@mock_configurator).run
34
- stub(@mock_configurator).log
35
- mock(@mock_configurator).join
36
-
37
- mock_thread_class = "mock_thread_class"
38
- @runner.thread_class = mock_thread_class
39
- mock(mock_thread_class).start.yields
40
- @runner
3
+ module Seleniumrc
4
+ describe MongrelSeleniumServerRunner, "#start_server" do
5
+ attr_reader :configuration
6
+ before do
7
+ @configuration = SeleniumConfiguration.new
8
+ end
9
+
10
+ it "initializes server and runs app_server_initialization callback" do
11
+ mongrel_configurator = configuration.create_mongrel_configurator
12
+ stub(configuration).create_mongrel_configurator {mongrel_configurator}
13
+ mock(mongrel_configurator).run
14
+ stub(mongrel_configurator).log
15
+ mock(mongrel_configurator).join
16
+ fake_rails = "fake rails"
17
+ mock(mongrel_configurator).rails {fake_rails}
18
+ mock(mongrel_configurator).uri("/", {:handler => fake_rails})
19
+ mock(mongrel_configurator).load_plugins
20
+ mock(mongrel_configurator).listener.yields(mongrel_configurator)
21
+
22
+ callback_mongrel = nil
23
+ configuration.app_server_initialization = proc do |mongrel|
24
+ callback_mongrel = mongrel
25
+ end
26
+ runner = configuration.create_mongrel_runner
27
+ stub(runner).defaults do; {:environment => ""}; end
28
+ runner.thread_class = mock_thread_class = "mock_thread_class"
29
+ mock(mock_thread_class).start.yields
30
+
31
+ runner.start
32
+ callback_mongrel.should == mongrel_configurator
33
+ end
41
34
  end
42
35
  end
@@ -1,25 +1,25 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
- module Selenium
4
- describe SeleneseInterpreter do
3
+ module Seleniumrc
4
+ describe SeleniumDriver do
5
5
  it "initializes with defaults" do
6
- @interpreter = Selenium::SeleneseInterpreter.new("localhost", 4444, "*iexplore", "localhost:3000")
6
+ @driver = SeleniumDriver.new("localhost", 4444, "*iexplore", "localhost:3000")
7
7
 
8
- @interpreter.server_host.should == "localhost"
9
- @interpreter.server_port.should == 4444
10
- @interpreter.browser_start_command.should == "*iexplore"
11
- @interpreter.browser_url.should == "localhost:3000"
12
- @interpreter.timeout_in_milliseconds.should == 30000
8
+ @driver.server_host.should == "localhost"
9
+ @driver.server_port.should == 4444
10
+ @driver.browser_start_command.should == "*iexplore"
11
+ @driver.browser_url.should == "localhost:3000"
12
+ @driver.timeout_in_milliseconds.should == 30000
13
13
  end
14
14
 
15
15
  it "should start" do
16
- @interpreter = Selenium::SeleneseInterpreter.new("localhost", 4444, "*iexplore", "localhost:3000")
16
+ @driver = SeleniumDriver.new("localhost", 4444, "*iexplore", "localhost:3000")
17
17
 
18
- mock(@interpreter).do_command.
18
+ mock(@driver).do_command.
19
19
  with("getNewBrowserSession", ["*iexplore", "localhost:3000"]).returns(" 12345")
20
20
 
21
- @interpreter.start
22
- @interpreter.instance_eval {@session_id}.should == "12345"
21
+ @driver.start
22
+ @driver.instance_eval {@session_id}.should == "12345"
23
23
  end
24
24
  end
25
25
  end
@@ -1,21 +1,359 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  module Seleniumrc
4
- describe SeleniumConfiguration do
5
- before(:each) do
6
- SeleniumConfiguration.instance_eval {@context = nil}
7
- @mock_context = SeleniumContext.new
4
+ describe SeleniumConfiguration, ".instance" do
5
+ attr_reader :configuration
6
+ before(:each) do
7
+ SeleniumConfiguration.instance = nil
8
+ @configuration = SeleniumConfiguration.new
9
+ end
10
+
11
+ it "should create a new SeleniumConfiguration if it hasn't been called yet" do
12
+ mock(SeleniumConfiguration).new.returns(configuration)
13
+ SeleniumConfiguration.instance.should == configuration
14
+ end
15
+
16
+ it "should reuse the existing SeleniumConfiguration if it has been called. So new/establish_environment should only be called once." do
17
+ SeleniumConfiguration.instance.should_not be_nil
18
+ dont_allow(SeleniumConfiguration).new
19
+ end
20
+ end
21
+
22
+ describe SeleniumConfiguration do
23
+ attr_reader :configuration
24
+ before(:each) do
25
+ @configuration = SeleniumConfiguration.new
26
+ @old_rails_root = RAILS_ROOT if Object.const_defined? :RAILS_ROOT
27
+ silence_warnings { Object.const_set :RAILS_ROOT, "foobar" }
28
+ require 'webrick_server'
29
+ end
30
+
31
+ after(:each) do
32
+ if @old_rails_root
33
+ silence_warnings { Object.const_set :RAILS_ROOT, @old_rails_root }
34
+ else
35
+ Object.instance_eval {remove_const :RAILS_ROOT}
36
+ end
37
+ end
38
+
39
+ it "registers and notifies after_driver_started callbacks" do
40
+ proc1_args = nil
41
+ proc1 = lambda {|*args| proc1_args = args}
42
+ proc2_args = nil
43
+ proc2 = lambda {|*args| proc2_args = args}
44
+
45
+ configuration.after_driver_started(&proc1)
46
+ configuration.after_driver_started(&proc2)
47
+
48
+ expected_driver = Object.new
49
+ configuration.notify_after_driver_started(expected_driver)
50
+ proc1_args.should == [expected_driver]
51
+ proc2_args.should == [expected_driver]
52
+ end
53
+
54
+ it "defaults to true for verify_remote_app_server_is_running" do
55
+ configuration.verify_remote_app_server_is_running.should == true
56
+ end
57
+
58
+ it "defaults app_server_initialization to a Proc" do
59
+ configuration.app_server_initialization.should be_instance_of(Proc)
60
+ end
61
+
62
+ it "creates a Selenese driver and notify listeners" do
63
+ configuration.selenium_server_host = "selenium_server_host.com"
64
+ configuration.selenium_server_port = 80
65
+ configuration.browser = "iexplore"
66
+ configuration.external_app_server_host = "browser_host.com"
67
+ configuration.external_app_server_port = 80
68
+
69
+ driver = configuration.create_driver
70
+ driver.server_host.should == "selenium_server_host.com"
71
+ driver.server_port.should == 80
72
+ driver.browser_start_command.should == "*iexplore"
73
+ driver.browser_url.should == "http://browser_host.com:80"
74
+ end
75
+
76
+ it "creates, initializes. and notifies listeners for a Selenese driver " do
77
+ passed_driver = nil
78
+ configuration.after_driver_started {|driver| passed_driver = driver}
79
+
80
+ stub_driver = Object.new
81
+ start_called = false
82
+ stub(stub_driver).start.returns {start_called = true}
83
+ stub(configuration).create_driver.returns {stub_driver}
84
+ driver = configuration.create_and_initialize_driver
85
+ driver.should == stub_driver
86
+ passed_driver.should == driver
87
+ start_called.should == true
88
+ end
89
+
90
+ it "creates a Webrick Server Runner" do
91
+ configuration.selenium_server_port = 4000
92
+ configuration.selenium_server_host = "localhost"
93
+ dir = File.dirname(__FILE__)
94
+ configuration.rails_root = dir
95
+ configuration.rails_env = "test"
96
+
97
+ runner = configuration.create_webrick_runner
98
+ runner.should be_an_instance_of(WebrickSeleniumServerRunner)
99
+ runner.configuration.should == configuration
100
+ runner.thread_class.should == Thread
101
+ runner.socket.should == Socket
102
+ runner.dispatch_servlet.should == DispatchServlet
103
+ runner.environment_path.should == File.expand_path("#{dir}/config/environment")
104
+ end
105
+
106
+ it "creates webrick http server" do
107
+ configuration.internal_app_server_port = 4000
108
+ configuration.internal_app_server_host = "localhost"
109
+
110
+ mock_logger = "logger"
111
+ mock(configuration).new_logger {mock_logger}
112
+ mock(WEBrick::HTTPServer).new({
113
+ :Port => 4000,
114
+ :BindAddress => "localhost",
115
+ :ServerType => WEBrick::SimpleServer,
116
+ :MimeTypes => WEBrick::HTTPUtils::DefaultMimeTypes,
117
+ :Logger => mock_logger,
118
+ :AccessLog => []
119
+ })
120
+ server = configuration.create_webrick_server
121
+ end
122
+
123
+ it "creates Mongrel Server Runner" do
124
+ server = configuration.create_mongrel_runner
125
+ server.should be_instance_of(MongrelSeleniumServerRunner)
126
+ server.configuration.should == configuration
127
+ server.thread_class.should == Thread
128
+ end
129
+
130
+ it "creates Mongrel configurator" do
131
+ configuration.internal_app_server_host = "localhost"
132
+ configuration.internal_app_server_port = 4000
133
+ configuration.rails_env = "test"
134
+ configuration.rails_root = rails_root = File.dirname(__FILE__)
135
+
136
+ configurator = configuration.create_mongrel_configurator
137
+ configurator.defaults[:host].should == "localhost"
138
+ configurator.defaults[:port].should == 4000
139
+ configurator.defaults[:cwd].should == configuration.rails_root
140
+ configurator.defaults[:log_file].should == "#{configuration.rails_root}/log/mongrel.log"
141
+ configurator.defaults[:pid_file].should == "#{configuration.rails_root}/log/mongrel.pid"
142
+ configurator.defaults[:environment].should == "test"
143
+ configurator.defaults[:docroot].should == "#{rails_root}/public"
144
+ configurator.defaults[:mime_map].should be_nil
145
+ configurator.defaults[:daemon].should == false
146
+ configurator.defaults[:debug].should == false
147
+ configurator.defaults[:includes].should == ["mongrel"]
148
+ configurator.defaults[:config_script].should be_nil
149
+ end
150
+ end
151
+
152
+ describe SeleniumConfiguration, "#establish_environment" do
153
+ attr_reader :configuration
154
+ before(:each) do
155
+ @old_configuration = SeleniumConfiguration.instance
156
+ SeleniumConfiguration.instance = nil
157
+ @configuration = SeleniumConfiguration.instance
158
+ configuration = @configuration
159
+ end
160
+
161
+ after(:each) do
162
+ SeleniumConfiguration.instance = @old_configuration
163
+ end
164
+
165
+ it "establish_environment__webrick_host" do
166
+ should_establish_environment('internal_app_server_host', '192.168.10.1', :internal_app_server_host )
167
+ end
168
+
169
+ it "initializes webrick_port" do
170
+ should_establish_environment('internal_app_server_port', 1337, :internal_app_server_port )
171
+ end
172
+
173
+ it "initializes internal_app_server_port" do
174
+ should_establish_environment('external_app_server_port', 1337, :external_app_server_port )
175
+ end
176
+
177
+ it "initializes internal_app_server_host" do
178
+ should_establish_environment('external_app_server_host', 'sammich.com', :external_app_server_host)
179
+ end
180
+
181
+ it "initializes selenium_server_host" do
182
+ should_establish_environment('selenium_server_host', 'sammich.com')
183
+ end
184
+
185
+ it "initializes selenium_server_host" do
186
+ should_establish_environment('selenium_server_port', 1337)
187
+ end
188
+
189
+ it "initializes app_server_engine" do
190
+ should_establish_environment('app_server_engine', :webrick, :app_server_engine)
191
+ end
192
+
193
+ it "initializes browser" do
194
+ configuration.env = stub_env
195
+ stub_env['browser'] = 'konqueror'
196
+ SeleniumConfiguration.__send__(:establish_environment)
197
+ configuration.browser.should == 'konqueror'
198
+ end
199
+
200
+ it "initializes keep_browser_open_on_failure" do
201
+ configuration.env = stub_env
202
+ env_var = 'keep_browser_open_on_failure'
203
+ stub_env[env_var] = 'false'
204
+ SeleniumConfiguration.send :establish_environment
205
+ configuration.send(env_var).should == false
206
+ configuration.send(env_var).should == false
207
+
208
+ stub_env[env_var] = 'true'
209
+ SeleniumConfiguration.send :establish_environment
210
+ configuration.send(env_var).should == true
211
+ configuration.send(env_var).should == true
212
+
213
+ stub_env[env_var] = 'blah'
214
+ SeleniumConfiguration.send :establish_environment
215
+ configuration.send(env_var).should == true
216
+ configuration.send(env_var).should == true
217
+ end
218
+
219
+ it "initializes verify_remote_app_server_is_running" do
220
+ configuration.env = stub_env
221
+ env_var = 'verify_remote_app_server_is_running'
222
+ stub_env[env_var] = 'false'
223
+ SeleniumConfiguration.send :establish_environment
224
+ configuration.send(env_var).should == false
225
+ configuration.send(env_var).should == false
226
+
227
+ stub_env[env_var] = 'true'
228
+ SeleniumConfiguration.send :establish_environment
229
+ configuration.send(env_var).should == true
230
+ configuration.send(env_var).should == true
231
+
232
+ stub_env[env_var] = 'blah'
233
+ SeleniumConfiguration.send :establish_environment
234
+ configuration.send(env_var).should == true
235
+ configuration.send(env_var).should == true
236
+ end
237
+
238
+ it "internal_app_server_host" do
239
+ should_lazily_load configuration, :internal_app_server_host, "0.0.0.0"
240
+ end
241
+
242
+ it "internal_app_server_port" do
243
+ should_lazily_load configuration, :internal_app_server_port, 4000
244
+ end
245
+
246
+ it "external_app_server_host" do
247
+ should_lazily_load configuration, :external_app_server_host, "localhost"
248
+ end
249
+
250
+ it "external_app_server_port" do
251
+ should_lazily_load configuration, :external_app_server_port, 4000
252
+ end
253
+
254
+ it "browsers__lazy_loaded" do
255
+ should_lazily_load configuration, :browser, SeleniumConfiguration::FIREFOX
256
+ end
257
+
258
+ it "keep_browser_open_on_failure" do
259
+ should_lazily_load configuration, :keep_browser_open_on_failure, true
260
+ end
261
+
262
+ it "formatted_browser" do
263
+ configuration.browser = SeleniumConfiguration::IEXPLORE
264
+ configuration.formatted_browser.should == "*iexplore"
265
+ end
266
+
267
+ it "browser_url" do
268
+ configuration.external_app_server_host = "test.com"
269
+ configuration.external_app_server_port = 101
270
+ configuration.browser_url.should == "http://test.com:101"
271
+ end
272
+
273
+ it "driver__when_in_test_browser_mode__should_be_nil" do
274
+ configuration.test_browser_mode
275
+ configuration.driver.should be_nil
276
+ end
277
+
278
+ protected
279
+ def should_establish_environment(env_var, expected_value, method_name=nil )
280
+ method_name = env_var unless method_name
281
+ configuration.env = stub_env
282
+ stub_env[env_var] = expected_value
283
+ SeleniumConfiguration.send :establish_environment
284
+ SeleniumConfiguration.instance.send(method_name).should == expected_value
285
+ end
286
+
287
+ def stub_env
288
+ @stub_env ||= {}
289
+ end
290
+
291
+ def should_lazily_load(object, method_name, default_value)
292
+ object.send(method_name).should == default_value
293
+ test_object = Object.new
294
+ object.send("#{method_name}=", test_object)
295
+ object.send(method_name).should == test_object
296
+ end
8
297
  end
9
298
 
10
- it "should create a new context if it hasn't been called yet" do
11
- mock(SeleniumContext).new.returns(@mock_context)
12
- SeleniumConfiguration.instance.should == @mock_context
299
+ describe SeleniumConfiguration, "#stop_driver_if_necessary" do
300
+ attr_reader :configuration
301
+ before(:each) do
302
+ @configuration = SeleniumConfiguration.new
303
+ end
304
+
305
+ it "when suite passes, should stop driver" do
306
+ driver = ::Seleniumrc::SeleniumDriver.new('http://test.host', 4000, "*firefox", 'http://test.host')
307
+ mock(driver).stop.once
308
+ configuration.driver = driver
309
+
310
+ configuration.stop_driver_if_necessary true
311
+ end
312
+
313
+ it "when suite fails and keep browser open on failure, should not stop driver" do
314
+ driver = ::Seleniumrc::SeleniumDriver.new('http://test.host', 4000, "*firefox", 'http://test.host')
315
+ mock(driver).stop.never
316
+ configuration.driver = driver
317
+ configuration.keep_browser_open_on_failure = true
318
+
319
+ configuration.stop_driver_if_necessary false
320
+ end
321
+
322
+ it "when suite fails and not keep browser open on failure, should stop driver" do
323
+ driver = ::Seleniumrc::SeleniumDriver.new('http://test.host', 4000, "*firefox", 'http://test.host')
324
+ mock(driver).stop
325
+ configuration.driver = driver
326
+ configuration.keep_browser_open_on_failure = false
327
+
328
+ configuration.stop_driver_if_necessary false
329
+ end
330
+
13
331
  end
14
332
 
15
- it "should reuse the existing context if it has been called. So new/establish_environment should only be called once." do
16
- mock(SeleniumContext).new.returns(@mock_context)
17
- SeleniumConfiguration.instance.should == @mock_context
18
- SeleniumConfiguration.instance.should == @mock_context
333
+ describe SeleniumConfiguration, "#create_server_runner where application server engine is mongrel" do
334
+ it "creates a mongrel server runner" do
335
+ configuration = SeleniumConfiguration.new
336
+ configuration.app_server_engine = :mongrel
337
+ runner = configuration.create_server_runner
338
+ runner.should be_instance_of(MongrelSeleniumServerRunner)
339
+ end
340
+ end
341
+
342
+ describe SeleniumConfiguration, "#create_server_runner where application server engine is webrick" do
343
+ before do
344
+ Object.const_set :RAILS_ROOT, "foobar"
345
+ require 'webrick_server'
346
+ end
347
+
348
+ after do
349
+ Object.instance_eval {remove_const :RAILS_ROOT}
350
+ end
351
+
352
+ it "creates a webrick server runner" do
353
+ configuration = SeleniumConfiguration.new
354
+ configuration.app_server_engine = :webrick
355
+ runner = configuration.create_server_runner
356
+ runner.should be_instance_of(WebrickSeleniumServerRunner)
357
+ end
19
358
  end
20
- end
21
359
  end