webspicy 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/bin/webspicy +6 -1
  3. data/doc/1-black-box-scene.md +109 -0
  4. data/doc/2-black-box-testing.md +27 -0
  5. data/doc/3-specification-importance.md +41 -0
  6. data/doc/4-sequence-diagram.md +82 -0
  7. data/lib/webspicy.rb +17 -7
  8. data/lib/webspicy/configuration.rb +48 -8
  9. data/lib/webspicy/configuration/scope.rb +22 -8
  10. data/lib/webspicy/formaldoc.fio +5 -5
  11. data/lib/webspicy/specification.rb +2 -0
  12. data/lib/webspicy/specification/condition.rb +23 -0
  13. data/lib/webspicy/specification/errcondition.rb +1 -0
  14. data/lib/webspicy/specification/postcondition.rb +1 -0
  15. data/lib/webspicy/specification/precondition.rb +1 -0
  16. data/lib/webspicy/specification/service.rb +11 -6
  17. data/lib/webspicy/specification/test_case.rb +8 -9
  18. data/lib/webspicy/support.rb +21 -0
  19. data/lib/webspicy/support/hooks.rb +65 -0
  20. data/lib/webspicy/support/world.rb +47 -0
  21. data/lib/webspicy/tester.rb +136 -3
  22. data/lib/webspicy/tester/client.rb +22 -42
  23. data/lib/webspicy/tester/file_checker.rb +22 -0
  24. data/lib/webspicy/tester/invocation.rb +15 -48
  25. data/lib/webspicy/tester/reporter.rb +85 -0
  26. data/lib/webspicy/tester/reporter/composite.rb +38 -0
  27. data/lib/webspicy/tester/reporter/documentation.rb +67 -0
  28. data/lib/webspicy/tester/reporter/error_count.rb +25 -0
  29. data/lib/webspicy/tester/reporter/exceptions.rb +60 -0
  30. data/lib/webspicy/tester/reporter/file_progress.rb +22 -0
  31. data/lib/webspicy/tester/reporter/file_summary.rb +42 -0
  32. data/lib/webspicy/tester/reporter/progress.rb +28 -0
  33. data/lib/webspicy/tester/reporter/summary.rb +62 -0
  34. data/lib/webspicy/tester/result.rb +139 -0
  35. data/lib/webspicy/tester/result/assert_met.rb +29 -0
  36. data/lib/webspicy/tester/result/check.rb +33 -0
  37. data/lib/webspicy/tester/result/errcondition_met.rb +29 -0
  38. data/lib/webspicy/tester/result/error_schema_met.rb +24 -0
  39. data/lib/webspicy/tester/result/output_schema_met.rb +24 -0
  40. data/lib/webspicy/tester/result/postcondition_met.rb +29 -0
  41. data/lib/webspicy/tester/result/response_header_met.rb +43 -0
  42. data/lib/webspicy/tester/result/response_status_met.rb +25 -0
  43. data/lib/webspicy/version.rb +1 -1
  44. data/lib/webspicy/web.rb +4 -0
  45. data/lib/webspicy/web/client.rb +15 -0
  46. data/lib/webspicy/{tester → web}/client/http_client.rb +34 -14
  47. data/lib/webspicy/{tester → web}/client/rack_test_client.rb +3 -3
  48. data/lib/webspicy/{tester → web}/client/support.rb +2 -2
  49. data/lib/webspicy/web/invocation.rb +65 -0
  50. data/lib/webspicy/web/mocker.rb +90 -0
  51. data/lib/webspicy/{mocker → web/mocker}/config.ru +3 -2
  52. data/lib/webspicy/{openapi.rb → web/openapi.rb} +0 -0
  53. data/lib/webspicy/web/openapi/generator.rb +129 -0
  54. data/spec/unit/specification/test_condition.rb +26 -0
  55. data/spec/unit/support/hooks/test_fire_after_each.rb +53 -0
  56. data/spec/unit/{tester/client/test_around.rb → support/hooks/test_fire_around.rb} +15 -10
  57. data/spec/unit/support/hooks/test_fire_before_each.rb +53 -0
  58. data/spec/unit/support/world/fixtures/array.json +8 -0
  59. data/spec/unit/support/world/fixtures/queue.rb +1 -0
  60. data/spec/unit/support/world/fixtures/single.json +11 -0
  61. data/spec/unit/support/world/fixtures/yaml.yml +3 -0
  62. data/spec/unit/support/world/test_world.rb +56 -0
  63. data/spec/unit/test_configuration.rb +49 -0
  64. data/spec/unit/web/mocker/test_mocker.rb +35 -0
  65. data/spec/unit/web/openapi/test_generator.rb +31 -0
  66. metadata +61 -59
  67. data/examples/restful/Gemfile +0 -5
  68. data/examples/restful/Rakefile +0 -25
  69. data/examples/restful/app.rb +0 -180
  70. data/examples/restful/webspicy/config.rb +0 -24
  71. data/examples/restful/webspicy/formaldef/todo/_one/delete.yml +0 -55
  72. data/examples/restful/webspicy/formaldef/todo/_one/get.simpler.yml +0 -46
  73. data/examples/restful/webspicy/formaldef/todo/_one/get.yml +0 -50
  74. data/examples/restful/webspicy/formaldef/todo/_one/patch.yml +0 -66
  75. data/examples/restful/webspicy/formaldef/todo/_one/put.yml +0 -65
  76. data/examples/restful/webspicy/formaldef/todo/get.yml +0 -36
  77. data/examples/restful/webspicy/formaldef/todo/options.yml +0 -32
  78. data/examples/restful/webspicy/formaldef/todo/post.csv.yml +0 -43
  79. data/examples/restful/webspicy/formaldef/todo/post.file.yml +0 -40
  80. data/examples/restful/webspicy/formaldef/todo/post.yml +0 -51
  81. data/examples/restful/webspicy/formaldef/todo/todos.csv +0 -4
  82. data/examples/restful/webspicy/rack.rb +0 -7
  83. data/examples/restful/webspicy/real.rb +0 -8
  84. data/examples/restful/webspicy/schema.fio +0 -20
  85. data/examples/restful/webspicy/support/must_be_an_admin.rb +0 -20
  86. data/examples/restful/webspicy/support/must_be_authenticated.rb +0 -48
  87. data/examples/restful/webspicy/support/todo_not_removed.rb +0 -21
  88. data/examples/restful/webspicy/support/todo_removed.rb +0 -20
  89. data/examples/single_spec/spec.yml +0 -59
  90. data/examples/website/config.rb +0 -2
  91. data/examples/website/schema.fio +0 -1
  92. data/examples/website/specification/get-http.yml +0 -30
  93. data/examples/website/specification/get-https.yml +0 -30
  94. data/lib/webspicy/checker.rb +0 -10
  95. data/lib/webspicy/mocker.rb +0 -88
  96. data/lib/webspicy/openapi/generator.rb +0 -127
  97. data/lib/webspicy/rspec/checker.rb +0 -2
  98. data/lib/webspicy/rspec/checker/rspec_checker.rb +0 -24
  99. data/lib/webspicy/rspec/support/rspec_runnable.rb +0 -27
  100. data/lib/webspicy/rspec/tester.rb +0 -4
  101. data/lib/webspicy/rspec/tester/rspec_asserter.rb +0 -121
  102. data/lib/webspicy/rspec/tester/rspec_matchers.rb +0 -114
  103. data/lib/webspicy/rspec/tester/rspec_tester.rb +0 -63
  104. data/spec/unit/mocker/test_mocker.rb +0 -32
  105. data/spec/unit/openapi/test_generator.rb +0 -28
