-
-
Save mhriess/3916266 to your computer and use it in GitHub Desktop.
Rspec Binary Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'simplecov' | |
SimpleCov.start | |
require './binary_search.rb' | |
describe "#binary_search" do | |
let(:array_1) { [1,2,3,4,5,6,7] } | |
let(:array_2) { ["apple", "pear", "banana", "pineapple", "kiwi"].sort} | |
it "is defined as a method" do | |
defined?(binary_search).should eq 'method' | |
end | |
it "requires two arguments" do | |
method(:binary_search).arity.should eq 2 | |
end | |
it "returns the correct value for a simple array of numbers" do | |
binary_search(4, array_1).should eq 3 | |
end | |
it "returns the correct value for an array of strings" do | |
binary_search("pear", array_2).should eq 3 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment