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
39 40 41 42 43 44 45 46 |
# File 'lib/test/spec/rails/macros.rb', line 39 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
34 35 36 |
# File 'lib/test/spec/rails/macros.rb', line 34 def known_fixture?(name) respond_to?(:fixture_table_names) && fixture_table_names.include?(name.to_s) end |