Sha256: b241d19b9562ec4298f3b8e6cccb74f3b34b6ece224fb6d828b49682ad6019bb

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'

class Staff < Peek::Views::View
  def initialize(options = {})
    @username = options.delete(:username)
  end

  def username
    @username
  end

  def enabled?
    !!@username
  end
end

describe Peek do
  describe "enabled?" do
    it "should not be enabled in test" do
      refute Peek.enabled?
    end
  end

  describe "env" do
    it "should return the current environment" do
      assert_equal 'test', Peek.env
    end
  end

  describe "views" do
    before do
      Peek.reset
    end

    it "should have none by default" do
      assert_equal [], Peek.views
    end

    it "should be able to append views" do
      Peek.into Staff, username: 'dewski'
      assert_kind_of Staff, Peek.views.first
    end

    it "should be able to append views with options" do
      Peek.into Staff, username: 'dewski'
      @staff = Peek.views.first
      assert_kind_of Staff, @staff
      assert_equal 'dewski', @staff.username
    end

    it "should only return enabled views" do
      Peek.into Staff, username: false
      assert_equal [], Peek.views
    end
  end

  describe "reset" do
    before do
      Peek.reset
    end

    it "should clear any current views" do
      Peek.into Staff, username: 'dewski'
      assert_kind_of Staff, Peek.views.first
      Peek.reset
      assert_equal [], Peek.views
    end
  end
end

Version data entries

17 entries across 13 versions & 3 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/peek-1.1.0/test/peek_test.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/peek-1.1.0/test/peek_test.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/peek-1.1.0/test/peek_test.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/peek-1.1.0/test/peek_test.rb
peek-1.1.0 test/peek_test.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
gitlab-peek-0.0.1 test/peek_test.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/peek-1.0.1/test/peek_test.rb
peek-1.0.1 test/peek_test.rb