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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/Rakefile +7 -5
  4. data/bin/saper +51 -1
  5. data/lib/saper/actions/create_atom.rb +0 -5
  6. data/lib/saper/actions/nothing.rb +2 -0
  7. data/lib/saper/actions/remove_matching.rb +1 -1
  8. data/lib/saper/actions/run_recipe.rb +5 -5
  9. data/lib/saper/actions/run_recipe_and_save.rb +5 -5
  10. data/lib/saper/actions/select_matching.rb +1 -1
  11. data/lib/saper/actions/set_input.rb +0 -5
  12. data/lib/saper/core/action.rb +69 -53
  13. data/lib/saper/core/argument.rb +3 -0
  14. data/lib/saper/core/browser.rb +3 -2
  15. data/lib/saper/core/error.rb +4 -1
  16. data/lib/saper/core/keychain.rb +2 -2
  17. data/lib/saper/core/logger.rb +9 -54
  18. data/lib/saper/core/recipe.rb +36 -5
  19. data/lib/saper/core/result.rb +36 -5
  20. data/lib/saper/core/runtime.rb +17 -11
  21. data/lib/saper/core/stack.rb +17 -1
  22. data/lib/saper/items/html.rb +1 -1
  23. data/lib/saper/items/nothing.rb +9 -0
  24. data/lib/saper/items/xml.rb +5 -1
  25. data/lib/saper/version.rb +1 -1
  26. data/lib/tungsten/lib/README +5 -0
  27. data/lib/tungsten/lib/test.rb +18 -0
  28. data/lib/tungsten/lib/tungsten.rb +33 -0
  29. data/lib/tungsten/lib/tungsten/headers.rb +37 -0
  30. data/lib/tungsten/lib/tungsten/jar.rb +17 -0
  31. data/lib/tungsten/lib/tungsten/request.rb +102 -0
  32. data/lib/tungsten/lib/tungsten/response.rb +101 -0
  33. data/spec/actions/append_with_spec.rb +144 -21
  34. data/spec/actions/convert_to_html_spec.rb +126 -11
  35. data/spec/actions/convert_to_json_spec.rb +126 -11
  36. data/spec/actions/convert_to_markdown_spec.rb +126 -11
  37. data/spec/actions/convert_to_time_spec.rb +150 -15
  38. data/spec/actions/convert_to_xml_spec.rb +136 -11
  39. data/spec/actions/create_atom_spec.rb +116 -7
  40. data/spec/actions/fetch_spec.rb +110 -3
  41. data/spec/actions/find_first_spec.rb +149 -24
  42. data/spec/actions/find_spec.rb +167 -19
  43. data/spec/actions/get_attribute_spec.rb +145 -15
  44. data/spec/actions/get_contents_spec.rb +125 -4
  45. data/spec/actions/get_text_spec.rb +125 -4
  46. data/spec/actions/nothing_spec.rb +119 -4
  47. data/spec/actions/prepend_with_spec.rb +148 -22
  48. data/spec/actions/remove_after_spec.rb +160 -4
  49. data/spec/actions/remove_before_spec.rb +160 -4
  50. data/spec/actions/remove_matching_spec.rb +164 -4
  51. data/spec/actions/remove_tags_spec.rb +1 -1
  52. data/spec/actions/replace_spec.rb +1 -1
  53. data/spec/actions/run_recipe_and_save_spec.rb +1 -1
  54. data/spec/actions/run_recipe_spec.rb +1 -1
  55. data/spec/actions/save_spec.rb +1 -1
  56. data/spec/actions/select_matching_spec.rb +164 -4
  57. data/spec/actions/set_input_spec.rb +1 -1
  58. data/spec/actions/skip_tags_spec.rb +1 -1
  59. data/spec/actions/split_spec.rb +1 -1
  60. data/spec/arguments/attribute_spec.rb +1 -1
  61. data/spec/arguments/recipe_spec.rb +1 -1
  62. data/spec/arguments/text_spec.rb +1 -1
  63. data/spec/arguments/timezone_spec.rb +1 -1
  64. data/spec/arguments/variable_spec.rb +1 -1
  65. data/spec/arguments/xpath_spec.rb +1 -1
  66. data/spec/core/action_spec.rb +25 -13
  67. data/spec/core/argument_spec.rb +55 -31
  68. data/spec/core/browser_spec.rb +21 -11
  69. data/spec/core/dsl_spec.rb +1 -1
  70. data/spec/core/item_spec.rb +1 -1
  71. data/spec/core/keychain_spec.rb +1 -1
  72. data/spec/core/logger_spec.rb +1 -1
  73. data/spec/core/namespace_spec.rb +1 -1
  74. data/spec/core/recipe_spec.rb +85 -51
  75. data/spec/core/result_spec.rb +1 -1
  76. data/spec/core/runtime_spec.rb +45 -27
  77. data/spec/core/stack_spec.rb +1 -1
  78. data/spec/core/type_spec.rb +1 -1
  79. data/spec/integration/simple_invalid_spec.rb +46 -9
  80. data/spec/integration/simple_valid_spec.rb +9 -9
  81. data/spec/items/atom_spec.rb +7 -7
  82. data/spec/items/document_spec.rb +29 -29
  83. data/spec/items/html_spec.rb +80 -48
  84. data/spec/items/json_spec.rb +17 -11
  85. data/spec/items/markdown_spec.rb +30 -18
  86. data/spec/items/nothing_spec.rb +1 -1
  87. data/spec/items/text_spec.rb +12 -10
  88. data/spec/items/time_spec.rb +35 -21
  89. data/spec/items/url_spec.rb +1 -1
  90. data/spec/items/xml_spec.rb +75 -42
  91. data/spec/spec_helper.rb +90 -2
  92. metadata +51 -16