@@ -1,5 +1,6 @@
1
1
  require "webspicy"
2
- require "webspicy/mocker"
2
+ require "webspicy/web"
3
+ require "webspicy/web/mocker"
3
4
  require 'rack'
4
5
  config = Webspicy::Configuration.dress(Path("/formalspec/"))
5
- run Webspicy::Mocker.new(config)
6
+ run Webspicy::Web::Mocker.new(config)
File without changes
@@ -0,0 +1,129 @@
1
+ require "finitio/generation"
2
+ require "finitio/json_schema"
3
+ module Webspicy
4
+ module Web
5
+ module Openapi
6
+ class Generator
7
+
8
+ def initialize(config)
9
+ @config = Configuration.dress(config)
10
+ @generator = config.generator || Finitio::Generation.new
11
+ end
12
+ attr_reader :config, :generator
13
+
14
+ def call
15
+ {
16
+ openapi: "3.0.2",
17
+ info: {
18
+ version: "1.0.0",
19
+ title: "Hello API"
20
+ },
21
+ paths: paths
22
+ }
23
+ end
24
+
25
+ private
26
+
27
+ def paths
28
+ config.each_scope.inject({}) do |paths,scope|
29
+ scope.each_specification.inject(paths) do |paths,specification|
30
+ paths.merge(path_for(specification)){|k,ps,qs|
31
+ ps.merge(qs)
32
+ }
33
+ end
34
+ end
35
+ end
36
+
37
+ def path_for(specification)
38
+ {
39
+ specification.url => {
40
+ summary: specification.name
41
+ }.merge(verbs_for(specification))
42
+ }
43
+ end
44
+
45
+ def verbs_for(specification)
46
+ specification.services.inject({}) do |verbs,service|
47
+ verb = service.method.downcase
48
+ verb_defn = {
49
+ description: service.description,
50
+ responses: responses_for(service)
51
+ }
52
+ unless ["get", "options", "delete", "head"].include?(verb)
53
+ verb_defn[:requestBody] = request_body_for(service)
54
+ end
55
+ verbs.merge({ verb => verb_defn })
56
+ end
57
+ end
58
+
59
+ def request_body_for(service)
60
+ schema = actual_input_schema(service)
61
+ {
62
+ required: true,
63
+ content: {
64
+ "application/json" => {
65
+ schema: schema.to_json_schema,
66
+ example: generator.call(schema, {})
67
+ }
68
+ }
69
+ }
70
+ end
71
+
72
+ def responses_for(service)
73
+ result = {}
74
+ service.examples.each_with_object(result) do |test_case, rs|
75
+ rs.merge!(response_for(test_case, false)){|k,r1,r2| r1 }
76
+ end
77
+ service.counterexamples.each_with_object(result) do |test_case, rs|
78
+ rs.merge!(response_for(test_case, true)){|k,r1,r2| r1 }
79
+ end
80
+ result
81
+ end
82
+
83
+ def response_for(test_case, counterexample)
84
+ res = {
85
+ description: test_case.description,
86
+ }
87
+ status = (test_case.expected_status && test_case.expected_status.to_int) || 200
88
+ if test_case.expected_content_type && status != 204
89
+ content = {
90
+ schema: schema_for(test_case, counterexample)
91
+ }
92
+ unless counterexample
93
+ content[:example] = example_for(test_case, counterexample)
94
+ end
95
+ res[:content] = {
96
+ test_case.expected_content_type => content
97
+ }
98
+ end
99
+ {
100
+ status => res
101
+ }
102
+ end
103
+
104
+ def schema_for(test_case, counterexample)
105
+ schema = actual_output_schema(test_case, counterexample)
106
+ schema.to_json_schema
107
+ end
108
+
109
+ def example_for(test_case, counterexample)
110
+ schema = actual_output_schema(test_case, counterexample)
111
+ generator.call(schema, {})
112
+ end
113
+
114
+ def actual_output_schema(test_case, counterexample)
115
+ if counterexample
116
+ test_case.service.error_schema['Main']
117
+ else
118
+ test_case.service.output_schema['Main']
119
+ end
120
+ end
121
+
122
+ def actual_input_schema(service)
123
+ service.input_schema['Main']
124
+ end
125
+
126
+ end # class Generator
127
+ end # module Openapi
128
+ end # module Web
129
+ end # module Webspicy
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+ module Webspicy
3
+ class Specification
4
+ describe Condition do
5
+ describe "sooner_or_later" do
6
+ include Condition
7
+
8
+ it 'works when the block returns anything non falsy' do
9
+ x = sooner_or_later(max: 1){ 12 }
10
+ expect(x).to eql(12)
11
+ end
12
+
13
+ it 'returns nil otherwise' do
14
+ x = sooner_or_later(max: 1){ nil }
15
+ expect(x).to eql(nil)
16
+ end
17
+
18
+ it 'can raise for us' do
19
+ expect{
20
+ sooner_or_later(max: 1, raise: true){ nil }
21
+ }.to raise_error(TimeoutError)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ module Webspicy
3
+ module Support
4
+ describe Hooks, "fire_after_each" do
5
+
6
+ class Hooker
7
+ include Hooks
8
+ def initialize(config)
9
+ @config = config
10
+ end
11
+ attr_reader :config
12
+ end
13
+
14
+ it 'work with no after_each at all' do
15
+ config = Configuration.new
16
+ Hooker.new(config).fire_after_each(1, 2, 3)
17
+ end
18
+
19
+ it 'work with one after_each' do
20
+ config = Configuration.new
21
+
22
+ seen_args = nil
23
+ config.after_each do |*args|
24
+ seen_args = args
25
+ end
26
+
27
+ Hooker.new(config).fire_after_each(1, 2, 3)
28
+
29
+ expect(seen_args).to eql([1, 2, 3])
30
+ end
31
+
32
+ it 'works with two after_each' do
33
+ config = Configuration.new
34
+
35
+ seen = false
36
+
37
+ seen_args = []
38
+ config.after_each do |*args|
39
+ seen_args << args
40
+ end
41
+ config.after_each do |*args|
42
+ seen_args << args
43
+ end
44
+
45
+ Hooker.new(config).fire_after_each(1, 2, 3)
46
+
47
+ expect(seen_args.size).to eql(2)
48
+ expect(seen_args.all?{|sa| sa == [1,2,3] }).to be(true)
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -1,7 +1,15 @@
1
1
  require 'spec_helper'
