Skip to content

Instantly share code, notes, and snippets.

@gouf
Created March 10, 2014 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gouf/9457227 to your computer and use it in GitHub Desktop.
Save gouf/9457227 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment