Skip to content

Instantly share code, notes, and snippets.

@sulmanweb
Created May 20, 2018 05:55
Show Gist options
  • Save sulmanweb/3aaf780aadd516bbe501e6ff07391c4e to your computer and use it in GitHub Desktop.
Save sulmanweb/3aaf780aadd516bbe501e6ff07391c4e to your computer and use it in GitHub Desktop.
Find fixed point algorithm spec file
RSpec.describe BinarySearch, "#find_fixed_point" do
context "should have a sorted array" do
it "searches for the fixed point" do
binary_search = BinarySearch.new
expect(binary_search.find_fixed_point([0, 2, 3, 4, 5, 6, 7, 8])).to eql 0
expect(binary_search.find_fixed_point([0, 1, 2, 4, 5, 6, 7, 8])).to eql 2
end
it "returns -1 if not found" do
binary_search = BinarySearch.new
expect(binary_search.find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8])).to eql -1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment