-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for times option of ActiveRecord::Base::utusemi
- Loading branch information
YOSHIDA Hiroki
committed
Jul 16, 2014
1 parent
d1475bf
commit 357154e
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
describe Utusemi::Configuration do | ||
describe '"times" option' do | ||
let!(:product_one) { FactoryGirl.create(:product, description1: nil, description2: nil, description3: nil) } | ||
let!(:product_two) { FactoryGirl.create(:product, description1: 'foo', description2: 'bar', description3: 'hoge') } | ||
let!(:product_three) { FactoryGirl.create(:product, description1: 'foo', description2: 'bar', description3: nil) } | ||
|
||
before do | ||
Utusemi.configure do | ||
map(:sample) { |options| description "description#{options[:index]}" } | ||
end | ||
end | ||
|
||
subject { Product.utusemi(:sample, times: 3) } | ||
|
||
it 'found a record that all description are nil' do | ||
expect(subject.where(description: nil).count).to eq(1) | ||
end | ||
|
||
it 'found a record that all description are not nil' do | ||
pending 'Rails 3 is not supported' if Rails::VERSION::MAJOR == 3 | ||
expect(subject.where.not(description: nil).count).to eq(1) | ||
end | ||
end | ||
end |