Sha256: 39e53889ed11afdbe4a8fd8a76636b8db8f810ff49b49f3c6658d5e8547fc72f

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

require 'spec_helper'

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

    microscope 'User' do
      self.table_name = 'oh_users'
    end
  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

1 entries across 1 versions & 1 rubygems

Version Path
microscope-1.0.1 spec/microscope/scope/boolean_scope_spec.rb