Module: RSpec::Given
- Defined in:
- lib/rspec/given.rb,
lib/rspec/given/failure.rb,
lib/rspec/given/version.rb,
lib/rspec/given/evaluator.rb,
lib/rspec/given/extensions.rb,
lib/rspec/given/file_cache.rb,
lib/rspec/given/ext/numeric.rb,
lib/rspec/given/have_failed.rb,
lib/rspec/given/fuzzy_number.rb,
lib/rspec/given/line_extractor.rb,
lib/rspec/given/module_methods.rb,
lib/rspec/given/natural_assertion.rb
Defined Under Namespace
Modules: ClassExtensions, Ext, Fuzzy, HaveFailed, InstanceExtensions Classes: EvalErr, Evaluator, Failure, FileCache, LineExtractor, NaturalAssertion
Constant Summary collapse
- MONKEY =
false
- VERSION_NUMBERS =
[ VERSION_MAJOR = 2, VERSION_MINOR = 4, VERSION_BUILD = 4, ]
- VERSION =
VERSION_NUMBERS.join(".")
- RBX_IN_USE =
Does this platform support natural assertions?
(RUBY_ENGINE) && RUBY_ENGINE == 'rbx')
- JRUBY_IN_USE =
defined?(JRUBY_VERSION)
- NATURAL_ASSERTIONS_SUPPORTED =
! (JRUBY_IN_USE || RBX_IN_USE)
- InvalidThenError =
Class.new(StandardError)
Class Method Summary collapse
-
.detect_formatters(c) ⇒ Object
Detect the formatting requested in the given configuration object.
-
.fail_with(*args) ⇒ Object
Fail an example with the given messages.
- .matcher_called ⇒ Object
- .matcher_called=(value) ⇒ Object
-
.natural_assertions_enabled? ⇒ Boolean
TRUE if natural assertions are globally enabled?.
-
.ok_to_use_natural_assertions(enabled) ⇒ Object
Is is OK to use natural assertions on this platform.
-
.pending_error ⇒ Object
Error object used by RSpec to indicate a pending example.
- .source_caching_disabled ⇒ Object
- .source_caching_disabled=(value) ⇒ Object
-
.use_natural_assertions(enabled = true) ⇒ Object
Globally enable/disable natural assertions.
- .using_old_rspec? ⇒ Boolean
Class Method Details
.detect_formatters(c) ⇒ Object
Detect the formatting requested in the given configuration object.
If the format requires it, source caching will be enabled.
28 29 30 31 |
# File 'lib/rspec/given/module_methods.rb', line 28 def self.detect_formatters(c) format_active = c.formatters.any? { |f| f.class.name !~ /ProgressFormatter/ } RSpec::Given.source_caching_disabled = ! format_active end |
.fail_with(*args) ⇒ Object
Fail an example with the given messages.
This should be the only place we reference the RSpec function. Everywhere else in rspec-given should be calling this function.
61 62 63 |
# File 'lib/rspec/given/module_methods.rb', line 61 def self.fail_with(*args) ::RSpec::Expectations.fail_with(*args) end |
.matcher_called ⇒ Object
9 10 11 |
# File 'lib/rspec/given/module_methods.rb', line 9 def self.matcher_called @_matcher_called end |
.matcher_called=(value) ⇒ Object
13 14 15 |
# File 'lib/rspec/given/module_methods.rb', line 13 def self.matcher_called=(value) @_matcher_called = value end |
.natural_assertions_enabled? ⇒ Boolean
TRUE if natural assertions are globally enabled?
43 44 45 |
# File 'lib/rspec/given/module_methods.rb', line 43 def self.natural_assertions_enabled? @natural_assertions_enabled end |
.ok_to_use_natural_assertions(enabled) ⇒ Object
Is is OK to use natural assertions on this platform.
An error is raised if the the platform does not support natural assertions and the flag is attempting to enable them.
51 52 53 54 55 |
# File 'lib/rspec/given/module_methods.rb', line 51 def self.ok_to_use_natural_assertions(enabled) if enabled && ! NATURAL_ASSERTIONS_SUPPORTED fail ArgumentError, "Natural Assertions are disabled for JRuby" end end |
.pending_error ⇒ Object
Error object used by RSpec to indicate a pending example.
66 67 68 |
# File 'lib/rspec/given/module_methods.rb', line 66 def self.pending_error RSpec::Core::Pending::PendingDeclaredInExample end |
.source_caching_disabled ⇒ Object
17 18 19 |
# File 'lib/rspec/given/module_methods.rb', line 17 def self.source_caching_disabled @_rg_source_caching_disabled end |
.source_caching_disabled=(value) ⇒ Object
21 22 23 |
# File 'lib/rspec/given/module_methods.rb', line 21 def self.source_caching_disabled=(value) @_rg_source_caching_disabled = value end |
.use_natural_assertions(enabled = true) ⇒ Object
Globally enable/disable natural assertions.
There is a similar function in Extensions that works at a describe or context scope.
37 38 39 40 |
# File 'lib/rspec/given/module_methods.rb', line 37 def self.use_natural_assertions(enabled=true) ok_to_use_natural_assertions(enabled) @natural_assertions_enabled = enabled end |
.using_old_rspec? ⇒ Boolean
3 4 5 6 7 8 |
# File 'lib/rspec/given.rb', line 3 def self.using_old_rspec? defined?(Spec) && defined?(Spec::VERSION) && defined?(Spec::VERSION::SUMMARY) && Spec::VERSION::SUMMARY =~ /^rspec +1\./ end |