Sha256: d7c561d774250331be42b1dcb9ff74cf6dd015f01228bea6af507034271d38e8

Contents?: true

Size: 798 Bytes

Versions: 5

Compression:

Stored size: 798 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).to have(1).items }
    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).to have(1).items }
    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

5 entries across 5 versions & 1 rubygems

Version Path
microscope-0.6.1 spec/microscope/scope/boolean_scope_spec.rb
microscope-0.6 spec/microscope/scope/boolean_scope_spec.rb
microscope-0.5.10 spec/microscope/scope/boolean_scope_spec.rb
microscope-0.5.9 spec/microscope/scope/boolean_scope_spec.rb
microscope-0.5.8 spec/microscope/scope/boolean_scope_spec.rb