Sha256: c88abff5e55a099735fb5dc44e549c18a32444e665fbde00b8d8e6ed112fb565

Contents?: true

Size: 665 Bytes

Versions: 4

Compression:

Stored size: 665 Bytes

Contents

require 'spec_helper'
require 'ostruct'

describe ApplicationController, :type => :controller do
  controller do

  end

  before(:each) do
    @mock_warden = OpenStruct.new
    @controller.request.env['warden'] = @mock_warden
  end

  it "should create an anonymous user for a guest" do
    allow(@mock_warden).to receive(:authenticate).with(anything).and_return(false)

    expect(@controller.current_or_guest_user.email).to match(/guest/)
  end

  it "should use the current user when available" do
    m = double()
    allow(@mock_warden).to receive(:authenticate).with(anything).and_return(m)

    expect(@controller.current_or_guest_user).to eq(m)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-guests-0.7.0 spec/controllers/application_controller_spec.rb
devise-guests-0.6.1 spec/controllers/application_controller_spec.rb
devise-guests-0.6.0 spec/controllers/application_controller_spec.rb
devise-guests-0.5.0 spec/controllers/application_controller_spec.rb