@@ -1,7 +1,128 @@
1
1
  require './spec/spec_helper'
2
2
 
3
- describe Saper::Actions::GetText do
4
-
5
- it # TODO
6
-
3
+ RSpec.describe Saper::Actions::GetText do
4
+ subject do
5
+ Saper::Actions::GetText.new()
6
+ end
7
+ let :html do
8
+ Saper::Items::HTML.new("<html><body><p>test</p></body></html>")
9
+ end
10
+ context ".type" do
11
+ it "returns get_text" do
12
+ expect(described_class.type).to eq 'get_text'
13
+ end
14
+ end
15
+ context ".accepts?(:atom)" do
16
+ it "returns false" do
17
+ expect(described_class.accepts?(:atom)).to be false
18
+ end
19
+ end
20
+ context ".accepts?(:html)" do
21
+ it "returns true" do
22
+ expect(described_class.accepts?(:html)).to be true
23
+ end
24
+ end
25
+ context ".accepts?(:json)" do
26
+ it "returns false" do
27
+ expect(described_class.accepts?(:json)).to be false
28
+ end
29
+ end
30
+ context ".accepts?(:markdown)" do
31
+ it "returns false" do
32
+ expect(described_class.accepts?(:markdown)).to be false
33
+ end
34
+ end
35
+ context ".accepts?(:nothing)" do
36
+ it "returns false" do
37
+ expect(described_class.accepts?(:nothing)).to be false
38
+ end
39
+ end
40
+ context ".accepts?(:text)" do
41
+ it "returns false" do
42
+ expect(described_class.accepts?(:text)).to be false
43
+ end
44
+ end
45
+ context ".accepts?(:time)" do
46
+ it "returns false" do
47
+ expect(described_class.accepts?(:time)).to be false
48
+ end
49
+ end
50
+ context ".accepts?(:url)" do
51
+ it "returns false" do
52
+ expect(described_class.accepts?(:url)).to be false
53
+ end
54
+ end
55
+ context ".accepts?(:xml)" do
56
+ it "returns true" do
57
+ expect(described_class.accepts?(:xml)).to be true
58
+ end
59
+ end
60
+ context ".output_for(:atom)" do
61
+ it "returns :nothing" do
62
+ expect(described_class.output_for(:atom)).to be :nothing
63
+ end
64
+ end
65
+ context ".output_for(:document)" do
66
+ it "returns :nothing" do
67
+ expect(described_class.output_for(:document)).to be :nothing
68
+ end
69
+ end
70
+ context ".output_for(:html)" do
71
+ it "returns :text" do
72
+ expect(described_class.output_for(:html)).to be :text
73
+ end
74
+ end
75
+ context ".output_for(:json)" do
76
+ it "returns :nothing" do
77
+ expect(described_class.output_for(:json)).to be :nothing
78
+ end
79
+ end
80
+ context ".output_for(:markdown)" do
81
+ it "returns :nothing" do
82
+ expect(described_class.output_for(:markdown)).to be :nothing
83
+ end
84
+ end
85
+ context ".output_for(:text)" do
86
+ it "returns :nothing" do
87
+ expect(described_class.output_for(:text)).to be :nothing
88
+ end
89
+ end
90
+ context ".output_for(:time)" do
91
+ it "returns :nothing" do
92
+ expect(described_class.output_for(:time)).to be :nothing
93
+ end
94
+ end
95
+ context ".output_for(:url)" do
96
+ it "returns :nothing" do
97
+ expect(described_class.output_for(:url)).to be :nothing
98
+ end
99
+ end
100
+ context ".output_for(:xml)" do
101
+ it "returns :text" do
102
+ expect(described_class.output_for(:xml)).to be :text
103
+ end
104
+ end
105
+ context ".returns_multiple_items?" do
106
+ it "returns false" do
107
+ expect(described_class.returns_multiple_items?).to be false
108
+ end
109
+ end
110
+ context ".new(nil)" do
111
+ it "raises no errors" do
112
+ expect { described_class.new(nil) }.to_not raise_error
113
+ end
114
+ end
115
+ context "#run(nil)" do
116
+ it "raises InvalidInput" do
117
+ expect { subject.run(nil) }.to raise_error Saper::InvalidInput
118
+ end
119
+ end
120
+ context "#run(HTML)" do
121
+ it "returns HTML instance" do
122
+ expect(subject.run(html)).to be_a Saper::Items::Text
123
+ end
124
+ it "returns valid output" do
125
+ expect(subject.run(html).to_s).to eq 'test'
126
+ end
127
+ end
7
128
  end
