gouf
3/10/2014 - 12:18 AM

RSpec での量産型テストのれんしゅう。

RSpec での量産型テストのれんしゅう。

require 'spec_helper'

describe "always divisible by 9" do
  (1..100).each do |x|
    first = x.to_s[0]
    last  = x.to_s[1]
    next if first == last
    next if first.nil? or last.nil?
    swap_x = (last + first).to_i
    new_x = (x - swap_x).abs
    it "is #{x}: #{new_x} / 9 is 0" do
      result = new_x % 9
      expect(result).to eq 0
    end
  end
end