Permalink
Browse files

Leave -v for --version, -w for --validate..

  • Loading branch information...
1 parent 5b854b1 commit 886963392c2d0c6334c8bf70d51a0d200d59f471 @jarib committed Jan 10, 2011
Showing with 27 additions and 9 deletions.
  1. +1 −0 lib/har.rb
  2. +6 −1 lib/har/viewer.rb
  3. +20 −8 spec/har/viewer_spec.rb
View
@@ -7,6 +7,7 @@ class Error < StandardError; end
class ValidationError < StandardError; end
end
+require 'har/version'
require 'har/serializable'
require 'har/schema_type'
require 'har/page'
View
@@ -74,7 +74,12 @@ def parse(args)
options[:port] = int
end
- opts.on "-v", "--validate" do
+ opts.on "-v", "--version" do
+ puts "har #{HAR::VERSION}"
+ exit
+ end
+
+ opts.on "-w", "--validate" do
options[:validate] = true
end
end.parse!(args)
View
@@ -3,19 +3,31 @@
module HAR
describe Viewer do
- context "creating" do
- it "validates the given HARs if asked to" do
- lambda { Viewer.new(["--validate", *all_hars]) }.should raise_error(ValidationError)
- end
+ context "options" do
+ it "has sensible defaults" do
+ v = Viewer.new([google_path])
- it "has a merged archive" do
- Viewer.new(good_hars).har.should be_kind_of(Archive)
+ v.options[:port] == 1234
+ v.options[:validate] == true
end
- it "parses options" do
- v = Viewer.new(["-p", "1234", *good_hars])
+ it "parses the port option" do
+ v = Viewer.new(["-p", "1234", google_path])
v.options[:port].should == 1234
end
+
+ it "parses the --validate option" do
+ v = Viewer.new(["--validate", google_path])
+ v.options[:validate].should be_true
+ end
+ end
+
+ it "validates the given HARs if asked to" do
+ lambda { Viewer.new(["--validate", *all_hars]) }.should raise_error(ValidationError)
+ end
+
+ it "has a merged archive" do
+ Viewer.new(good_hars).har.should be_kind_of(Archive)
end
end

0 comments on commit 8869633

Please sign in to comment.