@@ -1,7 +1,122 @@
1
1
  require './spec/spec_helper'
2
2
 
3
- describe Saper::Actions::Nothing do
4
-
5
- it # TODO
6
-
3
+ RSpec.describe Saper::Actions::Nothing do
4
+ context ".type" do
5
+ it "returns nothing" do
6
+ expect(described_class.type).to eq 'nothing'
7
+ end
8
+ end
9
+ context ".accepts?(:atom)" do
10
+ it "returns true" do
11
+ expect(described_class.accepts?(:atom)).to be true
12
+ end
13
+ end
14
+ context ".accepts?(:html)" do
15
+ it "returns true" do
16
+ expect(described_class.accepts?(:html)).to be true
17
+ end
18
+ end
19
+ context ".accepts?(:json)" do
20
+ it "returns true" do
21
+ expect(described_class.accepts?(:json)).to be true
22
+ end
23
+ end
24
+ context ".accepts?(:markdown)" do
25
+ it "returns true" do
26
+ expect(described_class.accepts?(:markdown)).to be true
27
+ end
28
+ end
29
+ context ".accepts?(:nothing)" do
30
+ it "returns true" do
31
+ expect(described_class.accepts?(:nothing)).to be true
32
+ end
33
+ end
34
+ context ".accepts?(:text)" do
35
+ it "returns true" do
36
+ expect(described_class.accepts?(:text)).to be true
37
+ end
38
+ end
39
+ context ".accepts?(:time)" do
40
+ it "returns true" do
41
+ expect(described_class.accepts?(:time)).to be true
42
+ end
43
+ end
44
+ context ".accepts?(:url)" do
45
+ it "returns true" do
46
+ expect(described_class.accepts?(:url)).to be true
47
+ end
48
+ end
49
+ context ".accepts?(:xml)" do
50
+ it "returns true" do
51
+ expect(described_class.accepts?(:xml)).to be true
52
+ end
53
+ end
54
+ context ".output_for(:atom)" do
55
+ it "returns :atom" do
56
+ expect(described_class.output_for(:atom)).to be :atom
57
+ end
58
+ end
59
+ context ".output_for(:document)" do
60
+ it "returns :document" do
61
+ expect(described_class.output_for(:document)).to be :document
62
+ end
63
+ end
64
+ context ".output_for(:html)" do
65
+ it "returns :html" do
66
+ expect(described_class.output_for(:html)).to be :html
67
+ end
68
+ end
69
+ context ".output_for(:json)" do
70
+ it "returns :json" do
71
+ expect(described_class.output_for(:json)).to be :json
72
+ end
73
+ end
74
+ context ".output_for(:markdown)" do
75
+ it "returns :markdown" do
76
+ expect(described_class.output_for(:markdown)).to be :markdown
77
+ end
78
+ end
79
+ context ".output_for(:text)" do
80
+ it "returns :text" do
81
+ expect(described_class.output_for(:text)).to be :text
82
+ end
83
+ end
84
+ context ".output_for(:time)" do
85
+ it "returns :time" do
86
+ expect(described_class.output_for(:time)).to be :time
87
+ end
88
+ end
89
+ context ".output_for(:url)" do
90
+ it "returns :url" do
91
+ expect(described_class.output_for(:url)).to be :url
92
+ end
93
+ end
94
+ context ".output_for(:xml)" do
95
+ it "returns :xml" do
96
+ expect(described_class.output_for(:xml)).to be :xml
97
+ end
98
+ end
99
+ context ".returns_multiple_items?" do
100
+ it "returns false" do
101
+ expect(described_class.returns_multiple_items?).to be false
102
+ end
103
+ end
104
+ context ".new(nil)" do
105
+ it "raises no errors" do
106
+ expect { described_class.new(nil) }.to_not raise_error
107
+ end
108
+ end
109
+ context "#run(nil)" do
110
+ it "raises no errors" do
111
+ expect { subject.run(nil) }.to_not raise_error
112
+ end
113
+ it "returns nil" do
114
+ expect(subject.run(nil)).to be_nil
115
+ end
116
+ end
117
+ context "#run(String)" do
118
+ it "returns same string" do
119
+ expect(subject.run("abcde")).to eq 'abcde'
120
+ end
121
+ end
7
122
  end
