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
|
@@ -1,7 +1,163 @@
|
|
|
1
1
|
require './spec/spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Saper::Actions::RemoveBefore do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
RSpec.describe Saper::Actions::RemoveBefore do
|
|
4
|
+
let :subject do
|
|
5
|
+
Saper::Actions::RemoveBefore.new('!')
|
|
6
|
+
end
|
|
7
|
+
context ".type" do
|
|
8
|
+
it "returns remove_before" do
|
|
9
|
+
expect(described_class.type).to eq 'remove_before'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
context ".accepts?(:atom)" do
|
|
13
|
+
it "returns false" do
|
|
14
|
+
expect(described_class.accepts?(:atom)).to be false
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
context ".accepts?(:html)" do
|
|
18
|
+
it "returns false" do
|
|
19
|
+
expect(described_class.accepts?(:html)).to be false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
context ".accepts?(:json)" do
|
|
23
|
+
it "returns false" do
|
|
24
|
+
expect(described_class.accepts?(:json)).to be false
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
context ".accepts?(:markdown)" do
|
|
28
|
+
it "returns false" do
|
|
29
|
+
expect(described_class.accepts?(:markdown)).to be false
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
context ".accepts?(:nothing)" do
|
|
33
|
+
it "returns false" do
|
|
34
|
+
expect(described_class.accepts?(:nothing)).to be false
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
context ".accepts?(:text)" do
|
|
38
|
+
it "returns true" do
|
|
39
|
+
expect(described_class.accepts?(:text)).to be true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
context ".accepts?(:time)" do
|
|
43
|
+
it "returns false" do
|
|
44
|
+
expect(described_class.accepts?(:time)).to be false
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
context ".accepts?(:url)" do
|
|
48
|
+
it "returns false" do
|
|
49
|
+
expect(described_class.accepts?(:url)).to be false
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
context ".accepts?(:xml)" do
|
|
53
|
+
it "returns false" do
|
|
54
|
+
expect(described_class.accepts?(:xml)).to be false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
context ".output_for(:atom)" do
|
|
58
|
+
it "returns :nothing" do
|
|
59
|
+
expect(described_class.output_for(:atom)).to be :nothing
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
context ".output_for(:document)" do
|
|
63
|
+
it "returns :nothing" do
|
|
64
|
+
expect(described_class.output_for(:document)).to be :nothing
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
context ".output_for(:html)" do
|
|
68
|
+
it "returns :nothing" do
|
|
69
|
+
expect(described_class.output_for(:html)).to be :nothing
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
context ".output_for(:json)" do
|
|
73
|
+
it "returns :nothing" do
|
|
74
|
+
expect(described_class.output_for(:json)).to be :nothing
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
context ".output_for(:markdown)" do
|
|
78
|
+
it "returns :nothing" do
|
|
79
|
+
expect(described_class.output_for(:markdown)).to be :nothing
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
context ".output_for(:text)" do
|
|
83
|
+
it "returns :text" do
|
|
84
|
+
expect(described_class.output_for(:text)).to be :text
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
context ".output_for(:time)" do
|
|
88
|
+
it "returns :nothing" do
|
|
89
|
+
expect(described_class.output_for(:time)).to be :nothing
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
context ".output_for(:url)" do
|
|
93
|
+
it "returns :nothing" do
|
|
94
|
+
expect(described_class.output_for(:url)).to be :nothing
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
context ".output_for(:xml)" do
|
|
98
|
+
it "returns :nothing" do
|
|
99
|
+
expect(described_class.output_for(:xml)).to be :nothing
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
context ".returns_multiple_items?" do
|
|
103
|
+
it "returns false" do
|
|
104
|
+
expect(described_class.returns_multiple_items?).to be false
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
context ".new(nil)" do
|
|
108
|
+
it "raises InvalidArgument" do
|
|
109
|
+
expect { described_class.new }.to raise_error Saper::InvalidArgument
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
context ".new(Numeric)" do
|
|
113
|
+
it "raises InvalidArgument" do
|
|
114
|
+
expect { described_class.new(2) }.to raise_error Saper::InvalidArgument
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
context ".new(Hash)" do
|
|
118
|
+
it "raises InvalidArgumenth" do
|
|
119
|
+
expect { described_class.new({}) }.to raise_error Saper::InvalidArgument
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
context ".new(Array)" do
|
|
123
|
+
it "raises InvalidArgument" do
|
|
124
|
+
expect { described_class.new([]) }.to raise_error Saper::InvalidArgument
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
context ".new(String)" do
|
|
128
|
+
it "returns Action instance" do
|
|
129
|
+
expect(described_class.new("!")).to be_a Saper::Action
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
context ".new(Text)" do
|
|
133
|
+
it "returns Action instance" do
|
|
134
|
+
expect(described_class.new(Saper::Arguments::Text.new(:value => "!"))).to be_a Saper::Action
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
context "#run(nil)" do
|
|
138
|
+
it "raises InvalidInput" do
|
|
139
|
+
expect { subject.run(nil) }.to raise_error Saper::InvalidInput
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
context "#run(Numeric)" do
|
|
143
|
+
it "returns valid output" do
|
|
144
|
+
expect { subject.run(1) }.to raise_error Saper::InvalidInput
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
context "#run(String)" do
|
|
148
|
+
it "returns Text instance" do
|
|
149
|
+
expect(subject.run('a!b')).to be_a Saper::Items::Text
|
|
150
|
+
end
|
|
151
|
+
it "returns valid output" do
|
|
152
|
+
expect(subject.run('a!b').to_s).to eq 'b'
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
context "#run(String)" do
|
|
156
|
+
it "returns Text instance" do
|
|
157
|
+
expect(subject.run(Saper::Items::Text.new('a!b'))).to be_a Saper::Items::Text
|
|
158
|
+
end
|
|
159
|
+
it "returns valid output" do
|
|
160
|
+
expect(subject.run(Saper::Items::Text.new('a!b')).to_s).to eq 'b'
|
|
161
|
+
end
|
|
162
|
+
end
|
|
7
163
|
end
|
|
@@ -1,7 +1,167 @@
|
|
|
1
1
|
require './spec/spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Saper::Actions::RemoveMatching do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
RSpec.describe Saper::Actions::RemoveMatching do
|
|
4
|
+
let :subject do
|
|
5
|
+
Saper::Actions::RemoveMatching.new('abc')
|
|
6
|
+
end
|
|
7
|
+
context ".type" do
|
|
8
|
+
it "returns remove_matching" do
|
|
9
|
+
expect(described_class.type).to eq 'remove_matching'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
context ".accepts?(:atom)" do
|
|
13
|
+
it "returns false" do
|
|
14
|
+
expect(described_class.accepts?(:atom)).to be false
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
context ".accepts?(:html)" do
|
|
18
|
+
it "returns false" do
|
|
19
|
+
expect(described_class.accepts?(:html)).to be false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
context ".accepts?(:json)" do
|
|
23
|
+
it "returns false" do
|
|
24
|
+
expect(described_class.accepts?(:json)).to be false
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
context ".accepts?(:markdown)" do
|
|
28
|
+
it "returns false" do
|
|
29
|
+
expect(described_class.accepts?(:markdown)).to be false
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
context ".accepts?(:nothing)" do
|
|
33
|
+
it "returns false" do
|
|
34
|
+
expect(described_class.accepts?(:nothing)).to be false
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
context ".accepts?(:text)" do
|
|
38
|
+
it "returns true" do
|
|
39
|
+
expect(described_class.accepts?(:text)).to be true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
context ".accepts?(:time)" do
|
|
43
|
+
it "returns false" do
|
|
44
|
+
expect(described_class.accepts?(:time)).to be false
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
context ".accepts?(:url)" do
|
|
48
|
+
it "returns false" do
|
|
49
|
+
expect(described_class.accepts?(:url)).to be false
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
context ".accepts?(:xml)" do
|
|
53
|
+
it "returns false" do
|
|
54
|
+
expect(described_class.accepts?(:xml)).to be false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
context ".output_for(:atom)" do
|
|
58
|
+
it "returns :nothing" do
|
|
59
|
+
expect(described_class.output_for(:atom)).to be :nothing
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
context ".output_for(:document)" do
|
|
63
|
+
it "returns :nothing" do
|
|
64
|
+
expect(described_class.output_for(:document)).to be :nothing
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
context ".output_for(:html)" do
|
|
68
|
+
it "returns :nothing" do
|
|
69
|
+
expect(described_class.output_for(:html)).to be :nothing
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
context ".output_for(:json)" do
|
|
73
|
+
it "returns :nothing" do
|
|
74
|
+
expect(described_class.output_for(:json)).to be :nothing
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
context ".output_for(:markdown)" do
|
|
78
|
+
it "returns :nothing" do
|
|
79
|
+
expect(described_class.output_for(:markdown)).to be :nothing
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
context ".output_for(:text)" do
|
|
83
|
+
it "returns :text" do
|
|
84
|
+
expect(described_class.output_for(:text)).to be :text
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
context ".output_for(:time)" do
|
|
88
|
+
it "returns :nothing" do
|
|
89
|
+
expect(described_class.output_for(:time)).to be :nothing
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
context ".output_for(:url)" do
|
|
93
|
+
it "returns :nothing" do
|
|
94
|
+
expect(described_class.output_for(:url)).to be :nothing
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
context ".output_for(:xml)" do
|
|
98
|
+
it "returns :nothing" do
|
|
99
|
+
expect(described_class.output_for(:xml)).to be :nothing
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
context ".returns_multiple_items?" do
|
|
103
|
+
it "returns false" do
|
|
104
|
+
expect(described_class.returns_multiple_items?).to be false
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
context ".new(nil)" do
|
|
108
|
+
it "raises InvalidArgument" do
|
|
109
|
+
expect { described_class.new }.to raise_error Saper::InvalidArgument
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
context ".new(Numeric)" do
|
|
113
|
+
it "raises InvalidArgument" do
|
|
114
|
+
expect { described_class.new(2) }.to raise_error Saper::InvalidArgument
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
context ".new(Hash)" do
|
|
118
|
+
it "raises InvalidArgumenth" do
|
|
119
|
+
expect { described_class.new({}) }.to raise_error Saper::InvalidArgument
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
context ".new(Array)" do
|
|
123
|
+
it "raises InvalidArgument" do
|
|
124
|
+
expect { described_class.new([]) }.to raise_error Saper::InvalidArgument
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
context ".new(String)" do
|
|
128
|
+
it "returns Action instance" do
|
|
129
|
+
expect(described_class.new("!")).to be_a Saper::Action
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
context ".new(Text)" do
|
|
133
|
+
it "returns Action instance" do
|
|
134
|
+
expect(described_class.new(Saper::Arguments::Text.new(:value => "!"))).to be_a Saper::Action
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
context "#run(nil)" do
|
|
138
|
+
it "raises InvalidInput" do
|
|
139
|
+
expect { subject.run(nil) }.to raise_error Saper::InvalidInput
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
context "#run(Numeric)" do
|
|
143
|
+
it "returns valid output" do
|
|
144
|
+
expect { subject.run(1) }.to raise_error Saper::InvalidInput
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
context "#run(matching String)" do
|
|
148
|
+
it "returns nil" do
|
|
149
|
+
expect(subject.run('abc')).to be_a Saper::Items::Nothing
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
context "#run(non-matching String)" do
|
|
153
|
+
it "returns Text instance" do
|
|
154
|
+
expect(subject.run('xyz')).to be_a Saper::Items::Text
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
context "#run(matching Text)" do
|
|
158
|
+
it "returns nil" do
|
|
159
|
+
expect(subject.run(Saper::Items::Text.new('abc'))).to be_a Saper::Items::Nothing
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
context "#run(non-matching Text)" do
|
|
163
|
+
it "returns Text instance" do
|
|
164
|
+
expect(subject.run(Saper::Items::Text.new('xyz'))).to be_a Saper::Items::Text
|
|
165
|
+
end
|
|
166
|
+
end
|
|
7
167
|
end
|
data/spec/actions/save_spec.rb
CHANGED
|
@@ -1,7 +1,167 @@
|
|
|
1
1
|
require './spec/spec_helper'
|
|
2
2
|
|
|
3
|
-
describe Saper::Actions::SelectMatching do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
RSpec.describe Saper::Actions::SelectMatching do
|
|
4
|
+
let :subject do
|
|
5
|
+
Saper::Actions::SelectMatching.new('xyz')
|
|
6
|
+
end
|
|
7
|
+
context ".type" do
|
|
8
|
+
it "returns remove_matching" do
|
|
9
|
+
expect(described_class.type).to eq 'select_matching'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
context ".accepts?(:atom)" do
|
|
13
|
+
it "returns false" do
|
|
14
|
+
expect(described_class.accepts?(:atom)).to be false
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
context ".accepts?(:html)" do
|
|
18
|
+
it "returns false" do
|
|
19
|
+
expect(described_class.accepts?(:html)).to be false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
context ".accepts?(:json)" do
|
|
23
|
+
it "returns false" do
|
|
24
|
+
expect(described_class.accepts?(:json)).to be false
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
context ".accepts?(:markdown)" do
|
|
28
|
+
it "returns false" do
|
|
29
|
+
expect(described_class.accepts?(:markdown)).to be false
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
context ".accepts?(:nothing)" do
|
|
33
|
+
it "returns false" do
|
|
34
|
+
expect(described_class.accepts?(:nothing)).to be false
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
context ".accepts?(:text)" do
|
|
38
|
+
it "returns true" do
|
|
39
|
+
expect(described_class.accepts?(:text)).to be true
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
context ".accepts?(:time)" do
|
|
43
|
+
it "returns false" do
|
|
44
|
+
expect(described_class.accepts?(:time)).to be false
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
context ".accepts?(:url)" do
|
|
48
|
+
it "returns false" do
|
|
49
|
+
expect(described_class.accepts?(:url)).to be false
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
context ".accepts?(:xml)" do
|
|
53
|
+
it "returns false" do
|
|
54
|
+
expect(described_class.accepts?(:xml)).to be false
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
context ".output_for(:atom)" do
|
|
58
|
+
it "returns :nothing" do
|
|
59
|
+
expect(described_class.output_for(:atom)).to be :nothing
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
context ".output_for(:document)" do
|
|
63
|
+
it "returns :nothing" do
|
|
64
|
+
expect(described_class.output_for(:document)).to be :nothing
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
context ".output_for(:html)" do
|
|
68
|
+
it "returns :nothing" do
|
|
69
|
+
expect(described_class.output_for(:html)).to be :nothing
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
context ".output_for(:json)" do
|
|
73
|
+
it "returns :nothing" do
|
|
74
|
+
expect(described_class.output_for(:json)).to be :nothing
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
context ".output_for(:markdown)" do
|
|
78
|
+
it "returns :nothing" do
|
|
79
|
+
expect(described_class.output_for(:markdown)).to be :nothing
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
context ".output_for(:text)" do
|
|
83
|
+
it "returns :text" do
|
|
84
|
+
expect(described_class.output_for(:text)).to be :text
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
context ".output_for(:time)" do
|
|
88
|
+
it "returns :nothing" do
|
|
89
|
+
expect(described_class.output_for(:time)).to be :nothing
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
context ".output_for(:url)" do
|
|
93
|
+
it "returns :nothing" do
|
|
94
|
+
expect(described_class.output_for(:url)).to be :nothing
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
context ".output_for(:xml)" do
|
|
98
|
+
it "returns :nothing" do
|
|
99
|
+
expect(described_class.output_for(:xml)).to be :nothing
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
context ".returns_multiple_items?" do
|
|
103
|
+
it "returns false" do
|
|
104
|
+
expect(described_class.returns_multiple_items?).to be false
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
context ".new(nil)" do
|
|
108
|
+
it "raises InvalidArgument" do
|
|
109
|
+
expect { described_class.new }.to raise_error Saper::InvalidArgument
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
context ".new(Numeric)" do
|
|
113
|
+
it "raises InvalidArgument" do
|
|
114
|
+
expect { described_class.new(2) }.to raise_error Saper::InvalidArgument
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
context ".new(Hash)" do
|
|
118
|
+
it "raises InvalidArgumenth" do
|
|
119
|
+
expect { described_class.new({}) }.to raise_error Saper::InvalidArgument
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
context ".new(Array)" do
|
|
123
|
+
it "raises InvalidArgument" do
|
|
124
|
+
expect { described_class.new([]) }.to raise_error Saper::InvalidArgument
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
context ".new(String)" do
|
|
128
|
+
it "returns Action instance" do
|
|
129
|
+
expect(described_class.new("!")).to be_a Saper::Action
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
context ".new(Text)" do
|
|
133
|
+
it "returns Action instance" do
|
|
134
|
+
expect(described_class.new(Saper::Arguments::Text.new(:value => "!"))).to be_a Saper::Action
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
context "#run(nil)" do
|
|
138
|
+
it "raises InvalidInput" do
|
|
139
|
+
expect { subject.run(nil) }.to raise_error Saper::InvalidInput
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
context "#run(Numeric)" do
|
|
143
|
+
it "returns valid output" do
|
|
144
|
+
expect { subject.run(1) }.to raise_error Saper::InvalidInput
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
context "#run(non-matching String)" do
|
|
148
|
+
it "returns nil" do
|
|
149
|
+
expect(subject.run('abc')).to be_a Saper::Items::Nothing
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
context "#run(matching String)" do
|
|
153
|
+
it "returns Text instance" do
|
|
154
|
+
expect(subject.run('xyz')).to be_a Saper::Items::Text
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
context "#run(non-matching Text)" do
|
|
158
|
+
it "returns nil" do
|
|
159
|
+
expect(subject.run(Saper::Items::Text.new('abc'))).to be_a Saper::Items::Nothing
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
context "#run(matching Text)" do
|
|
163
|
+
it "returns Text instance" do
|
|
164
|
+
expect(subject.run(Saper::Items::Text.new('xyz'))).to be_a Saper::Items::Text
|
|
165
|
+
end
|
|
166
|
+
end
|
|
7
167
|
end
|