Sha256: 5afad50b8ba7c090e7895e9f3037474006a8e0d71fc06800d9e9b2c12ed38d6c

Contents?: true

Size: 1013 Bytes

Versions: 30

Compression:

Stored size: 1013 Bytes

Contents

require_relative "../spec_helper"

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

30 entries across 30 versions & 1 rubygems

Version Path
roda-3.28.0 spec/plugin/shared_vars_spec.rb
roda-3.27.0 spec/plugin/shared_vars_spec.rb
roda-3.26.0 spec/plugin/shared_vars_spec.rb
roda-3.25.0 spec/plugin/shared_vars_spec.rb
roda-3.24.0 spec/plugin/shared_vars_spec.rb
roda-3.23.0 spec/plugin/shared_vars_spec.rb
roda-3.22.0 spec/plugin/shared_vars_spec.rb
roda-3.21.0 spec/plugin/shared_vars_spec.rb
roda-3.20.0 spec/plugin/shared_vars_spec.rb
roda-3.19.0 spec/plugin/shared_vars_spec.rb
roda-3.18.0 spec/plugin/shared_vars_spec.rb
roda-3.17.0 spec/plugin/shared_vars_spec.rb
roda-3.16.0 spec/plugin/shared_vars_spec.rb
roda-3.15.0 spec/plugin/shared_vars_spec.rb
roda-3.14.1 spec/plugin/shared_vars_spec.rb
roda-3.14.0 spec/plugin/shared_vars_spec.rb
roda-3.13.0 spec/plugin/shared_vars_spec.rb
roda-3.12.0 spec/plugin/shared_vars_spec.rb
roda-3.11.0 spec/plugin/shared_vars_spec.rb
roda-3.10.0 spec/plugin/shared_vars_spec.rb