nginx_test_helper 0.4.1 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58376a9b0561ae60632d2cff41ab8ed8ea812909
4
- data.tar.gz: 42c2d22cf2034178d8ca2fc76d4846585987e659
2
+ SHA256:
3
+ metadata.gz: e31f8e2148e3e7f128f75c8e6d5bd28eeb8900371ff95328f667d7b4ad32badf
4
+ data.tar.gz: 6e76902d9bd656693a7efb1be699afb88282b6c277876a45fce814aaf778ac11
5
5
  SHA512:
6
- metadata.gz: 8bfeff012bb7bc2fdfb1480a081fc20b3fc5573df9dabe32a1249e3bf1f25cef421ff0a6e8d8c6223f6ba1060f838d072ea36d3fc619087eaa7accf5b7d07836
7
- data.tar.gz: 47966a24b31a27bde7b4b551c4e30279c1d4862a31162a0f1806379630bc87ff51d40af8516414fc5fc20422ebd0a3f140e6a34cf785d6844d8d861d654adf18
6
+ metadata.gz: e4ae47cad9159ed43590ffad5760db5c58f141dd7c94e04355462c020b03ac5530f6e01393b3fd0847661241c7c83bc561e2cea0dfe6fa4909d318594c6b7a02
7
+ data.tar.gz: 46753bf5294e3682c1305279cea745b76878861fea197aa38b70dc9e1c8a262d9c2a8ce102b82c1bd8472bfc80f3672feb5e0bf27f8b8260387e3647eddc4008
@@ -1,3 +1,3 @@
1
1
  module NginxTestHelper
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -25,7 +25,7 @@ module NginxTestHelper
25
25
  config = Config.new(config_id, configuration)
26
26
  stderr_msg = start_server(config)
27
27
  stop_server(config)
28
- "#{stderr_msg}\n#{File.read(config.error_log) if File.exists?(config.error_log)}"
28
+ "#{stderr_msg}\n#{File.read(config.error_log) if File.exist?(config.error_log)}"
29
29
  end
30
30
 
31
31
  def open_socket(host, port)
@@ -25,9 +25,9 @@ describe NginxTestHelper::CommandLineTool do
25
25
 
26
26
  it "should create example files showing how to use the gem" do
27
27
  NginxTestHelper::CommandLineTool.new.process ["init"]
28
- expect(File.exists?('tmp/spec/nginx_configuration.rb')).to be true
29
- expect(File.exists?('tmp/spec/example_spec.rb')).to be true
30
- expect(File.exists?('tmp/spec/spec_helper.rb')).to be true
28
+ expect(File.exist?('tmp/spec/nginx_configuration.rb')).to be true
29
+ expect(File.exist?('tmp/spec/example_spec.rb')).to be true
30
+ expect(File.exist?('tmp/spec/spec_helper.rb')).to be true
31
31
 
32
32
  expect(File.read('tmp/spec/nginx_configuration.rb')).to eql(File.read('templates/spec/nginx_configuration.rb'))
33
33
  expect(File.read('tmp/spec/example_spec.rb')).to eql(File.read('templates/spec/example_spec.rb'))
@@ -30,8 +30,8 @@ describe NginxTestHelper::Config do
30
30
 
31
31
  it "should create dirs where logs and client_body_temp will be stored" do
32
32
  NginxTestHelper::Config.new("config_id", {})
33
- expect(File.exists?("/tmp/nginx_tests/logs")).to be true
34
- expect(File.exists?("/tmp/nginx_tests/client_body_temp")).to be true
33
+ expect(File.exist?("/tmp/nginx_tests/logs")).to be true
34
+ expect(File.exist?("/tmp/nginx_tests/client_body_temp")).to be true
35
35
  end
36
36
 
37
37
  it "should create the configuration file using the template configuration" do
@@ -48,10 +48,10 @@ describe NginxTestHelper::Config do
48
48
 
49
49
  it "should has a method to delete config and log files" do
50
50
  NginxTestHelper::Config.delete_config_and_log_files(subject.config_id)
51
- expect(File.exists?(subject.configuration[:configuration_filename])).to be false
52
- expect(File.exists?(subject.configuration[:access_log])).to be false
53
- expect(File.exists?(subject.configuration[:error_log])).to be false
54
- expect(File.exists?(subject.configuration[:client_body_temp])).to be false
51
+ expect(File.exist?(subject.configuration[:configuration_filename])).to be false
52
+ expect(File.exist?(subject.configuration[:access_log])).to be false
53
+ expect(File.exist?(subject.configuration[:error_log])).to be false
54
+ expect(File.exist?(subject.configuration[:client_body_temp])).to be false
55
55
  end
56
56
 
57
57
  it "should expose configurations keys as methods" do
@@ -253,9 +253,21 @@ describe NginxTestHelper do
253
253
 
254
254
  expect(subject.send(:config_id)).to eql("test_config_id_by___name__")
255
255
  end
256
+
257
+ context "for rspec 3.0+" do
258
+ before { |ex| Thread.current[:current_example] = ex }
259
+
260
+ it "should use example metadata if available" do
261
+ allow(Thread.current[:current_example]).to receive(:location).and_return("./spec/test_config_id_spec.rb:101")
262
+ expect(subject.send(:config_id)).to eql("test_config_id_spec_rb_101")
263
+ end
264
+ end
256
265
  end
257
266
 
258
267
  context "and check if the test has passed" do
268
+ before { Thread.current[:current_example] = nil }
269
+ after { |ex| Thread.current[:current_example] = ex }
270
+
259
271
  context "using example exception if available" do
260
272
  it "should be 'true' if exception is 'nil'" do
261
273
  allow(subject.example).to receive(:exception).and_return(nil)
@@ -266,6 +278,20 @@ describe NginxTestHelper do
266
278
  allow(subject.example).to receive(:exception).and_return("")
267
279
  expect(subject.send(:has_passed?)).to be false
268
280
  end
281
+
282
+ context "for rspec 3.0+" do
283
+ before { |ex| Thread.current[:current_example] = ex }
284
+
285
+ it "should be 'true' if exception is 'nil'" do
286
+ allow(Thread.current[:current_example]).to receive(:exception).and_return(nil)
287
+ expect(subject.send(:has_passed?)).to be true
288
+ end
289
+
290
+ it "should be 'false' if exception is not 'nil'" do
291
+ allow(Thread.current[:current_example]).to receive(:exception).and_return("")
292
+ expect(subject.send(:has_passed?)).to be false
293
+ end
294
+ end
269
295
  end
270
296
 
271
297
  context "using 'test_passed' attribute if example exception is not available" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nginx_test_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wandenberg Peixoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2023-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: popen4
@@ -117,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.2.2
120
+ rubygems_version: 3.4.1
122
121
  signing_key:
123
122
  specification_version: 4
124
123
  summary: A collection of helper methods to test your nginx module.