Fix up Rubinius specific library specs.
[rbx.git] / spec / library / config / rbconfig_spec.rb
blob30e3473a151d770ec8e81834011b001aa86b716d
1 require File.dirname(__FILE__) + '/../../spec_helper'
2 require 'rbconfig'
4 # These specs are difficult because the values may vary
5 # depending on platform or other configuration options.
6 # However, the specs are valuable in that they will ensure
7 # that rbconfig loads and contains required values.
9 # The Config entries fall into two general categories:
10 # 1) the static-value entries; and 2) the configured-
11 # value entries. For the second one, the specs check
12 # only for the existence of a key.
14 def it_has_keys(name, keys)
15   describe "#{name}" do
16     before :all do
17       @const = const_lookup name
18     end
20     keys.each do |key|
21       it "has key #{key}" do
22         @const.key?(key).should_not be_nil
23       end
24     end
25   end
26 end
28 def it_has_entries(name, entries)
29   describe "#{name}" do
30     before :all do
31       @const = const_lookup name
32     end
34     entries.each do |key, expected|
35       it "has entry #{key} == #{expected}" do
36         @const[key].should == expected
37       end
38     end
39   end
40 end
42 describe "RbConfig" do
43   it "is equal to Config" do
44     RbConfig.should eql(Config)
45   end
46 end
48 # TODO: many more specs needed
49 describe "Config::CONFIG" do
50   keys = [
51     "LDSHARED",
52     "DLEXT",
53     "EXEEXT",
54     "wordsize",
55     "prefix",
56     "bindir",
57     "datadir",
58     "rubyhdrdir",
59     "wordsize",
60     "arch"
61   ]
63   it_has_keys 'Config::CONFIG', keys
65   entries = {
66     "RUBY_SO_NAME"      => "rubinius-0.9.0",
67     "ruby_install_name" => "rbx",
68     "ruby_version"      => "1.8",
69   }
71   it_has_entries 'Config::CONFIG', entries
72 end
74 describe "Config::MAKEFILE_CONFIG" do
75   entries = {
76     "exec_prefix"        => "$(prefix)",
77     "bindir"             => "$(exec_prefix)/bin",
78     "sbindir"            => "$(exec_prefix)/sbin",
79     "libexecdir"         => "$(exec_prefix)/libexec",
80     "datarootdir"        => "$(prefix)/share",
81     "datadir"            => "$(datarootdir)",
82     "sysconfdir"         => "$(prefix)/etc",
83     "sharedstatedir"     => "$(prefix)/com",
84     "localstatedir"      => "$(prefix)/var",
85     "includedir"         => "$(prefix)/include",
86     "oldincludedir"      => "/usr/include",
87     "docdir"             => "$(datarootdir)/doc/$(PACKAGE)",
88     "infodir"            => "$(datarootdir)/info",
89     "htmldir"            => "$(docdir)",
90     "dvidir"             => "$(docdir)",
91     "pdfdir"             => "$(docdir)",
92     "psdir"              => "$(docdir)",
93     "libdir"             => "$(exec_prefix)/lib",
94     "localedir"          => "$(datarootdir)/locale",
95     "mandir"             => "$(datarootdir)/man",
96     "sitedir"            => "$(libdir)/ruby/site_ruby",
97     "ruby_version"       => "$(MAJOR).$(MINOR)",
98     "rubylibdir"         => "$(libdir)/ruby/$(ruby_version)",
99     "archdir"            => "$(rubylibdir)/$(arch)",
100     "sitearchdir"        => "$(sitelibdir)/$(sitearch)",
101     "sitedir"            => "$(install_prefix)/lib/rubinius",
102     "rubyhdrdir"         => "$(prefix)/shotgun/lib/subtend"
103   }
105   it_has_entries 'Config::MAKEFILE_CONFIG', entries