spec/lib/simple_navigation_spec.rb in simple-navigation-2.2.3 vs spec/lib/simple_navigation_spec.rb in simple-navigation-2.4.0
- old
+ new
@@ -71,10 +71,43 @@
SimpleNavigation.should_receive(:template=).with(@template)
SimpleNavigation.set_template_from @context
end
end
+ describe 'self.init_rails' do
+ before(:each) do
+ SimpleNavigation.stub!(:default_config_file_path => 'default_path')
+ ActionController::Base.stub!(:include)
+ end
+ context 'SimpleNavigation.config_file_path is already set' do
+ before(:each) do
+ SimpleNavigation.config_file_path = 'my_path'
+ end
+ it "should not override the config_file_path" do
+ SimpleNavigation.init_rails
+ SimpleNavigation.config_file_path.should == 'my_path'
+ end
+ end
+ context 'SimpleNavigation.config_file_path is not set' do
+ before(:each) do
+ SimpleNavigation.config_file_path = nil
+ end
+ it "should set the config_file_path to the default" do
+ SimpleNavigation.init_rails
+ SimpleNavigation.config_file_path.should == 'default_path'
+ end
+ end
+ it "should extend the ActionController::Base" do
+ ActionController::Base.should_receive(:include).with(SimpleNavigation::ControllerMethods)
+ SimpleNavigation.init_rails
+ end
+ end
+
+ describe 'self.default_config_file_path' do
+ it {SimpleNavigation.default_config_file_path.should == './config'}
+ end
+
describe 'self.extract_controller_from' do
before(:each) do
@nav_context = stub(:nav_context)
end
@@ -190,21 +223,21 @@
SimpleNavigation.config_file_path = 'path_to_config'
File.stub!(:exists? => true)
end
context "RAILS_ENV undefined" do
before(:each) do
- ::RAILS_ENV = nil
+ SimpleNavigation.rails_env = nil
end
it "should load the config file twice" do
IO.should_receive(:read).twice
SimpleNavigation.load_config
SimpleNavigation.load_config
end
end
context "RAILS_ENV defined" do
before(:each) do
- ::RAILS_ENV = 'production'
+ SimpleNavigation.rails_env = 'production'
end
context "RAILS_ENV=production" do
it "should load the config file only once" do
IO.should_receive(:read).once
SimpleNavigation.load_config
@@ -212,21 +245,21 @@
end
end
context "RAILS_ENV=development" do
before(:each) do
- ::RAILS_ENV = 'development'
+ SimpleNavigation.rails_env = 'development'
end
it "should load the config file twice" do
IO.should_receive(:read).twice
SimpleNavigation.load_config
SimpleNavigation.load_config
end
end
context "RAILS_ENV=test" do
before(:each) do
- ::RAILS_ENV = 'test'
+ SimpleNavigation.rails_env = 'test'
end
it "should load the config file twice" do
IO.should_receive(:read).twice
SimpleNavigation.load_config
SimpleNavigation.load_config
\ No newline at end of file