Sha256: 2e43c10fc3915a8e8c42ba81441288ffbe6111746eb1ed535bc7481d83020504

Contents?: true

Size: 882 Bytes

Versions: 20

Compression:

Stored size: 882 Bytes

Contents

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

describe "opts" do
  it "is inheritable and allows overriding" do
    c = Class.new(Roda)
    c.opts[:foo] = "bar"
    c.opts[:foo].must_equal "bar"

    sc = Class.new(c)
    sc.opts[:foo].must_equal "bar"

    sc.opts[:foo] = "baz"
    sc.opts[:foo].must_equal "baz"
    c.opts[:foo].must_equal "bar"
  end

  it "should be available as an instance methods" do
    app(:bare) do
      opts[:hello] = "Hello World"

      route do |r|
        r.on do
          opts[:hello]
        end
      end
    end

    body.must_equal "Hello World"
  end

  it "should only shallow clone by default" do
    c = Class.new(Roda)
    c.opts[:foo] = "bar".dup
    c.opts[:foo].must_equal "bar"

    sc = Class.new(c)
    sc.opts[:foo].replace("baz")

    sc.opts[:foo].must_equal "baz"
    c.opts[:foo].must_equal "baz"
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
roda-2.29.0 spec/opts_spec.rb
roda-2.28.0 spec/opts_spec.rb
roda-2.27.0 spec/opts_spec.rb
roda-2.26.0 spec/opts_spec.rb
roda-2.25.0 spec/opts_spec.rb
roda-2.24.0 spec/opts_spec.rb
roda-2.23.0 spec/opts_spec.rb
roda-2.22.0 spec/opts_spec.rb
roda-2.21.0 spec/opts_spec.rb
roda-2.20.0 spec/opts_spec.rb
roda-2.19.0 spec/opts_spec.rb
roda-2.18.0 spec/opts_spec.rb
roda-2.17.0 spec/opts_spec.rb
roda-2.16.0 spec/opts_spec.rb
roda-2.15.0 spec/opts_spec.rb
roda-2.14.0 spec/opts_spec.rb
roda-2.13.0 spec/opts_spec.rb
roda-2.12.0 spec/opts_spec.rb
roda-2.11.0 spec/opts_spec.rb
roda-2.10.0 spec/opts_spec.rb