Sha256: 9011ed7d30055fff1a38163a7e2fc4be201aa2bb06bb11bc7f8e73b8d4ca3d3a

Contents?: true

Size: 1.03 KB

Versions: 28

Compression:

Stored size: 1.03 KB

Contents

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

describe "shared_vars plugin" do 
  it "adds shared method for sharing variables across multiple apps" do
    app(:shared_vars) {|r| shared[:c]}
    old_app = app
    app(:shared_vars) do |r|
      shared[:c] = 'c'
      r.run old_app
    end

    body.must_equal 'c'
  end

  it "adds shared with hash merges the hash into the shared vars" do
    app(:shared_vars) do |r|
      shared(:c=>'c')
      shared[:c]
    end

    body.must_equal 'c'
  end

  it "calling shared with hash and a block sets shared variables only for that block" do
    app(:shared_vars) do |r|
      c = nil
      d = nil
      shared[:c] = 'b'
      shared(:c=>'c', :d=>'d') do
        c = shared[:c]
        d = shared[:d]
      end
      "#{shared[:c]}:#{shared[:d]}:#{c}:#{d}"
    end

    body.must_equal 'b::c:d'
  end

  it "calling shared with no arguments and a block raises an error" do
    app(:shared_vars) do |r|
      shared{}
    end
    proc{body}.must_raise(Roda::RodaError)
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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