Module: Test::Spec::Rails::Macros::ClassMethods
- Defined in:
- lib/test/spec/rails/macros.rb
Instance Method Summary collapse
-
#known_fixture?(name) ⇒ Boolean
Returns true when the passed name is a known table, we assume known tables also have fixtures.
-
#method_missing(method, *arguments, &block) ⇒ Object
Filter calls to fixture methods so we can use them in the definitions.
-
#should ⇒ Object
Returns an instance of the Should class, this allows you to call macros from the test case is a nice way:.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
Filter calls to fixture methods so we can use them in the definitions
41 42 43 44 45 46 47 48 |
# File 'lib/test/spec/rails/macros.rb', line 41 def method_missing(method, *arguments, &block) if known_fixture?(method) arguments = arguments.map { |a| a.inspect } Test::Spec::Rails::Macros::LazyValue.new("#{method}(#{arguments.join(', ')})") else super end end |
Instance Method Details
#known_fixture?(name) ⇒ Boolean
Returns true when the passed name is a known table, we assume known tables also have fixtures
36 37 38 |
# File 'lib/test/spec/rails/macros.rb', line 36 def known_fixture?(name) respond_to?(:fixture_table_names) && fixture_table_names.include?(name.to_s) end |