Class: Autotest::Rspec2

### Home Classes Methods

### In Files

- lib/autotest/rspec2.rb

### Parent

Autotest

### Methods

- ::new
- #consolidate_failures
- #make_test_cmd
- #normalize
- #setup_rspec_project_mappings

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::BacktraceCleaner
- RSpec::Core::BacktraceFormatter
- RSpec::Core::CommandLine
- RSpec::Core::Configuration
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::ConstMissing
- RSpec::Core::DRbCommandLine
- RSpec::Core::DSL
- RSpec::Core::Deprecation
- RSpec::Core::DrbOptions
- RSpec::Core::Example
- RSpec::Core::Example::NotPendingExampleFixed
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::Extensions
- RSpec::Core::Extensions::InstanceEvalWithArgs
- RSpec::Core::Extensions::ModuleEvalWithArgs
- RSpec::Core::Extensions::Ordered
- RSpec::Core::Extensions::Ordered::ExampleGroups
- RSpec::Core::Extensions::Ordered::Examples
- RSpec::Core::FilterManager
- RSpec::Core::FilterManager::BackwardCompatibility
- RSpec::Core::FilterManager::Describable
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::Formatters::TextMateFormatter
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterAllHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::AroundHookCollection
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::GroupHookCollection
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollection
- RSpec::Core::Hooks::HookCollectionAliases
- RSpec::Core::Hooks::RegistersGlobals
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::BeforeAllMemoizedHash
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleMetadataHash
- RSpec::Core::Metadata::GroupMetadataHash
- RSpec::Core::Metadata::MetadataHash
- RSpec::Core::MetadataHashBuilder
- RSpec::Core::MetadataHashBuilder::Common
- RSpec::Core::MetadataHashBuilder::WithConfigWarning
- RSpec::Core::MetadataHashBuilder::WithDeprecationWarning
- RSpec::Core::MockFrameworkAdapter
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingDeclaredInExample
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Collection
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::World
- RSpec::Rake
- RSpec::Runner
- Autotest
- Autotest::Rspec2
- Kernel

No matching classes.

# Autotest::Rspec2

Derived from the `Autotest` class, extends the `autotest` command to work with RSpec.

@note this will be extracted to a separate gem when we release rspec-3.

### Constants

RSPEC_EXECUTABLE

### Public Class Methods

new() click to toggle source

    # File lib/autotest/rspec2.rb, line 12
    def initialize
      super()
      clear_mappings
      setup_rspec_project_mappings

      # Example for Ruby 1.8: http://rubular.com/r/AOXNVDrZpx
      # Example for Ruby 1.9: http://rubular.com/r/85ag5AZ2jP
      self.failed_results_re = /^\s*\d+\).*\n\s+(?:\e\[\d*m)?Failure.*(\n(?:\e\[\d*m)?\s+#\s(.*)?:\d+(?::.*)?(?:\e\[\d*m)?)+$/
      self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/
    end

### Public Instance Methods

consolidate_failures(failed) click to toggle source

Overrides Autotest's implementation to read rspec output

    # File lib/autotest/rspec2.rb, line 37
    def consolidate_failures(failed)
      filters = new_hash_of_arrays
      failed.each do |spec, trace|
        if trace =~ /(.*spec\.rb)/
          filters[$1] << spec
        end
      end
      return filters
    end

make_test_cmd(files_to_test) click to toggle source

Overrides Autotest's implementation to generate the rspec command to run

    # File lib/autotest/rspec2.rb, line 48
    def make_test_cmd(files_to_test)
      files_to_test.empty? ? '' :
        %#{prefix}"#{ruby}"#{suffix} -S "#{RSPEC_EXECUTABLE}" --tty #{normalize(files_to_test).keys.flatten.map { |f| %|"#{f}"|}.join(' ')}|
    end

normalize(files_to_test) click to toggle source

Generates a map of filenames to Arrays for Autotest

    # File lib/autotest/rspec2.rb, line 54
    def normalize(files_to_test)
      files_to_test.keys.inject({}) do |result, filename|
        result.merge!(File.expand_path(filename) => [])
      end
    end

setup_rspec_project_mappings() click to toggle source

Adds conventional spec-to-file mappings to Autotest configuation.

    # File lib/autotest/rspec2.rb, line 24
    def setup_rspec_project_mappings
      add_mapping(%^spec/.*_spec\.rb$%) { |filename, _|
        filename
      }
      add_mapping(%^lib/(.*)\.rb$%) { |_, m|
        ["spec/#{m[1]}_spec.rb"]
      }
      add_mapping(%^spec/(spec_helper|shared/.*)\.rb$%) {
        files_matching %^spec/.*_spec\.rb$%
      }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.