moduleRspecmoduleCoreclassConfiguration# All of the defined advice in the configuration (before/after/around)attr_reader:advice# Allows you to control what examples are ran by filtering attr_reader:filterattr_reader:exclusion_filter# Modules that will be included or extended based on given filtersattr_reader:include_or_extend_modules# Run all examples if the run is filtered, and no examples were found. Normally this is what you want -# when using focused examples for instance. Defaults to trueattr_accessor:run_all_when_everything_filteredattr_reader:optionsdefinitialize@run_all_when_everything_filtered=false@advice={:before=>{:each=>[],:all=>[],:suite=>[]},:after=>{:each=>[],:all=>[],:suite=>[]}}@include_or_extend_modules=[]@filter,@exclusion_filter=nil,nil@options=default_optionsenddefdefault_options{:color_enabled=>false,:mock_framework=>nil,:profile_examples=>false,:files_to_run=>[],:filename_pattern=>'**/*_spec.rb',:formatter_class=>Rspec::Core::Formatters::ProgressFormatter,:backtrace_clean_patterns=>[/\/lib\/ruby\//,/bin\/rcov:/,/vendor\/rails/,/bin\/rspec/,/bin\/spec/,/lib\/rspec\/(core|expectations|matchers|mocks)/]}enddefcleaned_from_backtrace?(line)options[:backtrace_clean_patterns].any?{|regex|line=~regex}enddefbacktrace_clean_patternsoptions[:backtrace_clean_patterns]enddefmock_framework=(use_me_to_mock)options[:mock_framework]=use_me_to_mockmock_framework_class=caseuse_me_to_mock.to_swhen/rspec/irequire'rspec/core/mocking/with_rspec'Rspec::Core::Mocking::WithRspecwhen/mocha/irequire'rspec/core/mocking/with_mocha'Rspec::Core::Mocking::WithMochawhen/rr/irequire'rspec/core/mocking/with_rr'Rspec::Core::Mocking::WithRRwhen/flexmock/irequire'rspec/core/mocking/with_flexmock'Rspec::Core::Mocking::WithFlexmockelserequire'rspec/core/mocking/with_absolutely_nothing'Rspec::Core::Mocking::WithAbsolutelyNothingendoptions[:mock_framework_class]=mock_framework_classRspec::Core::ExampleGroup.send(:include,mock_framework_class)enddefmock_frameworkoptions[:mock_framework]enddeffilename_patternoptions[:filename_pattern]enddeffilename_pattern=(new_pattern)options[:filename_pattern]=new_patternenddefcolor_enabled=(on_or_off)options[:color_enabled]=on_or_offenddeffull_backtrace=(bool)@options[:backtrace_clean_patterns].clearenddefdebug=(bool)returnunlessboolbeginrequire'ruby-debug'rescueLoadErrorraise<<-EOM#{'*'*50}
You must install ruby-debug to run rspec with the --debug option.
If you have ruby-debug installed as a ruby gem, then you need to either
require 'rubygems' or configure the RUBYOPT environment variable with
the value 'rubygems'.
#{'*'*50}EOMendenddefcolor_enabled?options[:color_enabled]enddefline_number=(line_number)filter_run:line_number=>line_number.to_ienddeffull_description=(description)filter_run:full_description=>/#{description}/end# Enable profiling of example run - defaults to falsedefprofile_examplesoptions[:profile_examples]enddefprofile_examples=(on_or_off)options[:profile_examples]=on_or_offenddefformatter_classoptions[:formatter_class]enddefformatter=(formatter_to_use)formatter_class=caseformatter_to_use.to_swhen/doc/,'s','n'Rspec::Core::Formatters::DocumentationFormatterwhen'progress'Rspec::Core::Formatters::ProgressFormatterelseraiseArgumentError,"Formatter '#{formatter_to_use}' unknown - maybe you meant 'documentation' or 'progress'?."endoptions[:formatter_class]=formatter_classenddefformatter@formatter||=formatter_class.newenddeffiles_to_runoptions[:files_to_run]enddeffiles_or_directories_to_run=(*files)options[:files_to_run]=files.flatten.inject([])do|result,file|ifFile.directory?(file)filename_pattern.split(",").eachdo|pattern|result+=Dir["#{file}/#{pattern.strip}"]endelsepath,line_number=file.split(':')self.line_number=line_numberifline_numberresult<<pathendresultendend# E.g. alias_example_to :crazy_slow, :speed => 'crazy_slow' defines# crazy_slow as an example variant that has the crazy_slow speed optiondefalias_example_to(new_name,extra_options={})Rspec::Core::ExampleGroup.alias_example_to(new_name,extra_options)enddefautorun!Rspec::Core::Runner.autorunenddeffilter_run(options={})@filter=optionsunless@filterand@filter[:line_number]||@filter[:full_description]enddefrun_all_when_everything_filtered?@run_all_when_everything_filteredend# Where does output go? For now $stdoutdefoutput$stdoutenddefputs(msg='')output.puts(msg)enddefparse_command_line_args(args)@command_line_options=Rspec::Core::CommandLineOptions.parse(args)enddefinclude(mod,options={})include_or_extend_modules<<[:include,mod,options]enddefextend(mod,options={})include_or_extend_modules<<[:extend,mod,options]enddeffind_modules(group)include_or_extend_modules.selectdo|include_or_extend,mod,filters|group.all_apply?(filters)endenddefbefore(each_or_all=:each,options={},&block)advice[:before][each_or_all]<<[options,block]enddefafter(each_or_all=:each,options={},&block)advice[:after][each_or_all]<<[options,block]enddeffind_advice(desired_advice_type,desired_each_or_all,group)advice[desired_advice_type][desired_each_or_all].selectdo|filters,block|group.all_apply?(filters)end.map{|filters,block|block}endendendend