Sha256: c4cbfa7a6c2aa920a3f14245c13d8d4e808d51a576b05003e10a8b044c038cbb

Contents?: true

Size: 870 Bytes

Versions: 20

Compression:

Stored size: 870 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].should == "bar"

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

    sc.opts[:foo] = "baz"
    sc.opts[:foo].should == "baz"
    c.opts[:foo].should == "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.should == "Hello World"
  end

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

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

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

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
roda-2.2.0 spec/opts_spec.rb
roda-2.1.0 spec/opts_spec.rb
roda-2.0.0 spec/opts_spec.rb
roda-1.3.0 spec/opts_spec.rb
roda-1.2.0 spec/opts_spec.rb
roda-1.1.0 spec/opts_spec.rb
roda-cj-1.0.5 spec/opts_spec.rb
roda-cj-1.0.4 spec/opts_spec.rb
roda-cj-1.0.3 spec/opts_spec.rb
roda-cj-1.0.2 spec/opts_spec.rb
roda-cj-1.0.1 spec/opts_spec.rb
roda-cj-1.0.0 spec/opts_spec.rb
roda-1.0.0 spec/opts_spec.rb
roda-cj-0.9.6 spec/opts_spec.rb
roda-cj-0.9.5 spec/opts_spec.rb
roda-cj-0.9.4 spec/opts_spec.rb
roda-cj-0.9.3 spec/opts_spec.rb
roda-cj-0.9.2 spec/opts_spec.rb
roda-cj-0.9.1 spec/opts_spec.rb
roda-0.9.0 spec/opts_spec.rb