aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/syslog/shared/reopen.rb
blob: fd30ab824a5e2bff75056044899d66ba297d475a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
describe :syslog_reopen, shared: true do
  platform_is_not :windows do
    before :each do
      Syslog.opened?.should be_false
    end

    after :each do
      Syslog.opened?.should be_false
    end

    it "reopens the log" do
      Syslog.open
      lambda { Syslog.send(@method)}.should_not raise_error
      Syslog.opened?.should be_true
      Syslog.close
    end

    it "fails with RuntimeError if the log is closed" do
      lambda { Syslog.send(@method)}.should raise_error(RuntimeError)
    end

    it "receives the same parameters as Syslog.open" do
      Syslog.open
      Syslog.send(@method, "rubyspec", 3, 8) do |s|
        s.should == Syslog
        s.ident.should == "rubyspec"
        s.options.should == 3
        s.facility.should == Syslog::LOG_USER
        s.opened?.should be_true
      end
      Syslog.opened?.should be_false
    end

    it "returns the module" do
      Syslog.open
      Syslog.send(@method).should == Syslog
      Syslog.close
    end
  end
end