Module: NsOptions::AssertMacros::MacroMethods
- Defined in:
- lib/ns-options/assert_macros.rb
Instance Method Summary collapse
- #have_namespaces(*namespaces) ⇒ Object (also: #have_namespace)
- #have_option(*args) ⇒ Object
- #have_options(*options) ⇒ Object
Instance Method Details
#have_namespaces(*namespaces) ⇒ Object Also known as: have_namespace
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ns-options/assert_macros.rb', line 14 def have_namespaces(*namespaces) called_from = caller.first macro_name = "have namespaces: #{namespaces.map{|ns| "'#{ns}'"}.join(', ')}" Assert::Macro.new(macro_name) do namespaces.each do |ns| should "have a namespace named '#{ns}'", called_from do assert subject.has_namespace?(ns) end end end end |
#have_option(*args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ns-options/assert_macros.rb', line 41 def have_option(*args) called_from = caller.first opt_name, type_class, rules = NsOptions::Option.args(args) test_name = [ "have an option: '#{opt_name}'", "of type '#{type_class}'", "with rules '#{rules.inspect}'" ].join(', ') Assert::Macro.new(test_name) do should test_name, called_from do # have assertions assert subject.has_option?(opt_name) opt = subject.__data__.[opt_name] assert_kind_of NsOptions::Option, opt # type_class assertions assert_equal type_class, opt.type_class # rules assertions assert_equal rules, opt.rules end end end |
#have_options(*options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ns-options/assert_macros.rb', line 28 def (*) called_from = caller.first macro_name = "have options: #{.map{|opt| "'#{opt}'"}.join(', ')}" Assert::Macro.new(macro_name) do .each do |opt| should "have an option named '#{opt}'", called_from do assert subject.has_option?(opt) end end end end |