Sha256: 31a68d70d590919a6b076af36ee661e225dbb5a54d5921021b2f35093208246d

Contents?: true

Size: 1.13 KB

Versions: 18

Compression:

Stored size: 1.13 KB

Contents

require File.expand_path("helper", File.dirname(__FILE__))

test "settings contains request and response classes by default" do
  assert_equal Cuba.settings[:req], Rack::Request
  assert_equal Cuba.settings[:res], Cuba::Response
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

18 entries across 18 versions & 1 rubygems

Version Path
cuba-4.0.3 test/settings.rb
cuba-4.0.1 test/settings.rb
cuba-4.0.0 test/settings.rb
cuba-3.9.3 test/settings.rb
cuba-3.9.2 test/settings.rb
cuba-3.9.1 test/settings.rb
cuba-3.9.0 test/settings.rb
cuba-3.8.1 test/settings.rb
cuba-3.8.0 test/settings.rb
cuba-3.7.0 test/settings.rb
cuba-3.6.0 test/settings.rb
cuba-3.5.0 test/settings.rb
cuba-3.4.0 test/settings.rb
cuba-3.3.0 test/settings.rb
cuba-3.2.0 test/settings.rb
cuba-3.1.1 test/settings.rb
cuba-3.1.0 test/settings.rb
cuba-3.1.0.rc2 test/settings.rb