Permalink
Browse files

Use optional JASMINE_HOST to determine host to connect to

  • Loading branch information...
1 parent a7b5294 commit 0abe25123bdd748919da8269d465e6e26e17b7f2 @ragaskar ragaskar committed Apr 2, 2010
Showing with 40 additions and 10 deletions.
  1. +1 −1 VERSION.yml
  2. +2 −2 jasmine.gemspec
  3. +5 −1 lib/jasmine/config.rb
  4. +32 −6 spec/config_spec.rb
View
@@ -1,5 +1,5 @@
---
:major: 0
-:build:
+:build: 1
:minor: 10
:patch: 3
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{jasmine}
- s.version = "0.10.3"
+ s.version = "0.10.3.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Rajan Agaskar", "Christian Williams"]
- s.date = %q{2010-04-01}
+ s.date = %q{2010-04-02}
s.default_executable = %q{jasmine}
s.description = %q{Javascript BDD test framework}
s.email = %q{ragaskar@gmail.com}
@@ -17,7 +17,7 @@ def start_server(port = 8888)
def start
start_servers
- @client = Jasmine::SeleniumDriver.new("localhost", @selenium_server_port, "*#{@browser}", "http://localhost:#{@jasmine_server_port}/")
+ @client = Jasmine::SeleniumDriver.new("localhost", @selenium_server_port, "*#{@browser}", "#{jasmine_host}:#{@jasmine_server_port}/")
@client.connect
end
@@ -26,6 +26,10 @@ def stop
stop_servers
end
+ def jasmine_host
+ ENV["JASMINE_HOST"] || 'http://localhost'
+ end
+
def start_jasmine_server
@jasmine_server_port = Jasmine::find_unused_port
server = Jasmine::Server.new(@jasmine_server_port, self)
View
@@ -46,9 +46,9 @@
@config.spec_files.should == ['ExampleSpec.js']
@config.helpers.should == ['helpers/SpecHelper.js']
@config.js_files.should == [
- '/__spec__/helpers/SpecHelper.js',
- '/__spec__/ExampleSpec.js',
- ]
+ '/__spec__/helpers/SpecHelper.js',
+ '/__spec__/ExampleSpec.js',
+ ]
@config.js_files("ExampleSpec.js").should ==
['/__spec__/helpers/SpecHelper.js',
'/__spec__/ExampleSpec.js']
@@ -141,9 +141,9 @@
end
- describe "browsers" do
+ describe "browser configuration" do
it "should use firefox by default" do
- ENV.should_receive(:[], "JASMINE_BROWSER").and_return(nil)
+ ENV.stub!(:[], "JASMINE_BROWSER").and_return(nil)
config = Jasmine::Config.new
config.stub!(:start_servers)
Jasmine::SeleniumDriver.should_receive(:new).
@@ -153,14 +153,39 @@
end
it "should use ENV['JASMINE_BROWSER'] if set" do
- ENV.should_receive(:[], "JASMINE_BROWSER").and_return("mosaic")
+ ENV.stub!(:[], "JASMINE_BROWSER").and_return("mosaic")
config = Jasmine::Config.new
config.stub!(:start_servers)
Jasmine::SeleniumDriver.should_receive(:new).
with(anything(), anything(), "*mosaic", anything()).
and_return(mock(Jasmine::SeleniumDriver, :connect => true))
config.start
end
+ end
+
+ describe "jasmine host" do
+ it "should use http://localhost by default" do
+ config = Jasmine::Config.new
+ config.instance_variable_set(:@jasmine_server_port, '1234')
+ config.stub!(:start_servers)
+
+ Jasmine::SeleniumDriver.should_receive(:new).
+ with(anything(), anything(), anything(), "http://localhost:1234/").
+ and_return(mock(Jasmine::SeleniumDriver, :connect => true))
+ config.start
+ end
+
+ it "should use ENV['JASMINE_HOST'] if set" do
+ ENV.stub!(:[], "JASMINE_HOST").and_return("http://some_host")
+ config = Jasmine::Config.new
+ config.instance_variable_set(:@jasmine_server_port, '1234')
+ config.stub!(:start_servers)
+
+ Jasmine::SeleniumDriver.should_receive(:new).
+ with(anything(), anything(), anything(), "http://some_host:1234/").
+ and_return(mock(Jasmine::SeleniumDriver, :connect => true))
+ config.start
+ end
end
describe "#start_selenium_server" do
@@ -172,4 +197,5 @@
end
end
+
end

0 comments on commit 0abe251

Please sign in to comment.