@@ -1,37 +1,163 @@
1
1
  require './spec/spec_helper'
2
2
 
3
- describe Saper::Actions::PrependWith do
3
+ RSpec.describe Saper::Actions::PrependWith do
4
4
  let :subject do
5
- Saper::Action.new(:prepend_with, '!')
5
+ Saper::Actions::PrependWith.new('!')
6
6
  end
7
- it ".new(nil) raises InvalidArgument" do
8
- lambda { Saper::Actions::PrependWith.new }.must_raise(Saper::InvalidArgument)
7
+ context ".type" do
8
+ it "returns prepend_with" do
9
+ expect(described_class.type).to eq 'prepend_with'
10
+ end
9
11
  end
10
- it ".new(Numeric) raises InvalidArgument" do
11
- lambda { Saper::Actions::PrependWith.new(2) }.must_raise(Saper::InvalidArgument)
12
+ context ".accepts?(:atom)" do
13
+ it "returns false" do
14
+ expect(described_class.accepts?(:atom)).to be false
15
+ end
12
16
  end
13
- it ".new(Hash) raises InvalidArgumenth" do
14
- lambda { Saper::Actions::PrependWith.new({}) }.must_raise(Saper::InvalidArgument)
17
+ context ".accepts?(:html)" do
18
+ it "returns false" do
19
+ expect(described_class.accepts?(:html)).to be false
20
+ end
15
21
  end
16
- it ".new(Array) raises InvalidArgument" do
17
- lambda { Saper::Actions::PrependWith.new([]) }.must_raise(Saper::InvalidArgument)
22
+ context ".accepts?(:json)" do
23
+ it "returns false" do
24
+ expect(described_class.accepts?(:json)).to be false
25
+ end
18
26
  end
19
- it ".new(String)returns Action instance" do
20
- Saper::Actions::PrependWith.new("!").must_be_kind_of(Saper::Action)
27
+ context ".accepts?(:markdown)" do
28
+ it "returns false" do
29
+ expect(described_class.accepts?(:markdown)).to be false
30
+ end
21
31
  end
22
- it "#run(nil) raises InvalidInput" do
23
- lambda { subject.run(nil) }.must_raise(Saper::InvalidInput)
32
+ context ".accepts?(:nothing)" do
33
+ it "returns false" do
34
+ expect(described_class.accepts?(:nothing)).to be false
35
+ end
24
36
  end
25
- it "#run(Numeric) returns valid output" do
26
- lambda { subject.run(1) }.must_raise(Saper::InvalidInput)
37
+ context ".accepts?(:text)" do
38
+ it "returns true" do
39
+ expect(described_class.accepts?(:text)).to be true
40
+ end
27
41
  end
28
- it "#run(String) returns valid output" do
29
- subject.run('string').must_be :==, '!string'
42
+ context ".accepts?(:time)" do
43
+ it "returns false" do
44
+ expect(described_class.accepts?(:time)).to be false
45
+ end
30
46
  end
31
- it "#run(Text) returns valid output" do
32
- subject.run(Saper::Items::Text.new('string')).must_be :==, '!string'
47
+ context ".accepts?(:url)" do
48
+ it "returns false" do
49
+ expect(described_class.accepts?(:url)).to be false
50
+ end
33
51
  end
34
- it "#run returns Text instance" do
35
- subject.run('string').must_be_instance_of(Saper::Items::Text)
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('string')).to be_a Saper::Items::Text
150
+ end
151
+ it "returns valid output" do
152
+ expect(subject.run('string')).to eq '!string'
153
+ end
154
+ end
155
+ context "#run(Text)" do
156
+ it "returns Text instance" do
157
+ expect(subject.run(Saper::Items::Text.new('string'))).to be_a Saper::Items::Text
158
+ end
159
+ it "returns valid output" do
160
+ expect(subject.run(Saper::Items::Text.new('string'))).to eq '!string'
161
+ end
36
162
  end
37
163
  end
@@ -1,7 +1,163 @@
1
1
  require './spec/spec_helper'
2
2
 
3
- describe Saper::Actions::RemoveAfter do
4
-
5
- it # TODO
6
-
3
+ RSpec.describe Saper::Actions::RemoveAfter do
4
+ let :subject do
5
+ Saper::Actions::RemoveAfter.new('!')
6
+ end
7
+ context ".type" do
8
+ it "returns remove_after" do
9
+ expect(described_class.type).to eq 'remove_after'
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 'a'
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 'a'
161
+ end
162
+ end
7
163
  end