Class: Transpec::Syntax::RSpecConfigure::FrameworkConfiguration
- Inherits:
-
Object
- Object
- Transpec::Syntax::RSpecConfigure::FrameworkConfiguration
- Includes:
- AST::Sexp
- Defined in:
- lib/transpec/syntax/rspec_configure.rb
Instance Method Summary collapse
-
#initialize(rspec_configure_node, framework_config_method_name, source_rewriter) ⇒ FrameworkConfiguration
constructor
A new instance of FrameworkConfiguration.
- #modify_syntaxes!(syntaxes) ⇒ Object
- #syntaxes ⇒ Object
Constructor Details
#initialize(rspec_configure_node, framework_config_method_name, source_rewriter) ⇒ FrameworkConfiguration
Returns a new instance of FrameworkConfiguration.
13 14 15 16 17 |
# File 'lib/transpec/syntax/rspec_configure.rb', line 13 def initialize(rspec_configure_node, framework_config_method_name, source_rewriter) @rspec_configure_node = rspec_configure_node @framework_config_method_name = framework_config_method_name @source_rewriter = source_rewriter end |
Instance Method Details
#modify_syntaxes!(syntaxes) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/transpec/syntax/rspec_configure.rb', line 34 def modify_syntaxes!(syntaxes) unless [Array, Symbol].include?(syntaxes.class) fail ArgumentError, 'Syntaxes must be either an array or a symbol.' end @source_rewriter.replace(syntaxes_node.loc.expression, syntaxes.inspect) end |
#syntaxes ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/transpec/syntax/rspec_configure.rb', line 19 def syntaxes return [] unless syntaxes_node case syntaxes_node.type when :sym [syntaxes_node.children.first] when :array syntaxes_node.children.map do |child_node| child_node.children.first end else fail end end |