Sha256: 76add2ea046e34974fd84fb247e996a7be0b6a3983a88a259d9d57b81dbf1e8d
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
require 'spec_helper' describe Microscope::Scope::BooleanScope do describe 'for a valid column name' 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 describe 'for a invalid column name' do before do run_migration do create_table(:users, force: true) do |t| t.boolean :public, default: false end end end it { expect { microscope 'User' }.to raise_error(Microscope::BlacklistedColumnsError) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
microscope-1.1.1 | spec/microscope/scope/boolean_scope_spec.rb |
microscope-1.1.0 | spec/microscope/scope/boolean_scope_spec.rb |