nginx_test_helper 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75c520d4f170c613f24605612e69088fedb3a219
4
- data.tar.gz: a7c16004fb9a1a01a89ff5d331fef4376978c689
3
+ metadata.gz: 78a4974a32a0e57c0f6dcdf50600c34045085665
4
+ data.tar.gz: 012ca812a9689d695f1e39761aee4bd595f74eb3
5
5
  SHA512:
6
- metadata.gz: 706b0d4e95fbfae35443faad3f6916e223e2a8074c2e866fa336689d4c1a7d1231d1d1f3d6662902e8b2d8297c94fc4c2b45f86c57c137ea993ada8f8f89d59f
7
- data.tar.gz: 9a843a5c7cb60820a533db67dc3e226d37039d045e19c7ef4ee88bb97b364ee9a15ad2398c632a7ce925832ca30e66774ff8c5d6a36fac0b8d10bb5c07a2c11d
6
+ metadata.gz: 08f2d07609dea934f5013edfc80bf259402fda0e67170913b4b4a73a7ec7cecaf17b8fc333f2083b43562f15156b86e7ed96af7f52e2316122f2d2956780db10
7
+ data.tar.gz: 5d61fcb9ce455966da624bcb0833a4bd99c5febffe54b25d5a66a08e634528eecf1b6f3865f8d60ec5db08d28e367cbd6273d79aedba62b08f874e9350096966
@@ -10,6 +10,7 @@ if defined?(RSpec)
10
10
  end
11
11
 
12
12
  config.around(:each) do |ex|
13
+ Thread.current[:current_example] = ex
13
14
  logs = Dir[File.join(NginxTestHelper.nginx_tests_tmp_dir, "logs", "**")]
14
15
  error_log_pre = logs.map{|log| File.readlines(log)}.flatten
15
16
 
@@ -29,12 +30,22 @@ if defined?(RSpec)
29
30
  (actual >= min) && (actual <= max)
30
31
  end
31
32
 
32
- failure_message_for_should do |actual|
33
- "expected that #{actual} would be in the interval from #{min} to #{max}"
34
- end
33
+ if RSpec::Core::Version::STRING < "3.0.0"
34
+ failure_message_for_should do |actual|
35
+ "expected that #{actual} would be in the interval from #{min} to #{max}"
36
+ end
37
+
38
+ failure_message_for_should_not do |actual|
39
+ "expected that #{actual} would not be in the interval from #{min} to #{max}"
40
+ end
41
+ else
42
+ failure_message do |actual|
43
+ "expected that #{actual} would be in the interval from #{min} to #{max}"
44
+ end
35
45
 
36
- failure_message_for_should_not do |actual|
37
- "expected that #{actual} would not be in the interval from #{min} to #{max}"
46
+ failure_message_when_negated do |actual|
47
+ "expected that #{actual} would not be in the interval from #{min} to #{max}"
48
+ end
38
49
  end
39
50
 
40
51
  description do
@@ -47,12 +58,22 @@ if defined?(RSpec)
47
58
  actual.match(pattern)
48
59
  end
49
60
 
50
- failure_message_for_should do |actual|
51
- "expected that '#{actual}' would match the pattern '#{pattern.inspect}'"
52
- end
61
+ if RSpec::Core::Version::STRING < "3.0.0"
62
+ failure_message_for_should do |actual|
63
+ "expected that '#{actual}' would match the pattern '#{pattern.inspect}'"
64
+ end
65
+
66
+ failure_message_for_should_not do |actual|
67
+ "expected that '#{actual}' would not match the pattern '#{pattern.inspect}'"
68
+ end
69
+ else
70
+ failure_message do |actual|
71
+ "expected that '#{actual}' would match the pattern '#{pattern.inspect}'"
72
+ end
53
73
 
54
- failure_message_for_should_not do |actual|
55
- "expected that '#{actual}' would not match the pattern '#{pattern.inspect}'"
74
+ failure_message_when_negated do |actual|
75
+ "expected that '#{actual}' would not match the pattern '#{pattern.inspect}'"
76
+ end
56
77
  end
57
78
 
58
79
  description do
@@ -1,3 +1,3 @@
1
1
  module NginxTestHelper
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -106,7 +106,9 @@ module NginxTestHelper
106
106
 
107
107
  private
108
108
  def config_id
109
- if self.respond_to?(:example) && !self.example.nil? &&
109
+ if !Thread.current[:current_example].nil? && Thread.current[:current_example].respond_to?(:location)
110
+ (Thread.current[:current_example].location.split('/') - [".", "spec"]).join('_').gsub(/[\.\:]/, '_')
111
+ elsif self.respond_to?(:example) && !self.example.nil? &&
110
112
  self.example.respond_to?(:metadata) && !self.example.metadata.nil? &&
111
113
  !self.example.metadata[:location].nil?
112
114
  (self.example.metadata[:location].split('/') - [".", "spec"]).join('_').gsub(/[\.\:]/, '_')
@@ -118,7 +120,9 @@ private
118
120
  end
119
121
 
120
122
  def has_passed?
121
- if self.respond_to?(:example) && !self.example.nil? && self.example.respond_to?(:exception)
123
+ if !Thread.current[:current_example].nil? && Thread.current[:current_example].respond_to?(:exception)
124
+ Thread.current[:current_example].exception.nil?
125
+ elsif self.respond_to?(:example) && !self.example.nil? && self.example.respond_to?(:exception)
122
126
  self.example.exception.nil?
123
127
  elsif !@test_passed.nil?
124
128
  @test_passed
@@ -18,6 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.add_dependency "popen4"
19
19
 
20
20
  gem.add_development_dependency(%q<rspec>, [">= 2.10.0"])
21
- gem.add_development_dependency(%q<debugger>, [">= 1.1.3"])
21
+ gem.add_development_dependency(%q<byebug>, [">= 3.5.1"])
22
22
  gem.add_development_dependency(%q<simplecov>, [">= 0.0.1"]) if RUBY_VERSION > "1.9.0"
23
23
  end
@@ -3,8 +3,8 @@ require 'nginx_test_helper/command_line_tool'
3
3
 
4
4
  describe NginxTestHelper::CommandLineTool do
5
5
  before do
6
- $stdout.stub(:puts)
7
- Dir.stub(:pwd).and_return('tmp')
6
+ allow($stdout).to receive(:puts)
7
+ allow(Dir).to receive(:pwd).and_return('tmp')
8
8
  FileUtils.mkdir_p('tmp/spec')
9
9
  end
