Skip to content
Browse files

Encapsulating how the jasmine server url is constructed

Provides greater flexibility for when it needs to be customized
  • Loading branch information...
1 parent 28d7c9a commit 59d963b988673ee506113590b837509a8e639c4f Daren committed
Showing with 22 additions and 7 deletions.
  1. +1 −2 lib/jasmine/run_specs.rb
  2. +4 −0 lib/jasmine/runner_config.rb
  3. +1 −2 spec/jasmine_self_test_spec.rb
  4. +16 −3 spec/runner_config_spec.rb
View
3 lib/jasmine/run_specs.rb
@@ -12,8 +12,7 @@
jasmine_runner_config = Jasmine::RunnerConfig.new
server = Jasmine::Server.new(jasmine_runner_config.port, Jasmine::Application.app(jasmine_runner_config))
-client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser,
- "#{jasmine_runner_config.jasmine_host}:#{jasmine_runner_config.port}/")
+client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser, jasmine_runner_config.jasmine_server_url)
t = Thread.new do
begin
View
4 lib/jasmine/runner_config.rb
@@ -48,6 +48,10 @@ def browser
ENV["JASMINE_BROWSER"] || 'firefox'
end
+ def jasmine_server_url
+ "#{jasmine_host}:#{port}/"
+ end
+
def jasmine_host
ENV["JASMINE_HOST"] || 'http://localhost'
end
View
3 spec/jasmine_self_test_spec.rb
@@ -3,8 +3,7 @@
jasmine_runner_config = Jasmine::RunnerConfig.new(JasmineSelfTestConfig.new)
server = Jasmine::Server.new(jasmine_runner_config.port, Jasmine::Application.app(jasmine_runner_config))
-client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser,
- "#{jasmine_runner_config.jasmine_host}:#{jasmine_runner_config.port}/")
+client = Jasmine::SeleniumDriver.new(jasmine_runner_config.browser, jasmine_runner_config.jasmine_server_url)
t = Thread.new do
begin
View
19 spec/runner_config_spec.rb
@@ -135,16 +135,29 @@
end
end
+ describe "jasmine_server_url" do
+ subject { Jasmine::RunnerConfig.new.jasmine_server_url }
+
+ let(:host) { "the host" }
+ let(:port) { "484" }
+ before do
+ Jasmine::RunnerConfig.any_instance.should_receive(:jasmine_host).and_return(host)
+ Jasmine::RunnerConfig.any_instance.should_receive(:port).and_return(port)
+ end
+
+ it("") { should eq("#{host}:#{port}/")}
+ end
+
describe "result batch size" do
- subject { Jasmine::RunnerConfig.new }
+ subject { Jasmine::RunnerConfig.new.result_batch_size }
context "when not specified" do
- it("should use default") { subject.result_batch_size.should be(50) }
+ it("should use default") { should eq(50) }
end
context "when overridden" do
before { ENV.stub(:[], "JASMINE_RESULT_BATCH_SIZE").and_return("500") }
- it { subject.result_batch_size.should be(500) }
+ it { should be(500) }
end
end
end

0 comments on commit 59d963b

Please sign in to comment.
Something went wrong with that request. Please try again.