spec/guard/webrick_spec.rb in guard-webrick-0.1.1 vs spec/guard/webrick_spec.rb in guard-webrick-0.1.2

- old
+ new

@@ -33,10 +33,23 @@ subject = Guard::WEBrick.new([], { :port => 8080 }) subject.options[:port].should == 8080 end end + describe "ssl" do + + it "should be false by default" do + subject = Guard::WEBrick.new([]) + subject.options[:ssl].should be_false + end + + it "should be set to true" do + subject = Guard::WEBrick.new([], { :ssl => true }) + subject.options[:ssl].should be_true + end + end + describe "docroot" do it "should be Dir::pwd by default" do subject = Guard::WEBrick.new([]) subject.options[:docroot].should == Dir::pwd @@ -68,26 +81,29 @@ Spoon.stub(:spawnp).and_return(123456) subject.stub(:wait_for_port) end it "should spawn the server instance" do - subject = Guard::WEBrick.new([], { :host => '127.0.2.5', :port => 8080, + subject = Guard::WEBrick.new([], { + :host => '127.0.2.5', + :port => 8080, + :ssl => true, :docroot => '/tmp' }) subject.stub(:wait_for_port) Spoon.should_receive(:spawnp).with( 'ruby', File.expand_path(File.join(File.dirname(__FILE__), %w{.. .. lib guard webrick server.rb})), - '127.0.2.5', '8080', '/tmp' + '127.0.2.5', '8080', 'true', '/tmp' ) subject.start end it "should pass startup options to the server instance" do Spoon.should_receive(:spawnp).with( 'ruby', File.expand_path(File.join(File.dirname(__FILE__), %w{.. .. lib guard webrick server.rb})), - '0.0.0.0', '3000', Dir::pwd + '0.0.0.0', '3000', 'false', Dir::pwd ) subject.start end it "should set the pid" do @@ -105,11 +121,18 @@ Guard::UI.should_receive(:error).with( "Another instance of WEBrick::HTTPServer is running.") subject.start end - it "should open a web browser page" do + it "should open an HTTP web browser page" do Launchy.should_receive(:open).with("http://0.0.0.0:3000") + subject.start + end + + it "should open an HTTPS web browser page" do + Launchy.should_receive(:open).with("https://0.0.0.0:3000") + subject = Guard::WEBrick.new([], { :ssl => true }) + subject.stub(:wait_for_port) subject.start end it "should not open a web browser if disabled" do subject = Guard::WEBrick.new([], { :launchy => false })