So my idea for this class is to go through project euler problems in ruby, python and javascript and utilize object oriented design and a testing framework for each language. This week I did problem 1 in ruby using rspec. I wrote the tests first then created the class that made them pass. Then I refactored a little bit and made a test-program that solved the problem using my class. I'd like to do something similar with jasmine and javascript and pytest or something similar with python. Heres my console output running 1 failing test and making it pass:
ruby rspec
..F
Failures:
1) Euler_1#add_divisible_numbers adds all the numbers divisble by 3 and 5
Failure/Error: :example.divisible_by_3_or_5
NoMethodError:
undefined method `divisible_by_3_or_5' for :example:Symbol
# ./spec/euler_1_spec.rb:20:in `block (3 levels) in <top (required)>'
Finished in 0.00492 seconds (files took 0.10805 seconds to load)
3 examples, 1 failure
Failed examples:
rspec ./spec/euler_1_spec.rb:19 # Euler_1#add_divisible_numbers adds all the numbers divisble by 3 and 5
➜ ruby rspec
...
Finished in 0.00635 seconds (files took 0.10879 seconds to load)
3 examples, 0 failures
Here's my console output running the test program:
>> ruby ruby euler_1_test.rb
the sum of all the numbers divisble by 3 or 5 under 1000 is 233168