spec/ghostable_spec.rb in tbpgr_utils-0.0.150 vs spec/ghostable_spec.rb in tbpgr_utils-0.0.151
- old
+ new
@@ -4,19 +4,19 @@
describe Ghostable do
context :ghost_method do
module Checkable
include Ghostable
- ghost_method /check_range_.*\?$/, :check_range do |method_name, *args, &block|
+ ghost_method(/check_range_.*\?$/, :check_range) do |method_name, *args, &block|
method_name.to_s =~ /(check_range_)(\d+)(_to_)(\d*)/
from = Regexp.last_match[2].to_i
to = Regexp.last_match[4].to_i
value = args.first
(from..to).include? value
end
- ghost_method /^contain_.*\?$/, :check_contain do |method_name, *args, &block|
+ ghost_method(/^contain_.*\?$/, :check_contain) do |method_name, *args, &block|
method_name.to_s =~ /^(contain_)(.*)(\?)/
word = Regexp.last_match[2]
value = args.first
value.include? word
end
@@ -29,21 +29,21 @@
cases = [
{
case_no: 1,
case_title: 'valid case',
klass: SampleChecker,
- methods: [:check_range_3_to_5?, :check_range_3_to_5? , :contain_hoge?, :contain_hoge?],
+ methods: [:check_range_3_to_5?, :check_range_3_to_5?, :contain_hoge?, :contain_hoge?],
values: [3, 6, 'testhogetest', 'testhigetest'],
- expecteds: [true, false, true, false],
+ expecteds: [true, false, true, false]
},
{
case_no: 2,
case_title: 'method_missing case',
klass: SampleChecker,
methods: [:not_match_method],
values: [nil],
expect_error: true
- },
+ }
]
cases.each do |c|
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
begin