appacademy/prep-work — pull request #32 by twiz- (2014-08-16 22:28:47+00:00)
Title: add test case for 2 answers to the left selecting the nearest

I may be a little confused on best practices for testing; I'm not sure. i.e. this may be overkill.

In solving the first test problem in 00_nearest_integer and I wrote a method that gave me green for all of the written tests in the corresponding spec

```ruby
def nearest_larger(arr, idx)
test = arr.map do |element|
if element > arr[idx]
element
else
nil
end
end
test.find_index { |element| element != nil }
end
```

However, this method doesn't satisfy another reasonable scenario indicated in the test case I added in my PR.

```ruby
nearest_larger( [2, 6, 9, 4, 8], 3)

#would return 1 when it should return 2, but this method passes the spec as is.
```

In the real world would a developer be expected to write a spec that covers the basic cases for testing functionality and then when writing the actual methods account for less obvious cases (as I *didn't* in the method above)? Or should we be adding to the spec as I have here?

Looking for best practice, real-world answer here.Thanks!