2
2
  module Webspicy
3
- class Tester
4
- describe Client, "around" do
3
+ module Support
4
+ describe Hooks, "fire_around" do
5
+
6
+ class Hooker
7
+ include Hooks
8
+ def initialize(config)
9
+ @config = config
10
+ end
11
+ attr_reader :config
12
+ end
5
13
 
6
14
  it 'work with no around at all' do
7
15
  config = Configuration.new
@@ -9,8 +17,7 @@ module Webspicy
9
17
  seen = false
10
18
  block = ->(){ seen = true }
11
19
 
12
- scope = Configuration::Scope.new(config)
13
- Client.new(scope).around(1, 2, 3, &block)
20
+ Hooker.new(config).fire_around(1, 2, 3, &block)
14
21
  expect(seen).to be(true)
15
22
  end
16
23
 
@@ -24,11 +31,10 @@ module Webspicy
24
31
  bl.call
25
32
  end
26
33
 
27
- scope = Configuration::Scope.new(config)
28
34
  block = ->(){ seen = true }
29
- Client.new(scope).around(1, 2, 3, &block)
35
+ Hooker.new(config).fire_around(1, 2, 3, &block)
30
36
 
31
- expect(seen_args[0...-1]).to eql([1, 2, 3])
37
+ expect(seen_args).to eql([1, 2, 3])
32
38
  expect(seen).to be(true)
33
39
  end
34
40
 
@@ -47,12 +53,11 @@ module Webspicy
47
53
  bl.call
48
54
  end
49
55
 
50
- scope = Configuration::Scope.new(config)
51
56
  block = ->(){ seen = true }
52
- Client.new(scope).around(1, 2, 3, &block)
57
+ Hooker.new(config).fire_around(1, 2, 3, &block)
53
58
 
54
59
  expect(seen_args.size).to eql(2)
55
- expect(seen_args.all?{|sa| sa[0...-1] == [1,2,3] }).to be(true)
60
+ expect(seen_args.all?{|sa| sa == [1,2,3] }).to be(true)
56
61
  expect(seen).to be(true)
57
62
  end
58
63
 
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ module Webspicy
3
+ module Support
4
+ describe Hooks, "fire_before_each" do
5
+
6
+ class Hooker
7
+ include Hooks
8
+ def initialize(config)
9
+ @config = config
10
+ end
11
+ attr_reader :config
12
+ end
13
+
14
+ it 'work with no before_each at all' do
15
+ config = Configuration.new
16
+ Hooker.new(config).fire_before_each(1, 2, 3)
17
+ end
18
+
19
+ it 'work with one before_each' do
20
+ config = Configuration.new
21
+
22
+ seen_args = nil
23
+ config.before_each do |*args|
24
+ seen_args = args
25
+ end
26
+
27
+ Hooker.new(config).fire_before_each(1, 2, 3)
28
+
29
+ expect(seen_args).to eql([1, 2, 3])
30
+ end
31
+
32
+ it 'works with two before_each' do
33
+ config = Configuration.new
34
+
35
+ seen = false
36
+
37
+ seen_args = []
38
+ config.before_each do |*args|
39
+ seen_args << args
40
+ end
41
+ config.before_each do |*args|
42
+ seen_args << args
43
+ end
44
+
45
+ Hooker.new(config).fire_before_each(1, 2, 3)
46
+
47
+ expect(seen_args.size).to eql(2)
48
+ expect(seen_args.all?{|sa| sa == [1,2,3] }).to be(true)
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "name": "foo"
4
+ },
5
+ {
6
+ "name": "bar"
7
+ }
8
+ ]
@@ -0,0 +1 @@
1
+ Webspicy::SpecTests::Queue.new
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": 1,
3
+ "name": "single",
4
+ "version": {
5
+ "major": "1",
6
+ "minor": "0"
7
+ },
8
+ "hobbies": [
9
+ { "name": "programming"}
10
+ ]
11
+ }
@@ -0,0 +1,3 @@
1
+ ---
2
+ id: 3
3
+ name: 'YAML'
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ module Webspicy
4
+ module SpecTests
5
+ class Queue
6
+ include Webspicy::Support::World::Item
7
+
8
+ end
9
+ end
10
+ end
11
+
12
+ module Webspicy
13
+ module Support
14
+ describe World do
15
+
16
+ let(:config){
17
+ Configuration.new(restful_folder)
18
+ }
19
+
20
+ subject do
21
+ World.new Path.dir/"fixtures", config
22
+ end
23
+
24
+ it 'supports single objects' do
25
+ expect(subject.single.name).to eql("single")
26
+ expect(subject.single.version.minor).to eql("0")
27
+ expect(subject.single.hobbies[0].name).to eql("programming")
28
+ end
29
+
30
+ it 'supports yaml too' do
31
+ expect(subject.yaml.name).to eql("YAML")
32
+ end
33
+
34
+ it 'supports arrays' do
35
+ expect(subject.array[0].name).to eql("foo")
36
+ expect(subject.array[1].name).to eql("bar")
37
+ end
38
+
39
+ it 'allows setting new attributes on itself' do
40
+ subject.foo = "bar"
41
+ expect(subject.foo).to eql("bar")
42
+ end
43
+
44
+ it 'allows setting new attributes on existing objects' do
45
+ subject.single.foo = "bar"
46
+ expect(subject.single.foo).to eql("bar")
47
+ end
48
+
49
+ it 'supports ruby files and evaluates them' do
50
+ q = subject.queue
51
+ expect(q).to be_a(Webspicy::SpecTests::Queue)
52
+ expect(q.config).to be(config)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -48,6 +48,11 @@ module Webspicy
48
48
  expect(c.each_scope.to_a.first.each_specification.to_a.size).to eql(1)
