Sha256: e61e47e517efca4482f069115b3ce4183fb128ff6a447075ce710445181f7447

Contents?: true

Size: 689 Bytes

Versions: 97

Compression:

Stored size: 689 Bytes

Contents

require 'spec_helper'
require 'rainbow'

RSpec.describe 'Rainbow refinement' do
  before do
    require 'rainbow/refinement'
    
    class ScopeNotIncluded
      def self.red_hello
        'hello'.red
      end
    end

    class ScopeIncluded
      using Rainbow
      def self.red_hello
        'hello'.red
      end
    end
  end

  it 'is not active by default' do
    expect do
      ScopeNotIncluded.red_hello
    end.to raise_error(NoMethodError)
  end

  it 'is available when used' do
    expect(ScopeIncluded.red_hello).to eq(Rainbow('hello').red)
  end

  it 'respects disabled state' do
    Rainbow.enabled = false
    expect(ScopeIncluded.red_hello).to eq('hello')
  end
end

Version data entries

97 entries across 90 versions & 19 rubygems

Version Path
primary_connect_proto-0.20.0 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.20.0 vendor/bundle/ruby/3.0.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.19.0 vendor/bundle/ruby/3.0.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.18.0 vendor/bundle/ruby/3.0.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.18.0 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.17.0 vendor/bundle/ruby/3.0.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.17.0 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.12.1 vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.10.2 vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.10.1 vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.9.0 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.8.2 vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.8.1 vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.8.0 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.7.3 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.7.2 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.7.1 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.7.0 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
primary_connect_proto-0.6.0 vendor/bundle/ruby/2.6.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/rainbow-3.0.0/spec/integration/refinement_spec.rb