Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃殌 MONGOID-5572 Rspec use expectation syntax #5553

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions spec/integration/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def insert_rails_gem_version(cmd)
uri = URI.parse('http://localhost:4567/posts')
resp = JSON.parse(uri.open.read)

resp.should == []
expect(resp).to eq([])

end
end
Expand All @@ -64,7 +64,7 @@ def insert_rails_gem_version(cmd)
uri = URI.parse('http://localhost:3000/posts')
resp = JSON.parse(uri.open.read)

resp.should == []
expect(resp).to eq([])
end
end
end
Expand Down Expand Up @@ -95,7 +95,7 @@ def start_app(cmd, port, timeout)
# Puma on JRuby exits with status 1 when it receives a TERM signal.
allowed_statuses << 1
end
allowed_statuses.should include(status)
expect(allowed_statuses).to include(status)

rv
end
Expand Down Expand Up @@ -125,18 +125,18 @@ def prepare_new_rails_app(name)

# https://jira.mongodb.org/browse/MONGOID-4885
comment_text = File.read('app/models/comment.rb')
comment_text.should =~ /belongs_to :post/
comment_text.should_not =~ /embedded_in :post/
expect(comment_text).to match(/belongs_to :post/)
expect(comment_text).not_to match(/embedded_in :post/)
end
end

it 'generates Mongoid config' do
prepare_new_rails_app 'mongoid-test-config' do
mongoid_config_file = File.join(TMP_BASE, 'mongoid-test-config/config/mongoid.yml')

File.exist?(mongoid_config_file).should be false
expect(File.exist?(mongoid_config_file)).to be false
check_call(%w(rails g mongoid:config), env: clean_env)
File.exist?(mongoid_config_file).should be true
expect(File.exist?(mongoid_config_file)).to be true

config_text = File.read(mongoid_config_file)
expect(config_text).to match /mongoid_test_config_development/
Expand All @@ -159,9 +159,9 @@ def prepare_new_rails_app(name)
prepare_new_rails_app 'mongoid-test-init' do
mongoid_initializer = File.join(TMP_BASE, 'mongoid-test-init/config/initializers/mongoid.rb')

File.exist?(mongoid_initializer).should be false
expect(File.exist?(mongoid_initializer)).to be false
check_call(%w(rails g mongoid:config), env: clean_env)
File.exist?(mongoid_initializer).should be true
expect(File.exist?(mongoid_initializer)).to be true
end
end
end
Expand Down Expand Up @@ -215,15 +215,15 @@ def install_rails
index = client['posts'].indexes.detect do |index|
index['key'] == {'subject' => 1}
end
index.should be nil
expect(index).to be nil

check_call(%w(bundle exec rake db:mongoid:create_indexes -t),
cwd: APP_PATH, env: env)

index = client['posts'].indexes.detect do |index|
index['key'] == {'subject' => 1}
end
index.should be_a(Hash)
expect(index).to be_a(Hash)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/associations/embedded_dirty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
let(:subject) { EmmOuter.first }

it 'performs dirty tracking efficiently' do
subject.changed?.should be false
expect(subject.changed?).to be false
end

it 'calculates the descendants properly' do
Expand All @@ -46,7 +46,7 @@
let(:subject) { EmmOuter.first }

it 'performs dirty tracking efficiently' do
subject.changed?.should be false
expect(subject.changed?).to be false
end

it 'calculates the descendants properly' do
Expand Down
58 changes: 29 additions & 29 deletions spec/integration/associations/embedded_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
shared_examples_for 'an embedded association' do
it 'adds child documents to parent association object' do
legislator
congress.legislators._target.should == [legislator]
expect(congress.legislators._target).to eq([legislator])
end

it 'adds child documents to parent association object criteria' do
legislator
congress.legislators.criteria.documents.should == [legislator]
expect(congress.legislators.criteria.documents).to eq([legislator])
end

it 'populates documents on parent association object' do
congress.legislators.documents.should == [legislator]
expect(congress.legislators.documents).to eq([legislator])
end

it 'returns created child when referencing embedded association' do
congress.legislators.should == [legislator]
expect(congress.legislators).to eq([legislator])
end

it 'returns created child when referencing Criteria created from embedded association' do
congress.legislators.all.should be_a(Mongoid::Criteria)
congress.legislators.all.to_a.should == [legislator]
expect(congress.legislators.all).to be_a(Mongoid::Criteria)
expect(congress.legislators.all.to_a).to eq([legislator])
end
end

Expand Down Expand Up @@ -70,32 +70,32 @@

shared_examples_for 'adds child documents to parent association' do
it 'adds child documents to parent association' do
manufactory.products._target.should == [product]
expect(manufactory.products._target).to eq([product])
end
end

shared_examples_for 'an embedded association' do
it 'adds child documents to parent association object' do
product
manufactory.products._target.should == [product]
expect(manufactory.products._target).to eq([product])
end

it 'adds child documents to parent association object criteria' do
product
manufactory.products.criteria.documents.should == [product]
expect(manufactory.products.criteria.documents).to eq([product])
end

it 'populates documents on parent association object' do
manufactory.products.documents.should == [product]
expect(manufactory.products.documents).to eq([product])
end

it 'returns created child when referencing embedded association' do
manufactory.products.should == [product]
expect(manufactory.products).to eq([product])
end