10
10
 
@@ -13,36 +13,36 @@ describe NginxTestHelper::CommandLineTool do
13
13
  end
14
14
 
15
15
  it "should list available options" do
16
- $stdout.should_receive(:puts).with(/init/)
17
- $stdout.should_receive(:puts).with(/license/)
16
+ expect($stdout).to receive(:puts).with(/init/)
17
+ expect($stdout).to receive(:puts).with(/license/)
18
18
  NginxTestHelper::CommandLineTool.new.process []
19
19
  end
20
20
 
21
21
  it "should list the gem license" do
22
- $stdout.should_receive(:puts).with(/MIT License/)
22
+ expect($stdout).to receive(:puts).with(/MIT License/)
23
23
  NginxTestHelper::CommandLineTool.new.process ["license"]
24
24
  end
25
25
 
26
26
  it "should create example files showing how to use the gem" do
27
27
  NginxTestHelper::CommandLineTool.new.process ["init"]
28
- File.exists?('tmp/spec/nginx_configuration.rb').should be_true
29
- File.exists?('tmp/spec/example_spec.rb').should be_true
30
- File.exists?('tmp/spec/spec_helper.rb').should be_true
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
31
31
 
32
- File.read('tmp/spec/nginx_configuration.rb').should eql(File.read('templates/spec/nginx_configuration.rb'))
33
- File.read('tmp/spec/example_spec.rb').should eql(File.read('templates/spec/example_spec.rb'))
34
- File.read('tmp/spec/spec_helper.rb').should include('nginx_configuration')
32
+ expect(File.read('tmp/spec/nginx_configuration.rb')).to eql(File.read('templates/spec/nginx_configuration.rb'))
33
+ expect(File.read('tmp/spec/example_spec.rb')).to eql(File.read('templates/spec/example_spec.rb'))
34
+ expect(File.read('tmp/spec/spec_helper.rb')).to include('nginx_configuration')
35
35
  end
36
36
 
37
37
  it "should include require call on spec_helper if NgincConfiguration is not defined" do
38
- Object.stub(:const_defined?).with('NginxConfiguration').and_return(false)
38
+ allow(Object).to receive(:const_defined?).with('NginxConfiguration').and_return(false)
39
39
  File.open('tmp/spec/spec_helper.rb', 'w') { |f| f.write("#spec_helper content") }
40
40
  NginxTestHelper::CommandLineTool.new.process ["init"]
41
- File.read('tmp/spec/spec_helper.rb').should eql("#spec_helper content\nrequire File.expand_path('nginx_configuration', File.dirname(__FILE__))")
41
+ expect(File.read('tmp/spec/spec_helper.rb')).to eql("#spec_helper content\nrequire File.expand_path('nginx_configuration', File.dirname(__FILE__))")
42
42
  end
43
43
 
44
44
  it "should print INSTALL file content" do
45
- $stdout.should_receive(:puts).with(/Nginx Test Helper has been installed with example specs./)
45
+ expect($stdout).to receive(:puts).with(/Nginx Test Helper has been installed with example specs./)
46
46
  NginxTestHelper::CommandLineTool.new.process ["init"]
47
47
  end
48
48
  end
@@ -6,58 +6,58 @@ describe NginxTestHelper::Config do
6
6
  let(:subject) { NginxTestHelper::Config.new("config_id", configuration) }
7
7
 
8
8
  it "should include NginxTestHelper module" do
9
- subject.class.included_modules.should include(NginxTestHelper::EnvMethods)
9
+ expect(subject.class.included_modules).to include(NginxTestHelper::EnvMethods)
10
10
  end
11
11
 
12
12
  it "should define some keys with configuration filename, logs and temp dirs configurations" do
13
13
  default_configuration = NginxTestHelper::Config.new("config_id", {}).configuration
14
- default_configuration[:configuration_filename].should eql("/tmp/nginx_tests/config_id.conf")
15
- default_configuration[:pid_file].should eql("/tmp/nginx_tests/nginx.pid")
16
- default_configuration[:access_log].should eql("/tmp/nginx_tests/logs/access-config_id.log")
17
- default_configuration[:error_log].should eql("/tmp/nginx_tests/logs/error-config_id.log")
18
- default_configuration[:client_body_temp].should eql("/tmp/nginx_tests/client_body_temp")
14
+ expect(default_configuration[:configuration_filename]).to eql("/tmp/nginx_tests/config_id.conf")
15
+ expect(default_configuration[:pid_file]).to eql("/tmp/nginx_tests/nginx.pid")
16
+ expect(default_configuration[:access_log]).to eql("/tmp/nginx_tests/logs/access-config_id.log")
17
+ expect(default_configuration[:error_log]).to eql("/tmp/nginx_tests/logs/error-config_id.log")
18
+ expect(default_configuration[:client_body_temp]).to eql("/tmp/nginx_tests/client_body_temp")
19
19
  end
20
20
 
21
21
  it "should merge 'default configuration' with configuration filename, logs and temp dirs configurations" do
22
22
  default_configuration = NginxTestHelper::Config.new("config_id", {}).configuration
23
- default_configuration.keys.should eql([:conf_item, :configuration_filename, :pid_file, :access_log, :error_log, :client_body_temp])
23
+ expect(default_configuration.keys).to eql([:conf_item, :configuration_filename, :pid_file, :access_log, :error_log, :client_body_temp])
24
24
  end
25
25
 
26
26
  it "should merge given configuration with 'default configuration', configuration filename, logs and temp dirs configurations" do
27
27
  default_configuration = NginxTestHelper::Config.new("config_id", {:custom_key => "value"}).configuration
