spec/runner_spec.rb in httping-1.1.0 vs spec/runner_spec.rb in httping-1.3.0

- old
+ new

@@ -8,11 +8,11 @@ after(:each) do Output.clear end - context ".parse_arguments" do + context "#parse_arguments" do it "parses command-line arguments into an options hash" do ARGV << "http://www.example.com" ARGV << "--count" << "3" ARGV << "--delay" << "2" ARGV << "--audible" @@ -51,11 +51,11 @@ @runner.parse_arguments Output.to_s.should match(/-j, --json *Return JSON results/) end end - context ".run" do + context "#run" do it "returns the params banner if no arguments are passed" do @runner.run Output.to_s.should == "Usage: httping [options] uri" end @@ -72,24 +72,30 @@ @runner.run Output.to_s.should match(/5 GETs transmitted/) end end - context "parse_uri" do + context "#parse_uri" do it "outputs an error and exists if not given an HTTP(S) URI" do ARGV << "ftp://www.example.com" @runner.parse_uri - Output.to_s.should == "ERROR: Invalid URI ftp://www.example.com" + Output.to_s.should == "ERROR: Invalid URI ftp://www.example.com/" end it "accepts HTTP URIs" do ARGV << "http://www.example.com" @runner.parse_uri Output.to_s.should_not match(/ERROR/) end it "accepts HTTPS URIs" do ARGV << "https://www.example.com" + @runner.parse_uri + Output.to_s.should_not match(/ERROR/) + end + + it "assumes HTTP for URIs without a scheme" do + ARGV << "www.example.com" @runner.parse_uri Output.to_s.should_not match(/ERROR/) end end end \ No newline at end of file