Sha256: 0a7d43d28cc3d554ea9a27737b48972991ec3549a5034f8989c072c853c00312

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

#          Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require 'spec/helper'

class TCFlashHelperFirstController < Ramaze::Controller
  map :/
  helper :flash

  def index
    self.class.name
  end

  def first_here
    flash[:first] = 'hey'
  end

  def then_here
    flash[:first].to_s
  end
end

class TCFlashHelperSecondController < Ramaze::Controller
  map '/second'
  helper :flash

  def index
    self.class.name
  end

  def first_here
    flash[:first] = 'hey'
  end

  def then_here
    flash[:first].to_s
  end
end

class TCFlashHelperThirdController < Ramaze::Controller
  map '/third'
  helper :flash

  def index
  end

  def noop
    'noop'
  end

  def set par
    flash[:e] = par
  end

  def retrieve
    flash[:e]
  end
end

describe "FlashHelper" do
  behaves_like 'browser'
  ramaze :adapter => :webrick

  it "twice" do
    Browser.new('/') do
      get('/first_here')
      get('/then_here').should == 'hey'
      get('/then_here').should == ''
      get('/then_here').should == ''
      get('/first_here')
      get('/then_here').should == 'hey'
      get('/then_here').should == ''
    end
  end

  it "over seperate controllers" do
    Browser.new do
      get('/first_here')
      get('/second/then_here').should == 'hey'
      get('/then_here').should == ''
      get('/second/then_here').should == ''
      get('/second/first_here')
      get('/then_here').should == 'hey'
      get('/second/then_here').should == ''
    end
  end

  it "single" do
    Browser.new do
      get('/third/set/foo').should == 'foo'
    end
  end

  it "single" do
    Browser.new do
      get('/third/set/foo').should == 'foo'
      get('/third/retrieve').should == 'foo'
      get('/third/retrieve').should == ''
      get('/third/retrieve').should == ''
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ramaze-0.3.0 spec/ramaze/helper/flash.rb
ramaze-0.3.5 spec/ramaze/helper/flash.rb