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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use newer rspec .to format over .should #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/binary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
assert_creates(Pet, [{:name => name, :zipped_biography => zipped_biography}]) do
upsert.row({:name => name}, {:zipped_biography => Upsert.binary(zipped_biography)})
end
Zlib::Inflate.inflate(Pet.find_by_name(name).zipped_biography).should == biography
expect(Zlib::Inflate.inflate(Pet.find_by_name(name).zipped_biography)).to eq(biography)
end
end
end
Expand Down
28 changes: 14 additions & 14 deletions spec/correctness_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
u = Upsert.new($conn, :pets)
selector = {:name => 'Jerry', :tag_number => 6}
u.row(selector)
Pet.find_by_name('Jerry').tag_number.should == 5
expect(Pet.find_by_name('Jerry').tag_number).to eq(5)

# won't change anything because selector is wrong
u = Upsert.new($conn, :pets)
selector = {:name => 'Jerry', :tag_number => 10}
setter = { :tag_number => 5 }
u.row(selector, setter)
Pet.find_by_name('Jerry').tag_number.should == 5
expect(Pet.find_by_name('Jerry').tag_number).to eq(5)

u = Upsert.new($conn, :pets)
selector = { :name => 'Jerry' }
setter = { :tag_number => 10 }
u.row(selector, setter)
Pet.find_by_name('Jerry').tag_number.should == 10
expect(Pet.find_by_name('Jerry').tag_number).to eq(10)

u = Upsert.new($conn, :pets)
selector = { :name => 'Jerry', :tag_number => 10 }
setter = { :tag_number => 20 }
u.row(selector, setter)
Pet.find_by_name('Jerry').tag_number.should == 20
expect(Pet.find_by_name('Jerry').tag_number).to eq(20)
end

it "really limits its effects to the selector" do
Expand All @@ -39,34 +39,34 @@
p.gender = 'blue'
p.tag_number = 777
p.save!
Pet.find_by_name_and_gender('Jerry', 'blue').tag_number.should == 777
expect(Pet.find_by_name_and_gender('Jerry', 'blue').tag_number).to eq(777)
u = Upsert.new($conn, :pets)
selector = {:name => 'Jerry', :gender => 'red'} # this shouldn't select anything
setter = {:tag_number => 888}
u.row(selector, setter)
Pet.find_by_name_and_gender('Jerry', 'blue').tag_number.should == 777
expect(Pet.find_by_name_and_gender('Jerry', 'blue').tag_number).to eq(777)
end

# https://github.com/seamusabshere/upsert/issues/18
it "uses nil selectors" do
Pet.count.should == 0
expect(Pet.count).to eq(0)
now = Date.today
u = Upsert.new($conn, :pets)
5.times do
u.row(:gender => nil, :birthday => now)
end

Pet.count.should == 1
expect(Pet.count).to eq(1)
end

it "uses nil selectors on columns with date type" do
Pet.count.should == 0
expect(Pet.count).to eq(0)
u = Upsert.new($conn, :pets)
5.times do
u.row(:birthday => nil)
end

Pet.count.should == 1
expect(Pet.count).to eq(1)
end

it "uses nil selectors (another way of checking)" do
Expand All @@ -80,10 +80,10 @@

it "tells you if you request a column that doesn't exist" do
u = Upsert.new($conn, :pets)
lambda { u.row(:gibberish => 'ba') }.should raise_error(/invalid col/i)
lambda { u.row(:name => 'Jerry', :gibberish => 'ba') }.should raise_error(/invalid col/i)
lambda { u.row(:name => 'Jerry', :gibberish => 'ba') }.should raise_error(/invalid col/i)
lambda { u.row(:name => 'Jerry', :gibberish => 'ba', :gender => 'male') }.should raise_error(/invalid col/i)
expect { u.row(:gibberish => 'ba') }.to raise_error(/invalid col/i)
expect { u.row(:name => 'Jerry', :gibberish => 'ba') }.to raise_error(/invalid col/i)
expect { u.row(:name => 'Jerry', :gibberish => 'ba') }.to raise_error(/invalid col/i)
expect { u.row(:name => 'Jerry', :gibberish => 'ba', :gender => 'male') }.to raise_error(/invalid col/i)
end

end
Expand Down
10 changes: 5 additions & 5 deletions spec/database_functions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

io.rewind
hits = io.read.split("\n").grep(/Creating or replacing/)
hits.length.should == 2
expect(hits.length).to eq(2)
ensure
Upsert.logger = old_logger
end
Expand All @@ -42,7 +42,7 @@

io.rewind
hits = io.read.split("\n").grep(/Creating or replacing/)
hits.length.should == 2
expect(hits.length).to eq(2)
ensure
Upsert.logger = old_logger
end
Expand All @@ -65,7 +65,7 @@

io.rewind
hits = io.read.split("\n").grep(/Creating or replacing/)
hits.length.should == 1
expect(hits.length).to eq(1)
ensure
Upsert.logger = old_logger
end
Expand All @@ -88,8 +88,8 @@

io.rewind
lines = io.read.split("\n")
lines.grep(/went missing/).length.should == 1
lines.grep(/Creating or replacing/).length.should == 1
expect(lines.grep(/went missing/).length).to eq(1)
expect(lines.grep(/Creating or replacing/).length).to eq(1)
ensure
Upsert.logger = old_logger
end
Expand Down
8 changes: 4 additions & 4 deletions spec/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
upsert.row({:name => 'Jerry'}, {:gender => 'male'})
upsert.row({:name => 'Jerry'}, {:gender => 'neutered'})
end
Pet.where(:gender => 'male').count.should == 0
expect(Pet.where(:gender => 'male').count).to eq(0)
end
it "works for a single row with implicit nulls" do
upsert = Upsert.new $conn, :pets
Expand Down Expand Up @@ -72,8 +72,8 @@
upsert = Upsert.new $conn, :tasks
upsert.row({:id => task.id}, :name => 'Clean kitchen')
task.reload
task.created_at.should eql task.created_at
task.created_on.should eql task.created_on
expect(task.created_at).to eql task.created_at
expect(task.created_on).to eql task.created_on
end

it "converts symbol values to string" do
Expand Down Expand Up @@ -114,7 +114,7 @@
upsert.row({:name => 'Jerry'}, :gender => 'neutered')
end
end
Pet.where(:gender => 'male').count.should == 0
expect(Pet.where(:gender => 'male').count).to eq(0)
end
end
end
Expand Down
Loading