it 'returns created child when referencing Criteria created from embedded association' do
manufactory.products.all.should be_a(Mongoid::Criteria)
manufactory.products.all.to_a.should == [product]
expect(manufactory.products.all).to be_a(Mongoid::Criteria)
expect(manufactory.products.all.to_a).to eq([product])
end
end

Expand Down Expand Up @@ -129,7 +129,7 @@
shared_examples 'is set' do
it 'is set' do
parent.child = child_cls.new
parent.child.parent.should == parent
expect(parent.child.parent).to eq(parent)
end
end

Expand All @@ -154,7 +154,7 @@

shared_examples 'is set' do
it 'is set' do
child.congress.should == parent
expect(child.congress).to eq(parent)
end
end

Expand Down Expand Up @@ -183,7 +183,7 @@
parent.child = EomChild.new
parent.save!

parent.updated_at.should > first_updated_at
expect(parent.updated_at).to be > first_updated_at
end
end

Expand All @@ -196,7 +196,7 @@
parent.legislators << EmmLegislator.new
parent.save!

parent.updated_at.should > first_updated_at
expect(parent.updated_at).to be > first_updated_at
end
end
end
Expand All @@ -211,7 +211,7 @@
parent.child.a = 42
parent.save!

parent.updated_at.should > first_updated_at
expect(parent.updated_at).to be > first_updated_at
end
end

Expand All @@ -224,7 +224,7 @@
parent.legislators.first.a = 42
parent.save!

parent.updated_at.should > first_updated_at
expect(parent.updated_at).to be > first_updated_at
end
end
end
Expand All @@ -239,7 +239,7 @@
parent.child = nil
parent.save!

parent.updated_at.should > first_updated_at
expect(parent.updated_at).to be > first_updated_at
end
end

Expand All @@ -254,7 +254,7 @@
parent.legislators.clear
parent.save!

parent.updated_at.should > first_updated_at
expect(parent.updated_at).to be > first_updated_at
end
end
end
Expand Down Expand Up @@ -291,9 +291,9 @@
user.save!
user.reload

user.orders.map do
expect(user.orders.map do
|order| [order.sku, order.amount]
end.should == [[1, 10], [2, 2]]
end).to eq([[1, 10], [2, 2]])
end
end

Expand All @@ -304,9 +304,9 @@
user.save!
user.reload

user.orders.map do
expect(user.orders.map do
|order| [order.sku, order.amount]
end.should == [[1, 1], [2, 20]]
end).to eq([[1, 1], [2, 20]])
end
end
end
Expand All @@ -329,9 +329,9 @@
user.save!
user.reload

user.orders.map do
expect(user.orders.map do
|order| [order.sku, order.surcharges.first.amount]
end.should == [[1, 10], [2, 2]]
end).to eq([[1, 10], [2, 2]])
end
end

Expand All @@ -342,9 +342,9 @@
user.save!
user.reload

user.orders.map do
expect(user.orders.map do
|order| [order.sku, order.surcharges.first.amount]
end.should == [[1, 1], [2, 20]]
end).to eq([[1, 1], [2, 20]])
end
end
end
Expand Down
26 changes: 13 additions & 13 deletions spec/integration/associations/embeds_many_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
canvas.shapes = [shape]
canvas.save!
canvas.reload
canvas.shapes.should == [shape]
expect(canvas.shapes).to eq([shape])
end
end
end
Expand All @@ -30,21 +30,21 @@
it 'deletes the target from the database' do
unsaved_parent.shapes.clear

unsaved_parent.shapes.should be_empty
expect(unsaved_parent.shapes).to be_empty

unsaved_parent.new_record?.should be true
expect(unsaved_parent.new_record?).to be true
parent.reload
parent.shapes.should be_empty
expect(parent.shapes).to be_empty
end
end

shared_examples 'does not delete the target from the database' do
it 'does not delete the target from the database' do
unsaved_parent.shapes.should be_empty
expect(unsaved_parent.shapes).to be_empty

unsaved_parent.new_record?.should be true
expect(unsaved_parent.new_record?).to be true
parent.reload
parent.shapes.length.should == 1
expect(parent.shapes.length).to eq(1)
end
end

Expand Down Expand Up @@ -73,9 +73,9 @@

shared_examples 'persists correctly' do
it 'persists correctly' do
canvas.shapes.should be_empty
expect(canvas.shapes).to be_empty
_canvas = Canvas.find(canvas.id)
_canvas.shapes.should be_empty
expect(_canvas.shapes).to be_empty
end
end

Expand Down Expand Up @@ -117,9 +117,9 @@

shared_examples 'persists correctly' do
it 'persists correctly' do
canvas.shapes.length.should eq 2
expect(canvas.shapes.length).to eq 2
_canvas = Canvas.find(canvas.id)
_canvas.shapes.length.should eq 2
expect(_canvas.shapes.length).to eq 2
end
end

Expand Down Expand Up @@ -161,9 +161,9 @@

shared_examples 'persists correctly' do
it 'persists correctly' do
canvas.shapes.should be_empty
expect(canvas.shapes).to be_empty
_canvas = Canvas.find(canvas.id)
_canvas.shapes.should be_empty
expect(_canvas.shapes).to be_empty
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/associations/embeds_one_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
canvas.palette = canvas.palette
canvas.save!
canvas.reload
canvas.palette.should == palette
expect(canvas.palette).to eq(palette)
end
end
end
Expand Down