saper 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/Rakefile +7 -5
- data/bin/saper +51 -1
- data/lib/saper/actions/create_atom.rb +0 -5
- data/lib/saper/actions/nothing.rb +2 -0
- data/lib/saper/actions/remove_matching.rb +1 -1
- data/lib/saper/actions/run_recipe.rb +5 -5
- data/lib/saper/actions/run_recipe_and_save.rb +5 -5
- data/lib/saper/actions/select_matching.rb +1 -1
- data/lib/saper/actions/set_input.rb +0 -5
- data/lib/saper/core/action.rb +69 -53
- data/lib/saper/core/argument.rb +3 -0
- data/lib/saper/core/browser.rb +3 -2
- data/lib/saper/core/error.rb +4 -1
- data/lib/saper/core/keychain.rb +2 -2
- data/lib/saper/core/logger.rb +9 -54
- data/lib/saper/core/recipe.rb +36 -5
- data/lib/saper/core/result.rb +36 -5
- data/lib/saper/core/runtime.rb +17 -11
- data/lib/saper/core/stack.rb +17 -1
- data/lib/saper/items/html.rb +1 -1
- data/lib/saper/items/nothing.rb +9 -0
- data/lib/saper/items/xml.rb +5 -1
- data/lib/saper/version.rb +1 -1
- data/lib/tungsten/lib/README +5 -0
- data/lib/tungsten/lib/test.rb +18 -0
- data/lib/tungsten/lib/tungsten.rb +33 -0
- data/lib/tungsten/lib/tungsten/headers.rb +37 -0
- data/lib/tungsten/lib/tungsten/jar.rb +17 -0
- data/lib/tungsten/lib/tungsten/request.rb +102 -0
- data/lib/tungsten/lib/tungsten/response.rb +101 -0
- data/spec/actions/append_with_spec.rb +144 -21
- data/spec/actions/convert_to_html_spec.rb +126 -11
- data/spec/actions/convert_to_json_spec.rb +126 -11
- data/spec/actions/convert_to_markdown_spec.rb +126 -11
- data/spec/actions/convert_to_time_spec.rb +150 -15
- data/spec/actions/convert_to_xml_spec.rb +136 -11
- data/spec/actions/create_atom_spec.rb +116 -7
- data/spec/actions/fetch_spec.rb +110 -3
- data/spec/actions/find_first_spec.rb +149 -24
- data/spec/actions/find_spec.rb +167 -19
- data/spec/actions/get_attribute_spec.rb +145 -15
- data/spec/actions/get_contents_spec.rb +125 -4
- data/spec/actions/get_text_spec.rb +125 -4
- data/spec/actions/nothing_spec.rb +119 -4
- data/spec/actions/prepend_with_spec.rb +148 -22
- data/spec/actions/remove_after_spec.rb +160 -4
- data/spec/actions/remove_before_spec.rb +160 -4
- data/spec/actions/remove_matching_spec.rb +164 -4
- data/spec/actions/remove_tags_spec.rb +1 -1
- data/spec/actions/replace_spec.rb +1 -1
- data/spec/actions/run_recipe_and_save_spec.rb +1 -1
- data/spec/actions/run_recipe_spec.rb +1 -1
- data/spec/actions/save_spec.rb +1 -1
- data/spec/actions/select_matching_spec.rb +164 -4
- data/spec/actions/set_input_spec.rb +1 -1
- data/spec/actions/skip_tags_spec.rb +1 -1
- data/spec/actions/split_spec.rb +1 -1
- data/spec/arguments/attribute_spec.rb +1 -1
- data/spec/arguments/recipe_spec.rb +1 -1
- data/spec/arguments/text_spec.rb +1 -1
- data/spec/arguments/timezone_spec.rb +1 -1
- data/spec/arguments/variable_spec.rb +1 -1
- data/spec/arguments/xpath_spec.rb +1 -1
- data/spec/core/action_spec.rb +25 -13
- data/spec/core/argument_spec.rb +55 -31
- data/spec/core/browser_spec.rb +21 -11
- data/spec/core/dsl_spec.rb +1 -1
- data/spec/core/item_spec.rb +1 -1
- data/spec/core/keychain_spec.rb +1 -1
- data/spec/core/logger_spec.rb +1 -1
- data/spec/core/namespace_spec.rb +1 -1
- data/spec/core/recipe_spec.rb +85 -51
- data/spec/core/result_spec.rb +1 -1
- data/spec/core/runtime_spec.rb +45 -27
- data/spec/core/stack_spec.rb +1 -1
- data/spec/core/type_spec.rb +1 -1
- data/spec/integration/simple_invalid_spec.rb +46 -9
- data/spec/integration/simple_valid_spec.rb +9 -9
- data/spec/items/atom_spec.rb +7 -7
- data/spec/items/document_spec.rb +29 -29
- data/spec/items/html_spec.rb +80 -48
- data/spec/items/json_spec.rb +17 -11
- data/spec/items/markdown_spec.rb +30 -18
- data/spec/items/nothing_spec.rb +1 -1
- data/spec/items/text_spec.rb +12 -10
- data/spec/items/time_spec.rb +35 -21
- data/spec/items/url_spec.rb +1 -1
- data/spec/items/xml_spec.rb +75 -42
- data/spec/spec_helper.rb +90 -2
- metadata +51 -16
data/spec/actions/split_spec.rb
CHANGED
data/spec/arguments/text_spec.rb
CHANGED
data/spec/core/action_spec.rb
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
require './spec/spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Saper::Action do
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
RSpec.describe Saper::Action do
|
|
4
|
+
context ".[](invalid)" do
|
|
5
|
+
it "raises ActionNotFound" do
|
|
6
|
+
expect { Saper::Action[:unknown] }.to raise_error Saper::ActionNotFound
|
|
7
|
+
end
|
|
6
8
|
end
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
context ".new(invalid)" do
|
|
10
|
+
it "raises ActionNotFound" do
|
|
11
|
+
expect { Saper::Action.new(:unknown) }.to raise_error Saper::ActionNotFound
|
|
12
|
+
end
|
|
9
13
|
end
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
context ".new(valid)" do
|
|
15
|
+
it "returns Action" do
|
|
16
|
+
expect(Saper::Action.new(:nothing)).to be_a Saper::Actions::Nothing
|
|
17
|
+
end
|
|
12
18
|
end
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
context ".unserialize(nil)" do
|
|
20
|
+
it "raises InvalidAction" do
|
|
21
|
+
expect { Saper::Action.unserialize(nil) }.to raise_error Saper::InvalidAction
|
|
22
|
+
end
|
|
15
23
|
end
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
context ".unserialize(Hash)" do
|
|
25
|
+
it "returns Action" do
|
|
26
|
+
expect(Saper::Action.unserialize({ :type => :nothing })).to be_a Saper::Action
|
|
27
|
+
end
|
|
18
28
|
end
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
context ".unserialize(Array)" do
|
|
30
|
+
it "returns an Array" do
|
|
31
|
+
expect(Saper::Action.unserialize([{ :type => :nothing }, { :type => :nothing }])).to be_a Array
|
|
32
|
+
end
|
|
21
33
|
end
|
|
22
34
|
end
|
data/spec/core/argument_spec.rb
CHANGED
|
@@ -1,46 +1,70 @@
|
|
|
1
1
|
require './spec/spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Saper::Argument do
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
RSpec.describe Saper::Argument do
|
|
4
|
+
context ".new(:text, nil)" do
|
|
5
|
+
it "raises InvalidArgument" do
|
|
6
|
+
expect { Saper::Argument.new(:text, :value => nil) }.to raise_error Saper::InvalidArgument
|
|
7
|
+
end
|
|
6
8
|
end
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
context ".new(:text)" do
|
|
10
|
+
it "raises InvalidArgument" do
|
|
11
|
+
expect { Saper::Argument.new(:text) }.to raise_error Saper::InvalidArgument
|
|
12
|
+
end
|
|
9
13
|
end
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
context ".new(:text, invalid)" do
|
|
15
|
+
it "raises InvalidArgument" do
|
|
16
|
+
expect { Saper::Argument.new(:text, :value => 1) }.to raise_error Saper::InvalidArgument
|
|
17
|
+
end
|
|
12
18
|
end
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
context ".new(:text, valid)" do
|
|
20
|
+
it "raises no exceptions" do
|
|
21
|
+
expect(Saper::Argument.new(:text, :value => "text")).to be_a Saper::Argument
|
|
22
|
+
end
|
|
15
23
|
end
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
context ".new(:text, optional)" do
|
|
25
|
+
it "raises no exceptions" do
|
|
26
|
+
expect(Saper::Argument.new(:text, :optional => true)).to be_a Saper::Argument
|
|
27
|
+
end
|
|
18
28
|
end
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
context ".new(:text, optional, invalid)" do
|
|
30
|
+
it "raises InvalidArgument" do
|
|
31
|
+
expect { Saper::Argument.new(:text, :optional => true, :value => 1) }.to raise_error Saper::InvalidArgument
|
|
32
|
+
end
|
|
21
33
|
end
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
context ".new(:text, optional, valid)" do
|
|
35
|
+
it "returns Action instance" do
|
|
36
|
+
expect(Saper::Argument.new(:text, :optional => true, :value => "text")).to be_a Saper::Argument
|
|
37
|
+
end
|
|
24
38
|
end
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
context "#set(invalid)" do
|
|
40
|
+
it "raises InvalidArgument" do
|
|
41
|
+
expect { Saper::Argument.new(:text, :value => "text").set(1) }.to raise_error Saper::InvalidArgument
|
|
42
|
+
end
|
|
27
43
|
end
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
context "#set(optional invalid)" do
|
|
45
|
+
it "raises InvalidArgument" do
|
|
46
|
+
expect { Saper::Argument.new(:text, :optional => true, :value => "text").set(1) }.to raise_error Saper::InvalidArgument
|
|
47
|
+
end
|
|
30
48
|
end
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
context "#set(valid)" do
|
|
50
|
+
it "returns self" do
|
|
51
|
+
expect(Saper::Argument.new(:text, :optional => true).set("text")).to be_a Saper::Argument
|
|
52
|
+
end
|
|
33
53
|
end
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
context "#value" do
|
|
55
|
+
it "returns nil by default" do
|
|
56
|
+
expect(Saper::Argument.new(:text, :optional => true).value).to be_nil
|
|
57
|
+
end
|
|
58
|
+
it "returns stored value" do
|
|
59
|
+
expect(Saper::Argument.new(:text, :value => "text").value).to eq "text"
|
|
60
|
+
end
|
|
36
61
|
end
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Saper::Argument.new(:text, :optional => true).must_be :optional?
|
|
62
|
+
context "#optional?" do
|
|
63
|
+
it "returns false by default" do
|
|
64
|
+
expect(Saper::Argument.new(:text, :value => "text")).to_not be_optional
|
|
65
|
+
end
|
|
66
|
+
it "returns true if optionality flag is set" do
|
|
67
|
+
expect(Saper::Argument.new(:text, :optional => true)).to be_optional
|
|
68
|
+
end
|
|
45
69
|
end
|
|
46
70
|
end
|
data/spec/core/browser_spec.rb
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
require './spec/spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Saper::Browser do
|
|
3
|
+
RSpec.describe Saper::Browser do
|
|
4
4
|
let :subject do
|
|
5
5
|
Saper::Browser.new
|
|
6
6
|
end
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
context "#history" do
|
|
8
|
+
it "returns an empty array by default" do
|
|
9
|
+
expect(subject.history).to eq []
|
|
10
|
+
end
|
|
9
11
|
end
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
context "#headers" do
|
|
13
|
+
it "returns an empty Hash by default" do
|
|
14
|
+
expect(subject.headers).to eq({})
|
|
15
|
+
end
|
|
12
16
|
end
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
context "#received" do
|
|
18
|
+
it "returns zero by default" do
|
|
19
|
+
expect(subject.received).to eq 0
|
|
20
|
+
end
|
|
15
21
|
end
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
context "#sent" do
|
|
23
|
+
it "returns zero by default" do
|
|
24
|
+
expect(subject.sent).to eq 0
|
|
25
|
+
end
|
|
18
26
|
end
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
context "#agent" do
|
|
28
|
+
it "returns User-Agent string" do
|
|
29
|
+
expect(subject.agent).to include 'Mozilla'
|
|
30
|
+
end
|
|
21
31
|
end
|
|
22
32
|
end
|
data/spec/core/dsl_spec.rb
CHANGED
data/spec/core/item_spec.rb
CHANGED
data/spec/core/keychain_spec.rb
CHANGED
data/spec/core/logger_spec.rb
CHANGED
data/spec/core/namespace_spec.rb
CHANGED
data/spec/core/recipe_spec.rb
CHANGED
|
@@ -1,58 +1,92 @@
|
|
|
1
1
|
require './spec/spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Saper::Recipe do
|
|
3
|
+
RSpec.describe Saper::Recipe do
|
|
4
4
|
let :subject do
|
|
5
5
|
Saper::Recipe.new
|
|
6
6
|
end
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
7
|
+
context ".unserialize(Hash)" do
|
|
8
|
+
it "returns a Recipe instance" do
|
|
9
|
+
expect(Saper::Recipe.unserialize({ :id => 0 })).to be_a Saper::Recipe
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
context ".unserialize(Array)" do
|
|
13
|
+
it "returns an Array" do
|
|
14
|
+
expect(Saper::Recipe.unserialize([{ :id => 0 }, { :id => 1 }])).to be_a Array
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
context ".unserialize(nil)" do
|
|
18
|
+
it "raises InvalidRecipe" do
|
|
19
|
+
expect { Saper::Recipe.unserialize(nil) }.to raise_error Saper::InvalidRecipe
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
context "#id" do
|
|
23
|
+
it "returns recipe ID" do
|
|
24
|
+
expect(subject.id).to be_a(String)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
context "#actions" do
|
|
28
|
+
it "returns an empty array by default" do
|
|
29
|
+
expect(subject.actions).to eq []
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
context "#<<(action)" do
|
|
33
|
+
it "returns self" do
|
|
34
|
+
expect(Saper::Recipe.new << Saper::Action.new(:nothing)).to be_a Saper::Recipe
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
context "#<<(invalid)" do
|
|
38
|
+
it "raises ActionExpected" do
|
|
39
|
+
expect { Saper::Recipe.new << 'not an action' }.to raise_error Saper::ActionExpected
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
context "#push(action)" do
|
|
43
|
+
it "returns self" do
|
|
44
|
+
expect(Saper::Recipe.new.push(Saper::Action.new(:nothing))).to be_a Saper::Recipe
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
context "#push(invalid)" do
|
|
48
|
+
it "raises ActionExpected" do
|
|
49
|
+
expect { Saper::Recipe.new.push('not an action') }.to raise_error Saper::ActionExpected
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
context "#empty?" do
|
|
53
|
+
it "returns true by default" do
|
|
54
|
+
expect(subject).to be_empty
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
context "#multiple?" do
|
|
58
|
+
it "returns false by default" do
|
|
59
|
+
expect(subject).to_not be_multiple
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
context "#requires" do
|
|
63
|
+
it "returns empty array by default" do
|
|
64
|
+
expect(subject.requires).to eq []
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
context "#requires?" do
|
|
68
|
+
it "returns false by default" do
|
|
69
|
+
expect(subject.requires?).to be false
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
context "#run" do
|
|
73
|
+
it "returns Result instance" do
|
|
74
|
+
expect(subject.run).to be_a Saper::Result
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
context "#serialize" do
|
|
78
|
+
it "returns a Hash" do
|
|
79
|
+
expect(subject.serialize).to be_a Hash
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
context "#to_string" do
|
|
83
|
+
it "returns a string" do
|
|
84
|
+
expect(subject.to_string).to be_a String
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
context "#to_json" do
|
|
88
|
+
it "returns a string" do
|
|
89
|
+
expect(subject.to_json).to be_a String
|
|
90
|
+
end
|
|
57
91
|
end
|
|
58
92
|
end
|