retr0h / simply_tabby forked from latimes/simply_tabby

A Rails plugin which collects and reports system information inside HTML comments.

simply_tabby / spec / simply_tabby_spec.rb
100644 52 lines (44 sloc) 1.956 kb
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
41
42
43
44
45
46
47
48
49
50
51
52
require File.join(File.dirname(__FILE__), 'spec_helper')
 
describe SimplyTabby, "revision_number class method" do
  it "should return revision number" do
    @file = mock('file')
    File.should_receive(:exist?).and_return(true)
    File.should_receive(:open).and_return(@file)
    @file.should_receive(:readline).and_return('r123')
    SimplyTabby.revision_number.should be_eql('r123')
  end
  
  it "should _not return revision number" do
    File.should_receive(:exist?).and_return(false)
    SimplyTabby.revision_number.should be_eql('No revision found')
  end
end
 
describe SimplyTabby, "display_system_information class method" do
  it "should display system information and return a hash" do
    SimplyTabby.display_system_information.should be_an_instance_of(Hash)
  end
end
 
describe SimplyTabby, "display_crypt_system_information class method" do
  it "should display crypt system information and return a crypt" do
    SimplyTabby.display_crypt_system_information.should be_an_instance_of(String)
  end
end
 
describe SimplyTabby, "reload object" do
  before(:each) do
    ### Force a reload of SimplyTabby class, since our setters modify class variables.
    Object.send(:remove_const, 'SimplyTabby')
    load File.join(File.dirname(__FILE__), '../lib', 'simply_tabby.rb')
  end
 
  describe SimplyTabby, "remove_system_information class method" do
    it "should remove one element and return public(hash.keys - 1)" do
      SimplyTabby.remove_system_information(:public, :application_revision)
      SimplyTabby.display_system_information[:public].keys.size.should == 1
    end
  end
 
  load File.join(File.dirname(__FILE__), '../lib', 'simply_tabby.rb')
  describe SimplyTabby, "add_system_information class method" do
    it "should add one element and return public(hash.keys + 1)" do
      SimplyTabby.add_system_information(:public, :foo => 1)
      SimplyTabby.display_system_information[:public].keys.size.should == 3
    end
  end
end