49
49
  end
50
50
 
51
+ it 'exposes the world as a World instance' do
52
+ c = Configuration.dress(restful_folder)
53
+ expect(c.world).to be_a(Support::World)
54
+ end
55
+
51
56
  it 'yields the block with the configuration, if given' do
52
57
  seen = nil
53
58
  Configuration.dress(Path.dir/'configuration'){|c|
@@ -106,6 +111,7 @@ module Webspicy
106
111
  ENV['ROBUST'] = 'yes'
107
112
  config = Configuration.new
108
113
  expect(config.run_counterexamples?).to eql(true)
114
+ ENV.delete('ROBUST')
109
115
  end
110
116
 
111
117
  it 'ignores the environment is set explicitly' do
@@ -114,6 +120,7 @@ module Webspicy
114
120
  c.run_counterexamples = false
115
121
  end
116
122
  expect(config.run_counterexamples?).to eql(false)
123
+ ENV.delete('ROBUST')
117
124
  end
118
125
  end
119
126
 
@@ -130,6 +137,7 @@ module Webspicy
130
137
  expect(config.file_filter).to be_a(Regexp)
131
138
  expect(config.file_filter).to match("foo/bar/getTodo.yml")
132
139
  expect(config.file_filter).not_to match("foo/bar/getTodos.yml")
140
+ ENV.delete('RESOURCE')
133
141
  end
134
142
 
135
143
  it 'allows expressing a no match' do
@@ -138,6 +146,7 @@ module Webspicy
138
146
  expect(config.file_filter).to be_a(Proc)
139
147
  expect(config.file_filter.call("foo/bar/getTodos.yml")).to eq(true)
140
148
  expect(config.file_filter.call("foo/bar/getTodo.yml")).to eq(false)
149
+ ENV.delete('RESOURCE')
141
150
  end
142
151
 
143
152
  it 'ignores the environment if set explicitly' do
@@ -146,6 +155,7 @@ module Webspicy
146
155
  c.file_filter = nil
147
156
  end
148
157
  expect(config.file_filter).to be_nil
158
+ ENV.delete('RESOURCE')
149
159
  end
150
160
  end
151
161
 
@@ -160,6 +170,7 @@ module Webspicy
160
170
  ENV['METHOD'] = 'GET'
161
171
  config = Configuration.new
162
172
  expect(config.service_filter).to be_a(Proc)
173
+ ENV.delete('METHOD')
163
174
  end
164
175
 
165
176
  it 'ignores the environment is set explicitly' do
@@ -168,6 +179,36 @@ module Webspicy
168
179
  c.service_filter = nil
169
180
  end
170
181
  expect(config.service_filter).to be_nil
182
+ ENV.delete('METHOD')
183
+ end
184
+ end
185
+
186
+ describe 'insecure' do
187
+
188
+ it 'is false by default' do
189
+ config = Configuration.new
190
+ expect(config.insecure).to eql(false)
191
+ end
192
+
193
+ it 'is true if INSECURE is set to yes' do
194
+ ENV['INSECURE'] = 'yes'
195
+ config = Configuration.new
196
+ expect(config.insecure).to eql(true)
197
+ ENV.delete('INSECURE')
198
+ end
199
+
200
+ it 'is true if INSECURE is set to 1' do
201
+ ENV['INSECURE'] = '1'
202
+ config = Configuration.new
203
+ expect(config.insecure).to eql(true)
204
+ ENV.delete('INSECURE')
205
+ end
206
+
207
+ it 'is false if INSECURE is set to no' do
208
+ ENV['INSECURE'] = 'no'
209
+ config = Configuration.new
210
+ expect(config.insecure).to eql(false)
211
+ ENV.delete('INSECURE')
171
212
  end
172
213
  end
173
214
 
@@ -187,48 +228,56 @@ module Webspicy
187
228
  ENV['TAG'] = 'foo'
188
229
  expect(subject).to be_a(Proc)
189
230
  expect(subject.call(tc)).to eql(true)
231
+ ENV.delete('TAG')
190
232
  end
191
233
 
192
234
  it 'allows no matching a single tag' do
193
235
  ENV['TAG'] = 'baz'
194
236
  expect(subject).to be_a(Proc)
195
237
  expect(subject.call(tc)).to eql(false)
238
+ ENV.delete('TAG')
196
239
  end
197
240
 
198
241
  it 'allows setting multiple tags' do
199
242
  ENV['TAG'] = 'foo,baz'
200
243
  expect(subject).to be_a(Proc)
201
244
  expect(subject.call(tc)).to eql(true)
245
+ ENV.delete('TAG')
202
246
  end
203
247
 
204
248
  it 'allows no matching any of multiple tags' do
205
249
  ENV['TAG'] = 'foi,baz'
206
250
  expect(subject).to be_a(Proc)
207
251
  expect(subject.call(tc)).to eql(false)
252
+ ENV.delete('TAG')
208
253
  end
209
254
 
210
255
  it 'allows setting a single negative tag' do
211
256
  ENV['TAG'] = '!foo'
212
257
  expect(subject).to be_a(Proc)
213
258
  expect(subject.call(tc)).to eql(false)
259
+ ENV.delete('TAG')
214
260
  end
215
261
 
216
262
  it 'allows not matching a single negative tag' do
217
263
  ENV['TAG'] = '!baz'
218
264
  expect(subject).to be_a(Proc)
219
265
  expect(subject.call(tc)).to eql(true)
266
+ ENV.delete('TAG')
220
267
  end
221
268
 
222
269
  it 'allows mixing positive & negative tags and have a match' do
223
270
  ENV['TAG'] = 'foo,!baz'
224
271
  expect(subject).to be_a(Proc)
225
272
  expect(subject.call(tc)).to eql(true)
273
+ ENV.delete('TAG')
226
274
  end
227
275
 
228
276
  it 'allows mixing positive & negative tags and have no match' do
229
277
  ENV['TAG'] = 'foo,!bar'
230
278
  expect(subject).to be_a(Proc)
231
279
  expect(subject.call(tc)).to eql(false)
280
+ ENV.delete('TAG')
232
281
  end
233
282
 
234
283
  end