Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 886963392c2d0c6334c8bf70d51a0d200d59f471 1 parent 5b854b1
Jari Bakken authored
1  lib/har.rb
@@ -7,6 +7,7 @@ class Error < StandardError; end
7 7 class ValidationError < StandardError; end
8 8 end
9 9
  10 +require 'har/version'
10 11 require 'har/serializable'
11 12 require 'har/schema_type'
12 13 require 'har/page'
7 lib/har/viewer.rb
@@ -74,7 +74,12 @@ def parse(args)
74 74 options[:port] = int
75 75 end
76 76
77   - opts.on "-v", "--validate" do
  77 + opts.on "-v", "--version" do
  78 + puts "har #{HAR::VERSION}"
  79 + exit
  80 + end
  81 +
  82 + opts.on "-w", "--validate" do
78 83 options[:validate] = true
79 84 end
80 85 end.parse!(args)
28 spec/har/viewer_spec.rb
@@ -3,19 +3,31 @@
3 3 module HAR
4 4 describe Viewer do
5 5
6   - context "creating" do
7   - it "validates the given HARs if asked to" do
8   - lambda { Viewer.new(["--validate", *all_hars]) }.should raise_error(ValidationError)
9   - end
  6 + context "options" do
  7 + it "has sensible defaults" do
  8 + v = Viewer.new([google_path])
10 9
11   - it "has a merged archive" do
12   - Viewer.new(good_hars).har.should be_kind_of(Archive)
  10 + v.options[:port] == 1234
  11 + v.options[:validate] == true
13 12 end
14 13
15   - it "parses options" do
16   - v = Viewer.new(["-p", "1234", *good_hars])
  14 + it "parses the port option" do
  15 + v = Viewer.new(["-p", "1234", google_path])
17 16 v.options[:port].should == 1234
18 17 end
  18 +
  19 + it "parses the --validate option" do
  20 + v = Viewer.new(["--validate", google_path])
  21 + v.options[:validate].should be_true
  22 + end
  23 + end
  24 +
  25 + it "validates the given HARs if asked to" do
  26 + lambda { Viewer.new(["--validate", *all_hars]) }.should raise_error(ValidationError)
  27 + end
  28 +
  29 + it "has a merged archive" do
  30 + Viewer.new(good_hars).har.should be_kind_of(Archive)
19 31 end
20 32
21 33 end

0 comments on commit 8869633

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