闰年是否自动检测

新增一个档案 leap_year.rb
touch leap_year.rb

新增一个档案 .rspec
touch .rspec

新增一个档案 leap_year_spec.rb
touch leap_year spec.rb

liudezhi@ip-192-168-43-20 leap_year % irb
2.6.2 :001 > require_relative './leap_year'
is_leap_year?(2016)   # => 应该得到 true
is_leap_year?(2017)   # => 应该得到 false
Traceback (most recent call last):
        5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):1 1: from (irb):1:in `require_relative' LoadError (cannot load such file -- /Users/liudezhi/leap_year/leap_year) Traceback (most recent call last): 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):2 1: from (irb):2:in `rescue in irb_binding' NoMethodError (undefined method `is_leap_year?' for main:Object) Traceback (most recent call last): 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):3 1: from (irb):3:in `rescue in irb_binding' NoMethodError (undefined method `is_leap_year?' for main:Object) 2.6.2 :004 > require_relative './leap_year' Traceback (most recent call last): 6: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 3: from (irb):4 2: from (irb):4:in `rescue in irb_binding' 1: from (irb):4:in `require_relative' LoadError (cannot load such file -- /Users/liudezhi/leap_year/leap_year) 2.6.2 :005 > exit liudezhi@ip-192-168-43-20 leap_year % irb 2.6.2 :001 > require_relative './leap_year' Traceback (most recent call last): 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):1 1: from (irb):1:in `require_relative' LoadError (cannot load such file -- /Users/liudezhi/leap_year/leap_year) 2.6.2 :002 > 1+2 => 3 2.6.2 :003 > require_relative './leap_year' is_leap_year?(2016) # => 应该得到 true Traceback (most recent call last): 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):3 1: from (irb):3:in `require_relative' LoadError (cannot load such file -- /Users/liudezhi/leap_year/leap_year) Traceback (most recent call last): 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):4 1: from (irb):4:in `rescue in irb_binding' NoMethodError (undefined method `is_leap_year?' for main:Object) 2.6.2 :005 > exit liudezhi@ip-192-168-43-20 leap_year % gem install rspec Fetching rspec-3.10.0.gem Fetching rspec-support-3.10.2.gem Fetching rspec-mocks-3.10.2.gem Fetching rspec-core-3.10.1.gem Fetching diff-lcs-1.4.4.gem Fetching rspec-expectations-3.10.1.gem Successfully installed rspec-support-3.10.2 Successfully installed rspec-core-3.10.1 Successfully installed diff-lcs-1.4.4 Successfully installed rspec-expectations-3.10.1 Successfully installed rspec-mocks-3.10.2 Successfully installed rspec-3.10.0 Parsing documentation for rspec-support-3.10.2 Installing ri documentation for rspec-support-3.10.2 Parsing documentation for rspec-core-3.10.1 Installing ri documentation for rspec-core-3.10.1 Parsing documentation for diff-lcs-1.4.4 Installing ri documentation for diff-lcs-1.4.4 Parsing documentation for rspec-expectations-3.10.1 Installing ri documentation for rspec-expectations-3.10.1 Parsing documentation for rspec-mocks-3.10.2 Installing ri documentation for rspec-mocks-3.10.2 Parsing documentation for rspec-3.10.0 Installing ri documentation for rspec-3.10.0 Done installing documentation for rspec-support, rspec-core, diff-lcs, rspec-expectations, rspec-mocks, rspec after 5 seconds 6 gems installed liudezhi@ip-192-168-43-20 leap_year % rails g controller .rspec Running via Spring preloader in process 66128 Traceback (most recent call last): 37: from -e:1:in `
