Skip to content

Instantly share code, notes, and snippets.

@sulmanweb
Created May 19, 2018 21:00
Show Gist options
  • Save sulmanweb/844e9bf75464126acb4fd42df9a20b86 to your computer and use it in GitHub Desktop.
Save sulmanweb/844e9bf75464126acb4fd42df9a20b86 to your computer and use it in GitHub Desktop.
RSpec file for binary search
require 'binary_search'
RSpec.describe BinarySearch, "#sort_func" do
context "with array searches the required" do
it "searches!" do
binary_search = BinarySearch.new
expect(binary_search.search_func([1, 2, 3, 4, 5, 6, 7, 8], 5)).to eql 4
end
it "return string if not found" do
binary_search = BinarySearch.new
expect(binary_search.search_func([1, 2, 3, 4, 5, 6, 7, 8], 9)).to eql "Value not found in array"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment