Skip to content

Commit

Permalink
Avoid nondeterminism. Fixes #2244
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Apr 14, 2015
1 parent 2fa9ada commit c415858
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions spec/integration/config/list/rails_admin_config_list_spec.rb
Expand Up @@ -284,7 +284,7 @@
field :updated_at
end
end
@fans = 2.times.collect { FactoryGirl.create :fan }
@fans = FactoryGirl.create_list(:fan, 2)
visit index_path(model_name: 'fan')
# NOTE: Capybara really doesn't want us to look at invisible text. This test
# could break at any moment.
Expand All @@ -305,7 +305,7 @@
field :updated_at
end
end
@fans = 2.times.collect { FactoryGirl.create :fan }
@fans = FactoryGirl.create_list(:fan, 2).sort_by(&:id)
visit index_path(model_name: 'fan')
expect(find('tbody tr:nth-child(1) td:nth-child(3)')).to have_content(@fans[1].name.upcase)
expect(find('tbody tr:nth-child(2) td:nth-child(3)')).to have_content(@fans[0].name.upcase)
Expand All @@ -322,7 +322,7 @@
field :updated_at
end
end
@fans = 2.times.collect { FactoryGirl.create :fan }
@fans = FactoryGirl.create_list(:fan, 2)
visit index_path(model_name: 'fan')
is_expected.to have_selector('tbody tr:nth-child(1) td:nth-child(4)', text: /\d{2} \w{3} \d{1,2}:\d{1,2}/)
end
Expand All @@ -338,7 +338,7 @@
field :updated_at
end
end
@fans = 2.times.collect { FactoryGirl.create :fan }
@fans = FactoryGirl.create_list(:fan, 2)
visit index_path(model_name: 'fan')
is_expected.to have_selector('tbody tr:nth-child(1) td:nth-child(4)', text: /\d{4}-\d{2}-\d{2}/)
end
Expand All @@ -352,7 +352,7 @@
end
end
@team = FactoryGirl.create :team
@players = 2.times.collect { FactoryGirl.create :player, team: @team }
@players = FactoryGirl.create_list :player, 2, team: @team
visit index_path(model_name: 'team')
expect(find('tbody tr:nth-child(1) td:nth-child(4)')).to have_content(@players.sort_by(&:id).collect(&:name).join(', '))
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_admin/adapters/mongoid_spec.rb
Expand Up @@ -68,7 +68,7 @@
end

it 'supports pagination' do
expect(@abstract_model.all(sort: 'players._id', page: 2, per: 1).to_a).to eq(@players[1..1])
expect(@abstract_model.all(sort: 'players._id', page: 2, per: 1).to_a).to eq(@players.sort_by(&:_id)[1..1])
# To prevent RSpec matcher to call Mongoid::Criteria#== method,
# (we want to test equality of query result, not of Mongoid criteria)
# to_a is added to invoke Mongoid query
Expand Down

0 comments on commit c415858

Please sign in to comment.