Class: GenSpec::Matchers::Base
- Inherits:
-
Object
- Object
- GenSpec::Matchers::Base
- Defined in:
- lib/genspec/matchers/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#destination_root ⇒ Object
readonly
Returns the value of attribute destination_root.
-
#error ⇒ Object
Returns the value of attribute error.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
-
#init_blocks ⇒ Object
readonly
Returns the value of attribute init_blocks.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(&block) ⇒ Base
constructor
A new instance of Base.
- #match! ⇒ Object
- #matched? ⇒ Boolean
- #matches?(generator) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #source_root ⇒ Object
Constructor Details
#initialize(&block) ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/genspec/matchers/base.rb', line 12 def initialize(&block) @block = block if block_given? @matched = false end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/genspec/matchers/base.rb', line 4 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/genspec/matchers/base.rb', line 4 def block @block end |
#destination_root ⇒ Object (readonly)
Returns the value of attribute destination_root.
5 6 7 |
# File 'lib/genspec/matchers/base.rb', line 5 def destination_root @destination_root end |
#error ⇒ Object
Returns the value of attribute error.
6 7 8 |
# File 'lib/genspec/matchers/base.rb', line 6 def error @error end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
4 5 6 |
# File 'lib/genspec/matchers/base.rb', line 4 def generator @generator end |
#init_blocks ⇒ Object (readonly)
Returns the value of attribute init_blocks.
4 5 6 |
# File 'lib/genspec/matchers/base.rb', line 4 def init_blocks @init_blocks end |
Instance Method Details
#failure_message ⇒ Object
52 53 54 |
# File 'lib/genspec/matchers/base.rb', line 52 def "was supposed to match and didn't" end |
#match! ⇒ Object
17 18 19 |
# File 'lib/genspec/matchers/base.rb', line 17 def match! @matched = true end |
#matched? ⇒ Boolean
48 49 50 |
# File 'lib/genspec/matchers/base.rb', line 48 def matched? @matched end |
#matches?(generator) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/genspec/matchers/base.rb', line 21 def matches?(generator) @described = generator[:described] @args = generator[:args] @generator_options = generator[:generator_options] @shell = GenSpec::Shell.new(generator[:output] || "", generator[:input] || "") @init_blocks = generator[:init_blocks] if @described.kind_of?(Class) @generator = @described else if defined?(Rails) @generator = Rails::Generators.find_by_namespace(@described) else @generator = Thor::Util.find_by_namespace(@described) end end raise "Could not find generator: #{@described.inspect}" unless @generator inject_error_handlers! invoking invoke matched? ensure complete end |
#negative_failure_message ⇒ Object
56 57 58 |
# File 'lib/genspec/matchers/base.rb', line 56 def "was supposed to not match and did" end |
#source_root ⇒ Object
8 9 10 |
# File 'lib/genspec/matchers/base.rb', line 8 def source_root generator.source_root end |