@private Used internally to clear remaining groups when fail_fast is set
# File lib/rspec/core.rb, line 99 99: def self.clear_remaining_example_groups 100: world.example_groups.clear 101: end
Returns the global [Configuration](RSpec/Core/Configuration) object. While you can use this method to access the configuration, the more common convention is to use [RSpec.configure](RSpec#configure-class_method).
@example
RSpec.configuration.drb_port = 1234
@see RSpec.configure @see Core::Configuration
# File lib/rspec/core.rb, line 81 81: def self.configuration 82: @configuration ||= RSpec::Core::Configuration.new 83: end
Yields the global configuration to a block. @yield [Configuration] global configuration
@example
RSpec.configure do |config| config.add_formatter 'documentation' end
@see Core::Configuration
# File lib/rspec/core.rb, line 93 93: def self.configure 94: yield configuration if block_given? 95: end
@private
Used internally to print deprecation warnings
# File lib/rspec/core/deprecation.rb, line 6 6: def deprecate(method, alternate_method=nil, version=nil) 7: version_string = version ? "rspec-#{version}" : "a future version of RSpec" 8: 9: message = *****************************************************************DEPRECATION WARNING: you are using deprecated behaviour that willbe removed from #{version_string}.#{caller(0)[2]}* #{method} is deprecated. 10: if alternate_method 11: message << * please use #{alternate_method} instead. 12: end 13: 14: message << "*****************************************************************" 15: warn_deprecation(message) 16: end
@private Used internally to ensure examples get reloaded between multiple runs in the same process.
# File lib/rspec/core.rb, line 68 68: def self.reset 69: @world = nil 70: @configuration = nil 71: end
@private
# File lib/rspec/core.rb, line 48 48: def self.wants_to_quit 49: # Used internally to determine what to do when a SIGINT is received 50: world.wants_to_quit 51: end
@private Used internally to determine what to do when a SIGINT is received
# File lib/rspec/core.rb, line 55 55: def self.wants_to_quit=(maybe) 56: world.wants_to_quit=(maybe) 57: end
@private
# File lib/rspec/core/configuration.rb, line 738 738: def configure_expectation_framework 739: expectation_frameworks.each do |framework| 740: RSpec::Core::ExampleGroup.send(:include, framework) 741: end 742: end
@private
# File lib/rspec/core/configuration.rb, line 733 733: def configure_mock_framework 734: RSpec::Core::ExampleGroup.send(:include, mock_framework) 735: end
@private
# File lib/rspec/core/configuration.rb, line 745 745: def load_spec_files 746: files_to_run.uniq.map {|f| load File.expand_path(f) } 747: raise_if_rspec_1_is_loaded 748: end
@api
Sets the order and, if order is `’rand:
# File lib/rspec/core/configuration.rb, line 760 760: def order=(type) 761: order_and_seed_from_order(type) 762: end
# File lib/rspec/core/configuration.rb, line 799 799: def assert_no_example_groups_defined(config_option) 800: if RSpec.world.example_groups.any? 801: raise MustBeConfiguredBeforeExampleGroupsError.new( 802: "RSpec's #{config_option} configuration option must be configured before " + 803: "any example groups are defined, but you have already defined a group." 804: ) 805: end 806: end
# File lib/rspec/core/configuration.rb, line 832 832: def built_in_formatter(key) 833: case key.to_s 834: when 'd', 'doc', 'documentation', 's', 'n', 'spec', 'nested' 835: require 'rspec/core/formatters/documentation_formatter' 836: RSpec::Core::Formatters::DocumentationFormatter 837: when 'h', 'html' 838: require 'rspec/core/formatters/html_formatter' 839: RSpec::Core::Formatters::HtmlFormatter 840: when 't', 'textmate' 841: require 'rspec/core/formatters/text_mate_formatter' 842: RSpec::Core::Formatters::TextMateFormatter 843: when 'p', 'progress' 844: require 'rspec/core/formatters/progress_formatter' 845: RSpec::Core::Formatters::ProgressFormatter 846: end 847: end
# File lib/rspec/core/configuration.rb, line 791 791: def command 792: $0.split(File::SEPARATOR).last 793: end
# File lib/rspec/core/configuration.rb, line 849 849: def custom_formatter(formatter_ref) 850: if Class === formatter_ref 851: formatter_ref 852: elsif string_const?(formatter_ref) 853: begin 854: eval(formatter_ref) 855: rescue NameError 856: require path_for(formatter_ref) 857: eval(formatter_ref) 858: end 859: end 860: end
# File lib/rspec/core/configuration.rb, line 783 783: def extract_location(path) 784: if path =~ /^(.*?)((?:\:\d+)+)$/ 785: path, lines = $1, $2[1..1].split(":").map{|n| n.to_i} 786: filter_manager.add_location path, lines 787: end 788: path 789: end
# File lib/rspec/core/configuration.rb, line 885 885: def file_at(path) 886: FileUtils.mkdir_p(File.dirname(path)) 887: File.new(path, 'w') 888: end
# File lib/rspec/core/configuration.rb, line 777 777: def gather_directories(path, patterns) 778: patterns.map do |pattern| 779: pattern =~ /^#{path}/ ? Dir[pattern.strip] : Dir["#{path}/{#{pattern.strip}}"] 780: end 781: end
# File lib/rspec/core/configuration.rb, line 770 770: def get_files_to_run(paths) 771: patterns = pattern.split(",") 772: paths.map do |path| 773: File.directory?(path) ? gather_directories(path, patterns) : extract_location(path) 774: end.flatten 775: end
# File lib/rspec/core/configuration.rb, line 899 899: def order_and_seed_from_order(type) 900: order, seed = type.to_s.split(':') 901: @order = order 902: @seed = seed = seed.to_i if seed 903: @order, @seed = nil, nil if order == 'default' 904: return order, seed 905: end
# File lib/rspec/core/configuration.rb, line 890 890: def order_and_seed_from_seed(value) 891: @order, @seed = 'rand', value.to_i 892: end
# File lib/rspec/core/configuration.rb, line 824 824: def output_to_tty? 825: begin 826: output_stream.tty? || tty? 827: rescue NoMethodError 828: false 829: end 830: end
# File lib/rspec/core/configuration.rb, line 866 866: def path_for(const_ref) 867: underscore_with_fix_for_non_standard_rspec_naming(const_ref) 868: end
# File lib/rspec/core/configuration.rb, line 808 808: def raise_if_rspec_1_is_loaded 809: if defined?(Spec) && defined?(Spec::VERSION::MAJOR) && Spec::VERSION::MAJOR == 1 810: raise #{'*'*80} You are running rspec-2, but it seems as though rspec-1 has been loaded as well. This is likely due to a statement like this somewhere in the specs: require 'spec' Please locate that statement, remove it, and try again.#{'*'*80} 811: end 812: end
# File lib/rspec/core/configuration.rb, line 894 894: def set_order_and_seed(hash) 895: hash[:order], seed = order_and_seed_from_order(hash[:order]) 896: hash[:seed] = seed if seed 897: end
# File lib/rspec/core/configuration.rb, line 862 862: def string_const?(str) 863: str.is_a?(String) && /\A[A-Z][a-zA-Z0-9_:]*\z/ =~ str 864: end
activesupport/lib/active_support/inflector/methods.rb, line 48
# File lib/rspec/core/configuration.rb, line 875 875: def underscore(camel_cased_word) 876: word = camel_cased_word.to_s.dup 877: word.gsub!(/::/, '/') 878: word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') 879: word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') 880: word.tr!("-", "_") 881: word.downcase! 882: word 883: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.