Sha256: 8689003f8f1257681b5420129b5383c51d9fe5c5d23637061819944a2065d286
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
describe Bitten do before do Post.has_bits :published, :featured, :sponsored end subject(:post) { Post.new } it { should_not be_published } it { should_not be_featured } it { should_not be_sponsored } it { should respond_to(:published=) } it { should respond_to(:featured=) } it { should respond_to(:sponsored=) } its(:class) { should respond_to(:published) } its(:class) { should respond_to(:featured) } its(:class) { should respond_to(:sponsored) } its(:class) { should respond_to(:not_published) } its(:class) { should respond_to(:not_featured) } its(:class) { should respond_to(:not_sponsored) } it 'can toggle a flag' do subject.published = true expect(post).to be_published subject.published = false expect(post).not_to be_published end describe 'scopes' do let!(:post1) { Post.create! published: true } let!(:post2) { Post.create! featured: true } it 'finds a record by flag' do expect(Post.published).to include(post1) expect(Post.published).not_to include(post2) expect(Post.featured).not_to include(post1) expect(Post.featured).to include(post2) expect(Post.sponsored).not_to include(post1) expect(Post.sponsored).not_to include(post2) end it 'finds a record by not having a flag' do expect(Post.not_published).not_to include(post1) expect(Post.not_published).to include(post2) expect(Post.not_featured).to include(post1) expect(Post.not_featured).not_to include(post2) expect(Post.not_sponsored).to include(post1) expect(Post.not_sponsored).to include(post2) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bitten-0.0.1 | spec/bitten_spec.rb |