Sha256: 2bb6fe0d5b3763bb83f33adc36dd7337caa3f5af64df450b964b58f83f0c6177
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require File.expand_path("helper", File.dirname(__FILE__)) test "settings is an empty hash by default" do assert Cuba.settings.kind_of?(Hash) assert Cuba.settings.empty? end test "is inheritable and allows overriding" do Cuba.settings[:foo] = "bar" class Admin < Cuba; end assert_equal "bar", Admin.settings[:foo] Admin.settings[:foo] = "baz" assert_equal "bar", Cuba.settings[:foo] assert_equal "baz", Admin.settings[:foo] end test do Cuba.settings[:hello] = "Hello World" Cuba.define do on default do res.write settings[:hello] end end _, _, resp = Cuba.call({ "PATH_INFO" => "/", "SCRIPT_NAME" => ""}) body = [] resp.each do |line| body << line end assert_equal ["Hello World"], body end # The following tests the settings clone bug where # we share the same reference. Deep cloning is the solution here. Cuba.settings[:mote] ||= {} Cuba.settings[:mote][:layout] ||= "layout" class Login < Cuba settings[:mote][:layout] = "layout/guest" end test do assert Login.settings[:mote].object_id != Cuba.settings[:mote].object_id end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cuba-3.1.0.rc1 | test/settings.rb |