' 36: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 35: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 34: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:285:in `load' 33: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:257:in `load_dependency' 32: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:285:in `block in load' 31: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load' 30: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load' 29: from /Users/liudezhi/leap_year/bin/rails:9:in `
' 28: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `require' 27: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:257:in `load_dependency' 26: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `block in require' 25: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' 24: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' 23: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' 22: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' 21: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' 20: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/commands.rb:18:in `
' 19: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/command.rb:46:in `invoke' 18: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/command/base.rb:69:in `perform' 17: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch' 16: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command' 15: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/command.rb:27:in `run' 14: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/commands/generate/generate_command.rb:26:in `perform' 13: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/generators.rb:276:in `invoke' 12: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/base.rb:485:in `start' 11: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/group.rb:232:in `dispatch' 10: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `invoke_all' 9: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `map' 8: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `each' 7: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `block in invoke_all' 6: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command' 5: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/thor-1.1.0/lib/thor/command.rb:27:in `run' 4: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/generators/named_base.rb:226:in `block in check_class_collision' 3: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/generators/base.rb:258:in `class_collisions' 2: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/generators/base.rb:258:in `each' 1: from /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/generators/base.rb:267:in `block in class_collisions' /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/railties-5.2.6/lib/rails/generators/base.rb:267:in `const_defined?': wrong constant name .rspecController (NameError) liudezhi@ip-192-168-43-20 leap_year % rails g controller leap_year_spec Running via Spring preloader in process 66217 create app/controllers/leap_year_spec_controller.rb invoke erb create app/views/leap_year_spec invoke test_unit create test/controllers/leap_year_spec_controller_test.rb invoke helper create app/helpers/leap_year_spec_helper.rb invoke test_unit invoke assets invoke coffee create app/assets/javascripts/leap_year_spec.coffee invoke scss create app/assets/stylesheets/leap_year_spec.scss liudezhi@ip-192-168-43-20 leap_year % .rspec zsh: command not found: .rspec liudezhi@ip-192-168-43-20 leap_year % rails g .rspec Running via Spring preloader in process 66607 Could not find generator '.rspec'. Maybe you meant 'helper', 'model' or 'task' Run `rails generate --help` for more options. liudezhi@ip-192-168-43-20 leap_year % rails g controller rails g rspec Running via Spring preloader in process 66803 create app/controllers/rails_controller.rb route get 'rails/g' get 'rails/rspec' invoke erb create app/views/rails create app/views/rails/g.html.erb create app/views/rails/rspec.html.erb invoke test_unit create test/controllers/rails_controller_test.rb invoke helper create app/helpers/rails_helper.rb invoke test_unit invoke assets invoke coffee create app/assets/javascripts/rails.coffee invoke scss create app/assets/stylesheets/rails.scss liudezhi@ip-192-168-43-20 leap_year % gem install rspec Successfully installed rspec-3.10.0 Parsing documentation for rspec-3.10.0 Done installing documentation for rspec after 0 seconds 1 gem installed liudezhi@ip-192-168-43-20 leap_year % rspec leap_year_spec.rb An error occurred while loading ./leap_year_spec.rb. Failure/Error: __send__(method, file) LoadError: cannot load such file -- /Users/liudezhi/leap_year/leap_year_spec.rb # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load_file_handling_errors' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1615:in `block in load_spec_files' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `each' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `load_spec_files' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:102:in `setup' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:86:in `run' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/exe/rspec:4:in `' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/rspec:23:in `load' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/rspec:23:in `
' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/ruby_executable_hooks:24:in `eval' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/ruby_executable_hooks:24:in `
' # # Showing full backtrace because every line was filtered out. # See docs for RSpec::Configuration#backtrace_exclusion_patterns and # RSpec::Configuration#backtrace_inclusion_patterns for more information. No examples found. Finished in 0.00008 seconds (files took 0.27117 seconds to load) 0 examples, 0 failures, 1 error occurred outside of examples liudezhi@ip-192-168-43-20 leap_year % rspec leap_year_spec.rb An error occurred while loading ./leap_year_spec.rb. Failure/Error: __send__(method, file) LoadError: cannot load such file -- /Users/liudezhi/leap_year/leap_year_spec.rb # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load_file_handling_errors' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1615:in `block in load_spec_files' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `each' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `load_spec_files' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:102:in `setup' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:86:in `run' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/exe/rspec:4:in `' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/rspec:23:in `load' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/rspec:23:in `
' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/ruby_executable_hooks:24:in `eval' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/ruby_executable_hooks:24:in `
' # # Showing full backtrace because every line was filtered out. # See docs for RSpec::Configuration#backtrace_exclusion_patterns and # RSpec::Configuration#backtrace_inclusion_patterns for more information. No examples found. Finished in 0.00007 seconds (files took 0.25665 seconds to load) 0 examples, 0 failures, 1 error occurred outside of examples liudezhi@ip-192-168-43-20 leap_year % gem install rspec Successfully installed rspec-3.10.0 Parsing documentation for rspec-3.10.0 Done installing documentation for rspec after 0 seconds 1 gem installed liudezhi@ip-192-168-43-20 leap_year % touch app/.rspec liudezhi@ip-192-168-43-20 leap_year % touch .rspec liudezhi@ip-192-168-43-20 leap_year % rspec leap_year_spec.rb An error occurred while loading ./leap_year_spec.rb. Failure/Error: __send__(method, file) LoadError: cannot load such file -- /Users/liudezhi/leap_year/leap_year_spec.rb # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load_file_handling_errors' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1615:in `block in load_spec_files' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `each' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1613:in `load_spec_files' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:102:in `setup' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:86:in `run' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/gems/rspec-core-3.10.1/exe/rspec:4:in `' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/rspec:23:in `load' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/rspec:23:in `
' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/ruby_executable_hooks:24:in `eval' # /Users/liudezhi/.rvm/gems/ruby-2.6.2/bin/ruby_executable_hooks:24:in `
' # # Showing full backtrace because every line was filtered out. # See docs for RSpec::Configuration#backtrace_exclusion_patterns and # RSpec::Configuration#backtrace_inclusion_patterns for more information. No examples found. Finished in 0.00006 seconds (files took 0.26043 seconds to load) 0 examples, 0 failures, 1 error occurred outside of examples liudezhi@ip-192-168-43-20 leap_year % touch app/leap_year liudezhi@ip-192-168-43-20 leap_year % touch app/leap_year.rb liudezhi@ip-192-168-43-20 leap_year % irb 2.6.2 :001 > require_relative './leap_year' Traceback (most recent call last): 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):1 1: from (irb):1:in `require_relative' LoadError (cannot load such file -- /Users/liudezhi/leap_year/leap_year) 2.6.2 :002 > exit liudezhi@ip-192-168-43-20 leap_year % irb 2.6.2 :001 > require_relative './leap_year' Traceback (most recent call last): 5: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `
' 4: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/bin/irb:23:in `load' 3: from /Users/liudezhi/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `' 2: from (irb):1 1: from (irb):1:in `require_relative' LoadError (cannot load such file -- /Users/liudezhi/leap_year/leap_year) 2.6.2 :003 > exit liudezhi@ip-192-168-43-20 leap_year % touch leap_year_spec.rb liudezhi@ip-192-168-43-20 leap_year % touch leap_year.rb liudezhi@ip-192-168-43-20 leap_year % irb 2.6.2 :001 > exit liudezhi@ip-192-168-43-20 leap_year % rspec leap_year_spec.rb Leap Year 2016 is leap year 2017 is common year 2100 is common year 2400 is leap year (FAILED - 1) Failures: 1) Leap Year 2400 is leap year Failure/Error: expect(result).to eq(true) # 检查结果应该要是 true expected: true got: false (compared using ==) Diff: @@ -1 +1 @@ -true +false # ./leap_year_spec.rb:28:in `block (2 levels) in ' Finished in 0.02836 seconds (files took 0.24443 seconds to load) 4 examples, 1 failure Failed examples: rspec ./leap_year_spec.rb:25 # Leap Year 2400 is leap year
Last login: Mon Jun 14 12:07:52 on ttys004
liudezhi@Udizy ~ % cd leap_year
liudezhi@Udizy leap_year % irb
2.6.2 :001 > require_relative './leap_year'
 => true 
2.6.2 :002 > is_leap_year?(2016)
 => true 
2.6.2 :003 > is_leap_year?(2017)
 => false 
2.6.2 :004 > is_leap_year?(2100)
 => false 
2.6.2 :005 > 
liudezhi@Udizy leap_year % rspec leap_year_spec.rb

Leap Year
  2016 is leap year
  2017 is common year
  2100 is common year
  2400 is leap year

Finished in 0.00365 seconds (files took 0.18763 seconds to load)
4 examples, 0 failures

liudezhi@Udizy leap_year %

你可能感兴趣的:(闰年是否自动检测)