Sha256: c50aa6635d3de244c608c2967b386128ad6ffc9a45b4a6c362d40af6e0b7c8c8

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8
#
# This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun_panda@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

require "spec_helper"

describe Brauser::Hooks::RubyOnRails do
  before(:each) do
    stub_const("ActionController::Base", Class.new)
    allow(ActionController::Base).to receive(:helper_method)
    allow_any_instance_of(ActionController::Base).to receive(:request).and_return(OpenStruct.new(headers: {}))
    ActionController::Base.send(:include, Brauser::Hooks::RubyOnRails)
  end

  let(:controller){::ActionController::Base.new}

  it "should append to ActionController::Base" do
    expect(controller.respond_to?(:browser)).to be_true
  end

  it "should memoize browser" do
    browser = controller.browser
    expect(browser).to be_a(::Brauser::Browser)
    expect(controller.browser).to eq(browser)
  end

  it "should detect browser again" do
    browser = controller.browser
    expect(controller.browser(true)).not_to eq(browser)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brauser-3.2.1 spec/brauser/hooks_spec.rb