28
- default_configuration.keys.should eql([:conf_item, :custom_key, :configuration_filename, :pid_file, :access_log, :error_log, :client_body_temp])
28
+ expect(default_configuration.keys).to eql([:conf_item, :custom_key, :configuration_filename, :pid_file, :access_log, :error_log, :client_body_temp])
29
29
  end
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
- File.exists?("/tmp/nginx_tests/logs").should be_true
34
- File.exists?("/tmp/nginx_tests/client_body_temp").should be_true
33
+ expect(File.exists?("/tmp/nginx_tests/logs")).to be true
34
+ expect(File.exists?("/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
38
- File.read(subject.configuration[:configuration_filename]).should eql('"template configuration config_id"')
38
+ expect(File.read(subject.configuration[:configuration_filename])).to eql('"template configuration config_id"')
39
39
  end
40
40
 
41
41
  context "when using an alternative template" do
42
42
  let(:configuration) { {:foo => "bar", :configuration_template => %("custom template writing <%=configuration[:foo]%>")} }
43
43
 
44
44
  it "should create the configuration file using this template" do
45
- File.read(subject.configuration[:configuration_filename]).should eql('"custom template writing bar"')
45
+ expect(File.read(subject.configuration[:configuration_filename])).to eql('"custom template writing bar"')
46
46
  end
47
47
  end
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
- File.exists?(subject.configuration[:configuration_filename]).should be_false
52
- File.exists?(subject.configuration[:access_log]).should be_false
53
- File.exists?(subject.configuration[:error_log]).should be_false
54
- File.exists?(subject.configuration[:client_body_temp]).should be_false
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
55
55
  end
56
56
 
57
57
  it "should expose configurations keys as methods" do
58
58
  config = NginxTestHelper::Config.new("config_id", { :foo => "bar", :xyz => 1})
59
- config.foo.should eql("bar")
60
- config.xyz.should eql(1)
59
+ expect(config.foo).to eql("bar")
60
+ expect(config.xyz).to eql(1)
61
61
  end
62
62
 
63
63
  it "should raise exception if configuration key does not exists" do
@@ -67,8 +67,8 @@ describe NginxTestHelper::Config do
67
67
 
68
68
  it "should return 'true' to respond_to method for a configuration key" do
69
69
  config = NginxTestHelper::Config.new("config_id", { :foo => "bar"})
70
- config.should respond_to("config_id")
71
- config.should respond_to(:foo)
70
+ expect(config).to respond_to("config_id")
71
+ expect(config).to respond_to(:foo)
72
72
  end
73
73
 
74
74
  context "when using the write_directive helper method" do
@@ -76,14 +76,14 @@ describe NginxTestHelper::Config do
76
76
 
77
77
  it "should comment the line when value is nil" do
78
78
  conf = File.read(subject.configuration[:configuration_filename])
79
- conf.should include(%(\n#comment xyz\n#xyz "";))
80
- conf.should include(%(\n#xyz_without_comment "";))
79
+ expect(conf).to include(%(\n#comment xyz\n#xyz "";))
80
+ expect(conf).to include(%(\n#xyz_without_comment "";))
81
81
  end
82
82
 
83
83
  it "should write the line when value is not nil" do
84
84
  conf = File.read(subject.configuration[:configuration_filename])
85
- conf.should include(%(\n#comment foo\nname "bar";))
86
- conf.should include(%(\nwithout_comment "bar";))
85
+ expect(conf).to include(%(\n#comment foo\nname "bar";))
86
+ expect(conf).to include(%(\nwithout_comment "bar";))
87
87
  end
88
88
 
89
89
  context "when value is an Array" do
@@ -91,8 +91,8 @@ describe NginxTestHelper::Config do
91
91
 
92
92
  it "should write multiple itens without quotes" do
93
93
  conf = File.read(subject.configuration[:configuration_filename])
94
- conf.should include(%(\n#comment foo\nname bar zzz;))
95
- conf.should include(%(\nwithout_comment bar zzz;))
94
+ expect(conf).to include(%(\n#comment foo\nname bar zzz;))
95
+ expect(conf).to include(%(\nwithout_comment bar zzz;))
96
96
  end
97
97
  end
98
98
  end
@@ -8,82 +8,82 @@ describe NginxTestHelper::EnvMethods do
8
8
  shared_examples_for "has nginx configuration methods" do
9
9
  context "with default values" do
10
10
  it "should return nginx executable" do
11
- subject.nginx_executable.should eql("/usr/local/nginx/sbin/nginx")
11
+ expect(subject.nginx_executable).to eql("/usr/local/nginx/sbin/nginx")
12
12
  end
13
13
 
14
14
  it "should return nginx host" do
15
- subject.nginx_host.should eql("127.0.0.1")
15
+ expect(subject.nginx_host).to eql("127.0.0.1")
16
16
  end
17
17
 
18
18
  it "should return nginx port" do
19
- subject.nginx_port.should eql("9990")
19
+ expect(subject.nginx_port).to eql("9990")
20
20
  end
21
21
 
22
22
  it "should return nginx workers" do
23
- subject.nginx_workers.should eql("1")
23
+ expect(subject.nginx_workers).to eql("1")
24
24
  end
25
25
 
26
26
  it "should return nginx tests tmp dir" do
27
- subject.nginx_tests_tmp_dir.should eql("/tmp/nginx_tests")
27
+ expect(subject.nginx_tests_tmp_dir).to eql("/tmp/nginx_tests")
28
28
  end
29
29
 
30
30
  it "should return nginx tests cores dir based on tmp dir" do
31
- subject.nginx_tests_cores_dir.should eql("/tmp/nginx_tests/cores")
31
+ expect(subject.nginx_tests_cores_dir).to eql("/tmp/nginx_tests/cores")
32
32
  end
33
33
 
34
34
  it "should return nginx tests core dir based on tmp dir" do
35
- subject.nginx_tests_core_dir("test_id").should eql("/tmp/nginx_tests/cores/test_id")
35
+ expect(subject.nginx_tests_core_dir("test_id")).to eql("/tmp/nginx_tests/cores/test_id")
36
36
  end
37
37
  end
38
38
 
39
39
  context "with environment values" do
40
40
  it "should return nginx executable" do
41
41
  ENV['NGINX_EXEC'] = "/path/to/nginx/executable"
42
- subject.nginx_executable.should eql("/path/to/nginx/executable")
42
+ expect(subject.nginx_executable).to eql("/path/to/nginx/executable")
43
43
  end
44
44
 
45
45
  it "should return nginx host" do
46
46
  ENV['NGINX_HOST'] = "some_host"
47
- subject.nginx_host.should eql("some_host")
47
+ expect(subject.nginx_host).to eql("some_host")
48
48
  end
49
49
 
50
50
  it "should return nginx port" do
51
51
  ENV['NGINX_PORT'] = "some_port"
52
- subject.nginx_port.should eql("some_port")
52
+ expect(subject.nginx_port).to eql("some_port")
53
53
  end
54
54
 
55
55
  it "should return nginx workers" do
56
56
  ENV['NGINX_WORKERS'] = "25"
57
- subject.nginx_workers.should eql("25")
57
+ expect(subject.nginx_workers).to eql("25")
58
58
  end
59
59
 
60
60
  it "should return nginx tests tmp dir" do
61
61
  ENV['NGINX_TESTS_TMP_DIR'] = "/path/to/tests/tmp/dir"
62
- subject.nginx_tests_tmp_dir.should eql("/path/to/tests/tmp/dir")
62
+ expect(subject.nginx_tests_tmp_dir).to eql("/path/to/tests/tmp/dir")
63
63
  end
64
64
 
65
65
  it "should return nginx tests cores dir based on tmp dir" do
66
66
  ENV['NGINX_TESTS_TMP_DIR'] = "/path/to/tests/tmp/dir"
67
- subject.nginx_tests_cores_dir.should eql("/path/to/tests/tmp/dir/cores")
67
+ expect(subject.nginx_tests_cores_dir).to eql("/path/to/tests/tmp/dir/cores")
68
68
  end
69
69
 
70
70
  it "should return nginx tests core dir based on tmp dir" do
71
71
  ENV['NGINX_TESTS_TMP_DIR'] = "/path/to/tests/tmp/dir"
72
- subject.nginx_tests_core_dir("test_id").should eql("/path/to/tests/tmp/dir/cores/test_id")
72
+ expect(subject.nginx_tests_core_dir("test_id")).to eql("/path/to/tests/tmp/dir/cores/test_id")
73
73
  end
74
74
  end
75
75
 
76
76
  it "should use nginx host and port to compose nginx address" do
77
- subject.stub(:nginx_host).and_return("some_host")
78
- subject.stub(:nginx_port).and_return("some_port")
77
+ allow(subject).to receive(:nginx_host).and_return("some_host")
78
+ allow(subject).to receive(:nginx_port).and_return("some_port")
79
79
 
80
- subject.nginx_address.should eql("http://some_host:some_port")
80
+ expect(subject.nginx_address).to eql("http://some_host:some_port")
81
81
  end
82
82
 
83
83
  context "when on a Darwin ruby platform" do
84
84
  it "should return kqueue as event type" do
85
85
  with_constants({"RUBY_PLATFORM" => "x86_64-darwin13.0"}) do
86
- subject.nginx_event_type.should eql("kqueue")
86
+ expect(subject.nginx_event_type).to eql("kqueue")
87
87
  end
88
88
  end
89
89
  end
@@ -91,7 +91,7 @@ describe NginxTestHelper::EnvMethods do
91
91
  context "when not on a Darwin ruby platform" do
92
92
  it "should return epoll as event type" do
93
93
  with_constants({"RUBY_PLATFORM" => "Any other platform"}) do
94
- subject.nginx_event_type.should eql("epoll")
94
+ expect(subject.nginx_event_type).to eql("epoll")
95
95
  end
96
96
  end
97
97
  end
@@ -4,92 +4,92 @@ require 'nginx_test_helper/rspec_utils'
4
4
  describe "rspec_utils" do
5
5
 
6
6
  it "should include NginxTestHelper module on RSpec tests" do
7
- self.class.included_modules.should include(NginxTestHelper)
7
+ expect(self.class.included_modules).to include(NginxTestHelper)
8
8
  end
9
9
 
10
10
  context "when defining the 'be_in_the_interval' matcher" do
11
11
  context "and checking if the number is in the interval" do
12
12
  it "should be true when the actual value is equal to lower bound" do
13
- expect { 10.should be_in_the_interval(10,12) }.to_not raise_error
13
+ expect { expect(10).to be_in_the_interval(10,12) }.to_not raise_error
14
14
  end
15
15
 
16
16
  it "should be true when the actual value is equal to upper bound" do
17
- expect { 12.should be_in_the_interval(10,12) }.to_not raise_error
17
+ expect { expect(12).to be_in_the_interval(10,12) }.to_not raise_error
18
18
  end
19
19
 
20
20
  it "should be true when the actual value is between lower and upper bounds" do
21
- expect { 11.should be_in_the_interval(10,12) }.to_not raise_error
21
+ expect { expect(11).to be_in_the_interval(10,12) }.to_not raise_error
22
22
  end
23
23
 
24
24
  it "should be false when the actual value is smaller than lower bound" do
25
- expect { 9.should be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 9 would be in the interval from 10 to 12")
25
+ expect { expect(9).to be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 9 would be in the interval from 10 to 12")
26
26
  end
27
27
 
28
28
  it "should be false when the actual value is greater than upper bound" do
29
- expect { 13.should be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 13 would be in the interval from 10 to 12")
29
+ expect { expect(13).to be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 13 would be in the interval from 10 to 12")
30
30
  end
31
31
 
32
32
  it "should accept float numbers" do
33
- expect { 10.4.should be_in_the_interval(10.3,12.5) }.to_not raise_error
34
- expect { 12.4.should be_in_the_interval(10.3,12.5) }.to_not raise_error
33
+ expect { expect(10.4).to be_in_the_interval(10.3,12.5) }.to_not raise_error
34
+ expect { expect(12.4).to be_in_the_interval(10.3,12.5) }.to_not raise_error
35
35
  end
36
36
  end
37
37
 
38
38
  context "and checking if the number is out the interval" do
39
39
  it "should be false when the actual value is equal to lower bound" do
40
- expect { 10.should_not be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 10 would not be in the interval from 10 to 12")
40
+ expect { expect(10).not_to be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 10 would not be in the interval from 10 to 12")
41
41
  end
42
42
 
43
43
  it "should be false when the actual value is equal to upper bound" do
44
- expect { 12.should_not be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 12 would not be in the interval from 10 to 12")
44
+ expect { expect(12).not_to be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 12 would not be in the interval from 10 to 12")
45
45
  end
46
46
 
47
47
  it "should be false when the actual value is between lower and upper bounds" do
48
- expect { 11.should_not be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 11 would not be in the interval from 10 to 12")
48
+ expect { expect(11).not_to be_in_the_interval(10,12) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 11 would not be in the interval from 10 to 12")
49
49
  end
50
50
 
51
51
  it "should be true when the actual value is smaller than lower bound" do
52
- expect { 9.should_not be_in_the_interval(10,12) }.to_not raise_error
52
+ expect { expect(9).not_to be_in_the_interval(10,12) }.to_not raise_error
53
53
  end
54
54
 
55
55
  it "should be true when the actual value is greater than upper bound" do
56
- expect { 13.should_not be_in_the_interval(10,12) }.to_not raise_error
56
+ expect { expect(13).not_to be_in_the_interval(10,12) }.to_not raise_error
57
57
  end
58
58
 
59
59
  it "should accept float numbers" do
60
- expect { 10.2.should_not be_in_the_interval(10.3,12.5) }.to_not raise_error
61
- expect { 12.6.should_not be_in_the_interval(10.3,12.5) }.to_not raise_error
60
+ expect { expect(10.2).not_to be_in_the_interval(10.3,12.5) }.to_not raise_error
61
+ expect { expect(12.6).not_to be_in_the_interval(10.3,12.5) }.to_not raise_error
62
62
  end
63
63
  end
64
64
 
65
65
  it "should has a friendly description" do
66
- be_in_the_interval(10.3,12.5).description.should eql("be in the interval from 10.3 to 12.5")
66
+ expect(be_in_the_interval(10.3,12.5).description).to eql("be in the interval from 10.3 to 12.5")
67
67
  end
68
68
  end
69
69
 
70
70
  context "when defining the 'match_the_pattern' matcher" do
71
71
  context "and checking if the text match the pattern" do
72
72
  it "should be true when the actual value match the expression" do
73
- expect { "some text".should match_the_pattern(/EX/i) }.to_not raise_error
73
+ expect { expect("some text").to match_the_pattern(/EX/i) }.to_not raise_error
74
74
  end
75
75
 
76
76
  it "should be false when the actual value does not match the expression" do
77
- expect { "some text".should match_the_pattern(/EX/) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 'some text' would match the pattern '/EX/'")
77
+ expect { expect("some text").to match_the_pattern(/EX/) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 'some text' would match the pattern '/EX/'")
78
78
  end
79
79
  end
80
80
 
81
81
  context "and checking if the text not match the pattern" do
82
82
  it "should be true when the actual value match the expression" do
83
- expect { "some text".should_not match_the_pattern(/EX/i) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 'some text' would not match the pattern '/EX/i'")
83
+ expect { expect("some text").not_to match_the_pattern(/EX/i) }.to raise_error(RSpec::Expectations::ExpectationNotMetError, "expected that 'some text' would not match the pattern '/EX/i'")
84
84
  end
85
85
 
86
86
  it "should be false when the actual value does not match the expression" do
87
- expect { "some text".should_not match_the_pattern(/EX/) }.to_not raise_error
87
+ expect { expect("some text").not_to match_the_pattern(/EX/) }.to_not raise_error
88
88
  end
89
89
  end
90
90
 
91
91
  it "should has a friendly description" do
92
- match_the_pattern(/EX/i).description.should eql("match the pattern '/EX/i'")
92
+ expect(match_the_pattern(/EX/i).description).to eql("match the pattern '/EX/i'")
93
93
  end
94
94
  end
95
95
  end
@@ -6,92 +6,92 @@ describe NginxTestHelper do
6
6
  subject { Object.new.extend(NginxTestHelper) }
7
7
 
8
8
  it "should define a method with basic headers" do
9
- subject.headers.should eql({'accept' => 'text/html'})
9
+ expect(subject.headers).to eql({'accept' => 'text/html'})
10
10
  end
11
11
 
12
12
  it "should define a method to calculate the difference in seconds of two dates" do
13
- subject.time_diff_sec(Time.now, Time.now + 10).should eql(10)
13
+ expect(subject.time_diff_sec(Time.now, Time.now + 10)).to eql(10)
14
14
  end
15
15
 
16
16
  it "should define a method to calculate the difference in milliseconds of two dates" do
17
- subject.time_diff_milli(Time.now, Time.now + 10).should eql(10000)
17
+ expect(subject.time_diff_milli(Time.now, Time.now + 10)).to eql(10000)
18
18
  end
19
19
 
20
20
  context "when working with sockets" do
21
21
  let(:socket) { SocketMock.new }
22
22
 
23
23
  it "should be possible to open a socket to a host and port" do
24
- TCPSocket.should_receive(:open).with("xpto.com", 100).and_return(socket)
24
+ expect(TCPSocket).to receive(:open).with("xpto.com", 100).and_return(socket)
25
25
 
26
- subject.open_socket("xpto.com", 100).should eql(socket)
26
+ expect(subject.open_socket("xpto.com", 100)).to eql(socket)
27
27
  end
28
28
 
29
29
  it "should be possible to do a GET in an url using the opened socket, and receive header and body response" do
30
- socket.should_receive(:print).with("GET /index.html HTTP/1.1\r\nHost: localhost\r\n\r\n")
30
+ expect(socket).to receive(:print).with("GET /index.html HTTP/1.1\r\nHost: localhost\r\n\r\n")
31
31
 
32
32
  headers, body = subject.get_in_socket("/index.html", socket)
33
- headers.should eql("HTTP 200 OK")
34
- body.should eql("BODY")
33
+ expect(headers).to eql("HTTP 200 OK")
34
+ expect(body).to eql("BODY")
35
35
  end
36
36
 
37
37
  it "should be possible specify the host header value to do a GET" do
38
- socket.should_receive(:print).with("GET /index.html HTTP/1.1\r\nHost: some_host_value\r\n\r\n")
38
+ expect(socket).to receive(:print).with("GET /index.html HTTP/1.1\r\nHost: some_host_value\r\n\r\n")
39
39
 
40
40
  headers, body = subject.get_in_socket("/index.html", socket, {:host_header => "some_host_value"})
41
- headers.should eql("HTTP 200 OK")
42
- body.should eql("BODY")
41
+ expect(headers).to eql("HTTP 200 OK")
42
+ expect(body).to eql("BODY")
43
43
  end
44
44
 
45
45
  it "should be possible use http 1.0 to do a GET" do
46
- socket.should_receive(:print).with("GET /index.html HTTP/1.0\r\n\r\n")
46
+ expect(socket).to receive(:print).with("GET /index.html HTTP/1.0\r\n\r\n")
47
47
 
48
48
  headers, body = subject.get_in_socket("/index.html", socket, {:use_http_1_0 => true})
49
- headers.should eql("HTTP 200 OK")
50
- body.should eql("BODY")
49
+ expect(headers).to eql("HTTP 200 OK")
50
+ expect(body).to eql("BODY")
51
51
  end
52
52
 
53
53
  it "should pass 'wait_for' attribute to 'read_response_on_socket' method when doing a GET in a url" do
54
- socket.should_receive(:print).with("GET /index.html HTTP/1.1\r\nHost: localhost\r\n\r\n")
55
- subject.should_receive(:read_response_on_socket).with(socket, "wait for")
54
+ expect(socket).to receive(:print).with("GET /index.html HTTP/1.1\r\nHost: localhost\r\n\r\n")
55
+ expect(subject).to receive(:read_response_on_socket).with(socket, "wait for")
56
56
 
57
57
  subject.get_in_socket("/index.html", socket, {:wait_for => "wait for"})
58
58
  end
59
59
 
60
60
  it "should be possible to do a POST in an url using the opened socket, and receive header and body response" do
61
- socket.should_receive(:print).with("POST /service HTTP/1.1\r\nHost: localhost\r\nContent-Length: 4\r\n\r\nBODY")
61
+ expect(socket).to receive(:print).with("POST /service HTTP/1.1\r\nHost: localhost\r\nContent-Length: 4\r\n\r\nBODY")
62
62
 
63
63
  headers, body = subject.post_in_socket("/service", "BODY", socket)
64
- headers.should eql("HTTP 200 OK")
65
- body.should eql("BODY")
64
+ expect(headers).to eql("HTTP 200 OK")
65
+ expect(body).to eql("BODY")
66
66
  end
67
67
 
68
68
  it "should be possible specify the host header value to do a POST" do
69
- socket.should_receive(:print).with("POST /service HTTP/1.1\r\nHost: some_host_value\r\nContent-Length: 4\r\n\r\nBODY")
69
+ expect(socket).to receive(:print).with("POST /service HTTP/1.1\r\nHost: some_host_value\r\nContent-Length: 4\r\n\r\nBODY")
70
70
 
71
71
  headers, body = subject.post_in_socket("/service", "BODY", socket, {:host_header => "some_host_value"})
72
- headers.should eql("HTTP 200 OK")
73
- body.should eql("BODY")
72
+ expect(headers).to eql("HTTP 200 OK")
73
+ expect(body).to eql("BODY")
74
74
  end
75
75
 
76
76
  it "should be possible use http 1.0 to do a POST" do
77
- socket.should_receive(:print).with("POST /service HTTP/1.0\r\nContent-Length: 4\r\n\r\nBODY")
77
+ expect(socket).to receive(:print).with("POST /service HTTP/1.0\r\nContent-Length: 4\r\n\r\nBODY")
78
78
 
79
79
  headers, body = subject.post_in_socket("/service", "BODY", socket, {:use_http_1_0 => true})
80
- headers.should eql("HTTP 200 OK")
81
- body.should eql("BODY")
80
+ expect(headers).to eql("HTTP 200 OK")
81
+ expect(body).to eql("BODY")
82
82
  end
83
83
 
84
84
  it "should pass 'wait_for' attribute to 'read_response_on_socket' method when doing a POST in a url" do
85
- socket.should_receive(:print).with("POST /service HTTP/1.1\r\nHost: localhost\r\nContent-Length: 4\r\n\r\nBODY")
86
- subject.should_receive(:read_response_on_socket).with(socket, "wait for")
85
+ expect(socket).to receive(:print).with("POST /service HTTP/1.1\r\nHost: localhost\r\nContent-Length: 4\r\n\r\nBODY")
86
+ expect(subject).to receive(:read_response_on_socket).with(socket, "wait for")
87
87
 
88
88
  headers, body = subject.post_in_socket("/service", "BODY", socket, {:wait_for => "wait for"})
89
89
  end
90
90
 
91
91
  it "should be possible read a response in a opened socket" do
92
92
  headers, body = subject.read_response_on_socket(socket)
93
- headers.should eql("HTTP 200 OK")
94
- body.should eql("BODY")
93
+ expect(headers).to eql("HTTP 200 OK")
94
+ expect(body).to eql("BODY")
95
95
  end
96
96
 
97
97
  it "should concatenate response parts" do
@@ -99,12 +99,12 @@ describe NginxTestHelper do
99
99
  socket.response2 = "Y"
100
100
 
101
101
  headers, body = subject.read_response_on_socket(socket)
102
- headers.should eql("HTTP 200 OK")
103
- body.should eql("BODYXY")
102
+ expect(headers).to eql("HTTP 200 OK")
103
+ expect(body).to eql("BODYXY")
104
104
  end
105
105
 
106
106
  it "should raise error if not receive a response" do
107
- socket.stub(:readpartial).and_raise(Exception)
107
+ allow(socket).to receive(:readpartial).and_raise(Exception)
108
108
 
109
109
  expect { subject.read_response_on_socket(socket) }.to raise_error("Any response")
110
110
  end
@@ -117,8 +117,8 @@ describe NginxTestHelper do
117
117
  socket.exception = Errno::EAGAIN
118
118
 
119
119
  headers, body = subject.read_response_on_socket(socket)
120
- headers.should eql("HTTP 200 OK")
121
- body.should eql("BODYX")
120
+ expect(headers).to eql("HTTP 200 OK")
121
+ expect(body).to eql("BODYX")
122
122
  end
123
123
  end
124
124
 
@@ -127,19 +127,19 @@ describe NginxTestHelper do
127
127
  socket.exception = Errno::EAGAIN
128
128
 
129
129
  headers, body = subject.read_response_on_socket(socket, "OD")
130
- headers.should eql("HTTP 200 OK")
131
- body.should eql("BODY")
130
+ expect(headers).to eql("HTTP 200 OK")
131
+ expect(body).to eql("BODY")
132
132
  end
133
133
 
134
134
  it "should retry if the text is not present in the response" do
135
135
  socket.exception = Errno::EAGAIN
136
136
  socket.response3 = "Z"
137
137
 
138
- IO.should_receive(:select).with([socket])
138
+ expect(IO).to receive(:select).with([socket])
139
139
 
140
140
  headers, body = subject.read_response_on_socket(socket, "Z")
141
- headers.should eql("HTTP 200 OK")
142
- body.should include("BODY")
141
+ expect(headers).to eql("HTTP 200 OK")
142
+ expect(body).to include("BODY")
143
143
  end
144
144
  end
145
145
  end
@@ -147,64 +147,64 @@ describe NginxTestHelper do
147
147
 
148
148
  context "when testing configuration" do
149
149
  before do
150
- subject.stub(:config_id).and_return("config_id")
151
- subject.stub(:start_server).and_return("Server started")
152
- subject.stub(:stop_server).and_return("Server stoped")
150
+ allow(subject).to receive(:config_id).and_return("config_id")
151
+ allow(subject).to receive(:start_server).and_return("Server started")
152
+ allow(subject).to receive(:stop_server).and_return("Server stoped")
153
153
  end
154
154
 
155
155
  it "should create an instance of NginxTestHelper::Config with the given configuation" do
156
156
  config = NginxTestHelper::Config.new("config_id", {:foo => "bar"})
157
- NginxTestHelper::Config.should_receive(:new).with("config_id", {:foo => "bar"}).and_return(config)
157
+ expect(NginxTestHelper::Config).to receive(:new).with("config_id", {:foo => "bar"}).and_return(config)
158
158
  subject.nginx_test_configuration({:foo => "bar"})
159
159
  end
160
160
 
161
161
  it "should accept test default configuration" do
162
162
  config = NginxTestHelper::Config.new("config_id", {})
163
- NginxTestHelper::Config.should_receive(:new).with("config_id", {}).and_return(config)
163
+ expect(NginxTestHelper::Config).to receive(:new).with("config_id", {}).and_return(config)
164
164
  subject.nginx_test_configuration
165
165
  end
166
166
 
167
167
  it "should call start_server and stop_server methods" do
168
- subject.should_receive(:start_server).and_return("Server started")
169
- subject.should_receive(:stop_server).and_return("Server stoped")
168
+ expect(subject).to receive(:start_server).and_return("Server started")
169
+ expect(subject).to receive(:stop_server).and_return("Server stoped")
170
170
  subject.nginx_test_configuration({:foo => "bar"})
171
171
  end
172
172
 
173
173
  it "should return start command result" do
174
- subject.nginx_test_configuration({:foo => "bar"}).should eql("Server started\n")
174
+ expect(subject.nginx_test_configuration({:foo => "bar"})).to eql("Server started\n")
175
175
  end
176
176
 
177
177
  it "should return start command result concatenated with error log content if exists" do
178
178
  FileUtils.mkdir_p("/tmp/nginx_tests/logs/")
179
179
  File.open("/tmp/nginx_tests/logs/error-config_id.log", "w") { |f| f.write("Error log content") }
180
- subject.nginx_test_configuration({:foo => "bar"}).should eql("Server started\nError log content")
180
+ expect(subject.nginx_test_configuration({:foo => "bar"})).to eql("Server started\nError log content")
181
181
  end
182
182
  end
183
183
 
184
184
  context "when starting server to make tests" do
185
185
  before do
186
- subject.stub(:config_id).and_return("config_id")
187
- subject.stub(:start_server).and_return("Server started")
188
- subject.stub(:stop_server).and_return("Server stoped")
186
+ allow(subject).to receive(:config_id).and_return("config_id")
187
+ allow(subject).to receive(:start_server).and_return("Server started")
188
+ allow(subject).to receive(:stop_server).and_return("Server stoped")
189
189
  end
190
190
 
191
191
  it "should create an instance of NginxTestHelper::Config with the given configuation" do
192
192
  config = NginxTestHelper::Config.new("config_id", {:foo => "bar"})
193
- NginxTestHelper::Config.should_receive(:new).with("config_id", {:foo => "bar"}).and_return(config)
193
+ expect(NginxTestHelper::Config).to receive(:new).with("config_id", {:foo => "bar"}).and_return(config)
194
194
  subject.nginx_run_server({:foo => "bar"}) {}
195
195
  end
196
196
 
197
197
  it "should accept test default configuration" do
198
198
  config = NginxTestHelper::Config.new("config_id", {})
199
- NginxTestHelper::Config.should_receive(:new).with("config_id", {}).and_return(config)
199
+ expect(NginxTestHelper::Config).to receive(:new).with("config_id", {}).and_return(config)
200
200
  subject.nginx_run_server {}
201
201
  end
202
202
 
203
203
  it "should execute the block after start_server and before stop_server methods" do
204
204
  obj = {:xyz => 1}
205
- subject.should_receive(:start_server).ordered
206
- obj.should_receive(:delete).with(:xyz).ordered
207
- subject.should_receive(:stop_server).ordered
205
+ expect(subject).to receive(:start_server).ordered
206
+ expect(obj).to receive(:delete).with(:xyz).ordered
207
+ expect(subject).to receive(:stop_server).ordered
208
208
 
209
209
  subject.nginx_run_server({:foo => "bar"}) { obj.delete(:xyz) }
210
210
  end
@@ -219,78 +219,81 @@ describe NginxTestHelper do
219
219
  end
220
220
 
221
221
  it "should execute stop_server method if an exception was raised" do
222
- subject.should_receive(:stop_server)
222
+ expect(subject).to receive(:stop_server)
223
223
  expect { subject.nginx_run_server({:foo => "bar"}) { raise "some error" } }.to raise_error("some error")
224
224
  end
225
225
  end
226
226
 
227
227
  context "when checking internal behavior" do
228
228
  before do
229
- subject.stub(:start_server).and_return("Server started")
230
- subject.stub(:stop_server).and_return("Server stoped")
231
- subject.stub(:example).and_return(double)
229
+ allow(subject).to receive(:start_server).and_return("Server started")
230
+ allow(subject).to receive(:stop_server).and_return("Server stoped")
231
+ allow(subject).to receive(:example).and_return(double)
232
232
  end
233
233
 
234
234
  context "and check config_id value" do
235
+ before { Thread.current[:current_example] = nil }
236
+ after { |ex| Thread.current[:current_example] = ex }
237
+
235
238
  it "should use example metadata if available" do
236
- subject.example.stub(:metadata).and_return(:location => "./spec/test_config_id_spec.rb:100")
237
- subject.send(:config_id).should eql("test_config_id_spec_rb_100")
239
+ allow(subject.example).to receive(:metadata).and_return(:location => "./spec/test_config_id_spec.rb:100")
240
+ expect(subject.send(:config_id)).to eql("test_config_id_spec_rb_100")
238
241
  end
239
242
 
240
243
  it "should use method_name if example metadata is not available" do
241
- subject.example.stub(:metadata).and_return(nil)
242
- subject.stub(:method_name).and_return("test_config_id_by_method_name")
244
+ allow(subject.example).to receive(:metadata).and_return(nil)
245
+ allow(subject).to receive(:method_name).and_return("test_config_id_by_method_name")
243
246
 
244
- subject.send(:config_id).should eql("test_config_id_by_method_name")
247
+ expect(subject.send(:config_id)).to eql("test_config_id_by_method_name")
245
248
  end
246
249
 
247
250
  it "should use __name__ if example metadata and method_name are not available" do
248
- subject.example.stub(:metadata).and_return(nil)
249
- subject.stub(:__name__).and_return("test_config_id_by___name__")
251
+ allow(subject.example).to receive(:metadata).and_return(nil)
252
+ allow(subject).to receive(:__name__).and_return("test_config_id_by___name__")
250
253
 
251
- subject.send(:config_id).should eql("test_config_id_by___name__")
254
+ expect(subject.send(:config_id)).to eql("test_config_id_by___name__")
252
255
  end
253
256
  end
254
257
 
255
258
  context "and check if the test has passed" do
256
259
  context "using example exception if available" do
257
260
  it "should be 'true' if exception is 'nil'" do
258
- subject.example.stub(:exception).and_return(nil)
259
- subject.send(:has_passed?).should be_true
261
+ allow(subject.example).to receive(:exception).and_return(nil)
262
+ expect(subject.send(:has_passed?)).to be true
260
263
  end
261
264
 
262
265
  it "should be 'false' if exception is not 'nil'" do
263
- subject.example.stub(:exception).and_return("")
264
- subject.send(:has_passed?).should be_false
266
+ allow(subject.example).to receive(:exception).and_return("")
267
+ expect(subject.send(:has_passed?)).to be false
265
268
  end
266
269
  end
267
270
 
268
271
  context "using 'test_passed' attribute if example exception is not available" do
269
272
  it "should be 'true' if 'test_passed' is 'true'" do
270
273
  subject.instance_variable_set(:@test_passed, true)
271
- subject.send(:has_passed?).should be_true
274
+ expect(subject.send(:has_passed?)).to be true
272
275
  end
273
276
 
274
277
  it "should be 'false' if 'test_passed' is 'false'" do
275
278
  subject.instance_variable_set(:@test_passed, false)
276
- subject.send(:has_passed?).should be_false
279
+ expect(subject.send(:has_passed?)).to be false
277
280
  end
278
281
  end
279
282
 
280
283
  context "using 'passed' attribute if example exception and 'test_passed' are not available" do
281
284
  before do
282
- subject.example.stub(:instance_variable_defined?).with(:@exception).and_return(false)
285
+ allow(subject.example).to receive(:instance_variable_defined?).with(:@exception).and_return(false)
283
286
  subject.instance_variable_set(:@test_passed, nil)
284
287
  end
285
288
 
286
289
  it "should be 'true' if 'passed' is 'true'" do
287
290
  subject.instance_variable_set(:@passed, true)
288
- subject.send(:has_passed?).should be_true
291
+ expect(subject.send(:has_passed?)).to be true
289
292
  end
290
293
 
291
294
  it "should be 'false' if 'passed' is 'false'" do
292
295
  subject.instance_variable_set(:@passed, false)
293
- subject.send(:has_passed?).should be_false
296
+ expect(subject.send(:has_passed?)).to be false
294
297
  end
295
298
  end
296
299
  end
@@ -301,24 +304,24 @@ describe NginxTestHelper do
301
304
  let(:status) { Status.new }
302
305
 
303
306
  it "should use POpen4 to execute the command" do
304
- POpen4.should_receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf").and_return(status)
307
+ expect(POpen4).to receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf").and_return(status)
305
308
  subject.start_server(config)
306
309
  end
307
310
 
308
311
  it "should not start the server if configuration has a key 'disable_start_stop_server' with 'true'" do
309
312
  config.configuration[:disable_start_stop_server] = true
310
- POpen4.should_not_receive(:popen4)
313
+ expect(POpen4).not_to receive(:popen4)
311
314
  subject.start_server(config)
312
315
  end
313
316
 
314
317
  it "should raise error if 'exitstatus' is not '0'" do
315
318
  status.exitstatus = 1
316
- POpen4.should_receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf").and_return(status)
319
+ expect(POpen4).to receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf").and_return(status)
317
320
  expect { subject.start_server(config) }.to raise_error("Server doesn't started - ")
318
321
  end
319
322
 
320
323
  it "should return error message when the command fail" do
321
- subject.start_server(config).should eql("nginx: [emerg] unexpected end of file, expecting \";\" or \"}\" in /tmp/nginx_tests/config_id.conf:1")
324
+ expect(subject.start_server(config)).to eql("nginx: [emerg] unexpected end of file, expecting \";\" or \"}\" in /tmp/nginx_tests/config_id.conf:1")
322
325
  end
323
326
  end
324
327
 
@@ -327,24 +330,24 @@ describe NginxTestHelper do
327
330
  let(:status) { Status.new }
328
331
 
329
332
  it "should use POpen4 to execute the command" do
330
- POpen4.should_receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf -s stop").and_return(status)
333
+ expect(POpen4).to receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf -s stop").and_return(status)
331
334
  subject.stop_server(config)
332
335
  end
333
336
 
334
337
  it "should not start the server if configuration has a key 'disable_start_stop_server' with 'true'" do
335
338
  config.configuration[:disable_start_stop_server] = true
336
- POpen4.should_not_receive(:popen4)
339
+ expect(POpen4).not_to receive(:popen4)
337
340
  subject.stop_server(config)
338
341
  end
339
342
 
340
343
  it "should raise error if 'exitstatus' is not '0'" do
341
344
  status.exitstatus = 1
342
- POpen4.should_receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf -s stop").and_return(status)
345
+ expect(POpen4).to receive(:popen4).with("/usr/local/nginx/sbin/nginx -c /tmp/nginx_tests/config_id.conf -s stop").and_return(status)
343
346
  expect { subject.stop_server(config) }.to raise_error("Server doesn't stoped - ")
344
347
  end
345
348
 
346
349
  it "should return error message when the command fail" do
347
- subject.stop_server(config).should eql("nginx: [emerg] unexpected end of file, expecting \";\" or \"}\" in /tmp/nginx_tests/config_id.conf:1")
350
+ expect(subject.stop_server(config)).to eql("nginx: [emerg] unexpected end of file, expecting \";\" or \"}\" in /tmp/nginx_tests/config_id.conf:1")
348
351
  end
349
352
  end
350
353
 
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
  RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true if RSpec::Core::Version::STRING < "3.0.0"
9
9
  config.run_all_when_everything_filtered = true
10
10
  config.filter_run :focus
11
11
 
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nginx_test_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wandenberg Peixoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-26 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: popen4
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.10.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.10.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: debugger
42
+ name: byebug
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.1.3
47
+ version: 3.5.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.1.3
54
+ version: 3.5.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.0.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.0.1
69
69
  description: A collection of helper methods to test your nginx module.
@@ -74,8 +74,8 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
78
- - .rspec
77
+ - ".gitignore"
78
+ - ".rspec"
79
79
  - Gemfile
80
80
  - LICENSE
81
81
  - README.md
@@ -108,12 +108,12 @@ require_paths:
108
108
  - lib
109
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []