Class: Micronaut::Configuration
- Defined in:
- lib/micronaut/configuration.rb
Instance Attribute Summary collapse
-
#backtrace_clean_patterns ⇒ Object
readonly
Regex patterns to scrub backtrace with.
-
#before_and_afters ⇒ Object
readonly
All of the defined before/after blocks setup in the configuration.
-
#filter ⇒ Object
readonly
Allows you to control what examples are ran by filtering.
-
#include_or_extend_modules ⇒ Object
readonly
Modules that will be included or extended based on given filters.
-
#mock_framework ⇒ Object
readonly
Returns the value of attribute mock_framework.
-
#profile_examples ⇒ Object
Enable profiling of example run - defaults to false.
-
#run_all_when_everything_filtered ⇒ Object
Run all examples if the run is filtered, and no examples were found - defaults to true.
Instance Method Summary collapse
- #after(each_or_all = :each, options = {}, &block) ⇒ Object
-
#alias_example_to(new_name, extra_options = {}) ⇒ Object
E.g.
- #autorun! ⇒ Object
- #before(each_or_all = :each, options = {}, &block) ⇒ Object
- #cleaned_from_backtrace?(line) ⇒ Boolean
- #color_enabled=(on_or_off) ⇒ Object
-
#color_enabled? ⇒ Boolean
Output with ANSI color enabled? Defaults to false.
- #extend(mod, options = {}) ⇒ Object
- #filter_run(options = {}) ⇒ Object
- #find_before_or_after(desired_type, desired_each_or_all, group) ⇒ Object
- #find_modules(group) ⇒ Object
-
#formatter ⇒ Object
The formatter all output should use.
- #formatter=(formatter_to_use) ⇒ Object
-
#include(mod, options = {}) ⇒ Object
RJS I think we should rename include/extend so they don’t conflict or confuse with the ruby builtin maybe register_include, setup_include, add_include, or just _include ?.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #mock_with(make_a_mockery_with = nil) ⇒ Object
-
#output ⇒ Object
Where does output go? For now $stdout.
- #run_all_when_everything_filtered? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/micronaut/configuration.rb', line 24 def initialize @backtrace_clean_patterns = [/\/lib\/ruby\//, /bin\/rcov:/, /vendor\/rails/, /bin\/micronaut/, /#{::Micronaut::InstallDirectory}/] @profile_examples = false @run_all_when_everything_filtered = true @color_enabled = false @before_and_afters = { :before => { :each => [], :all => [] }, :after => { :each => [], :all => [] } } @include_or_extend_modules = [] @formatter_to_use = Micronaut::Formatters::ProgressFormatter @filter = nil end |
Instance Attribute Details
#backtrace_clean_patterns ⇒ Object (readonly)
Regex patterns to scrub backtrace with
5 6 7 |
# File 'lib/micronaut/configuration.rb', line 5 def backtrace_clean_patterns @backtrace_clean_patterns end |
#before_and_afters ⇒ Object (readonly)
All of the defined before/after blocks setup in the configuration
8 9 10 |
# File 'lib/micronaut/configuration.rb', line 8 def before_and_afters @before_and_afters end |
#filter ⇒ Object (readonly)
Allows you to control what examples are ran by filtering
11 12 13 |
# File 'lib/micronaut/configuration.rb', line 11 def filter @filter end |
#include_or_extend_modules ⇒ Object (readonly)
Modules that will be included or extended based on given filters
14 15 16 |
# File 'lib/micronaut/configuration.rb', line 14 def include_or_extend_modules @include_or_extend_modules end |
#mock_framework ⇒ Object (readonly)
Returns the value of attribute mock_framework.
22 23 24 |
# File 'lib/micronaut/configuration.rb', line 22 def mock_framework @mock_framework end |
#profile_examples ⇒ Object
Enable profiling of example run - defaults to false
20 21 22 |
# File 'lib/micronaut/configuration.rb', line 20 def profile_examples @profile_examples end |
#run_all_when_everything_filtered ⇒ Object
Run all examples if the run is filtered, and no examples were found - defaults to true
17 18 19 |
# File 'lib/micronaut/configuration.rb', line 17 def run_all_when_everything_filtered @run_all_when_everything_filtered end |
Instance Method Details
#after(each_or_all = :each, options = {}, &block) ⇒ Object
122 123 124 |
# File 'lib/micronaut/configuration.rb', line 122 def after(each_or_all=:each, ={}, &block) before_and_afters[:after][each_or_all] << [, block] end |
#alias_example_to(new_name, extra_options = {}) ⇒ Object
E.g. alias_example_to :crazy_slow, :speed => ‘crazy_slow’ defines crazy_slow as an example variant that has the crazy_slow speed option
37 38 39 |
# File 'lib/micronaut/configuration.rb', line 37 def alias_example_to(new_name, ={}) Micronaut::Behaviour.alias_example_to(new_name, ) end |
#autorun! ⇒ Object
62 63 64 |
# File 'lib/micronaut/configuration.rb', line 62 def autorun! Micronaut::Runner.autorun end |
#before(each_or_all = :each, options = {}, &block) ⇒ Object
118 119 120 |
# File 'lib/micronaut/configuration.rb', line 118 def before(each_or_all=:each, ={}, &block) before_and_afters[:before][each_or_all] << [, block] end |
#cleaned_from_backtrace?(line) ⇒ Boolean
41 42 43 |
# File 'lib/micronaut/configuration.rb', line 41 def cleaned_from_backtrace?(line) @backtrace_clean_patterns.any? { |regex| line =~ regex } end |
#color_enabled=(on_or_off) ⇒ Object
66 67 68 |
# File 'lib/micronaut/configuration.rb', line 66 def color_enabled=(on_or_off) @color_enabled = on_or_off end |
#color_enabled? ⇒ Boolean
Output with ANSI color enabled? Defaults to false
71 72 73 |
# File 'lib/micronaut/configuration.rb', line 71 def color_enabled? @color_enabled end |
#extend(mod, options = {}) ⇒ Object
106 107 108 |
# File 'lib/micronaut/configuration.rb', line 106 def extend(mod, ={}) include_or_extend_modules << [:extend, mod, ] end |
#filter_run(options = {}) ⇒ Object
75 76 77 |
# File 'lib/micronaut/configuration.rb', line 75 def filter_run(={}) @filter = end |
#find_before_or_after(desired_type, desired_each_or_all, group) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/micronaut/configuration.rb', line 126 def find_before_or_after(desired_type, desired_each_or_all, group) before_and_afters[desired_type][desired_each_or_all].select do |, block| .all? do |filter_on, filter| Micronaut.world.apply_condition(filter_on, filter, group.) end end.map { |, block| block } end |
#find_modules(group) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/micronaut/configuration.rb', line 110 def find_modules(group) include_or_extend_modules.select do |include_or_extend, mod, | .all? do |filter_on, filter| Micronaut.world.apply_condition(filter_on, filter, group.) end end end |
#formatter ⇒ Object
The formatter all output should use. Defaults to the progress formatter
91 92 93 |
# File 'lib/micronaut/configuration.rb', line 91 def formatter @formatter ||= @formatter_to_use.new end |
#formatter=(formatter_to_use) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/micronaut/configuration.rb', line 83 def formatter=(formatter_to_use) @formatter_to_use = case formatter_to_use.to_s when 'documentation' then Micronaut::Formatters::DocumentationFormatter when 'progress' then Micronaut::Formatters::ProgressFormatter end end |
#include(mod, options = {}) ⇒ Object
RJS I think we should rename include/extend so they don’t conflict or confuse with the ruby builtin
maybe register_include, setup_include, add_include, or just _include ?
102 103 104 |
# File 'lib/micronaut/configuration.rb', line 102 def include(mod, ={}) include_or_extend_modules << [:include, mod, ] end |
#mock_with(make_a_mockery_with = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/micronaut/configuration.rb', line 45 def mock_with(make_a_mockery_with=nil) @mock_framework = make_a_mockery_with mock_framework_class = case make_a_mockery_with.to_s when /mocha/i require 'micronaut/mocking/with_mocha' Micronaut::Mocking::WithMocha when /rr/i require 'micronaut/mocking/with_rr' Micronaut::Mocking::WithRR else require 'micronaut/mocking/with_absolutely_nothing' Micronaut::Mocking::WithAbsolutelyNothing end Micronaut::Behaviour.send(:include, mock_framework_class) end |
#output ⇒ Object
Where does output go? For now $stdout
96 97 98 |
# File 'lib/micronaut/configuration.rb', line 96 def output $stdout end |
#run_all_when_everything_filtered? ⇒ Boolean
79 80 81 |
# File 'lib/micronaut/configuration.rb', line 79 def run_all_when_everything_filtered? @run_all_when_everything_filtered end |