Sha256: f46fcb43d60a43cb949900b5a28d4f59deea4b1a3e3561d2adc4db4847a8678b

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

require 'spec_helper'

describe Microscope::Scope::BooleanScope do
  before do
    run_migration do
      create_table(:users, force: true) do |t|
        t.boolean :active, default: false
      end
    end

    microscope 'User'
  end

  describe 'positive scope' do
    before do
      @user1 = User.create(active: true)
      @user2 = User.create(active: false)
    end

    it { expect(User.active.length).to eql 1 }
    it { expect(User.active).to include(@user1) }
  end

  describe 'negative scope' do
    before do
      @user1 = User.create(active: false)
      @user2 = User.create(active: true)
    end

    it { expect(User.not_active.length).to eql 1 }
    it { expect(User.not_active).to include(@user1) }
    it { expect(User.unactive.to_a).to eql User.not_active.to_a }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
microscope-1.0.0 spec/microscope/scope/boolean_scope_spec.rb
microscope-0.6.2 spec/microscope/scope/boolean_scope_spec.rb