Module: Given
- Defined in:
- lib/given/failure.rb,
lib/given/version.rb,
lib/given/evaluator.rb,
lib/given/rspec/all.rb,
lib/given/assertions.rb,
lib/given/extensions.rb,
lib/given/file_cache.rb,
lib/given/ext/numeric.rb,
lib/given/fuzzy_number.rb,
lib/given/line_extractor.rb,
lib/given/module_methods.rb,
lib/given/failure_matcher.rb,
lib/given/binary_operation.rb,
lib/given/natural_assertion.rb,
lib/given/minitest/failure_must_raise.rb
Defined Under Namespace
Modules: Assertions, ClassExtensions, Ext, FailureMethod, Fuzzy, InstanceExtensions Classes: BinaryOperation, EvalErr, Evaluator, Failure, FailureMatcher, FileCache, LineExtractor, NaturalAssertion
Constant Summary collapse
- VERSION_NUMBERS =
[ VERSION_MAJOR = 3, VERSION_MINOR = 5, VERSION_BUILD = 0, ]
- VERSION =
VERSION_NUMBERS.join(".")
- RBX_IN_USE =
Does this platform support natural assertions?
(RUBY_ENGINE) && RUBY_ENGINE == 'rbx')
- JRUBY_IN_USE =
defined?(JRUBY_VERSION)
- OLD_JRUBY_IN_USE =
JRUBY_IN_USE && (JRUBY_VERSION < '1.7.5')
- NATURAL_ASSERTIONS_SUPPORTED =
! (OLD_JRUBY_IN_USE || RBX_IN_USE)
- InvalidThenError =
Class.new(StandardError)
Class Method Summary collapse
-
.count_assertion(*args) ⇒ Object
Increment the number of assertions made in the framework.
-
.detect_formatters(c) ⇒ Object
Detect the formatting requested in the given configuration object.
-
.explicit_assertions?(*args) ⇒ Boolean
Were there any explicit framework assertions made during the execution of the Then block?.
-
.fail_with(*args) ⇒ Object
Fail an example with the given messages.
- .framework ⇒ Object
- .framework=(framework) ⇒ Object
-
.location_of(block) ⇒ Object
Return file and line number where the block is defined.
-
.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 the current framework to indicate a pending example.
- .source_caching_disabled ⇒ Object
- .source_caching_disabled=(value) ⇒ Object
-
.start_evaluation(*args) ⇒ Object
Mark the start of a Then assertion evaluation.
-
.use_natural_assertions(enabled = true) ⇒ Object
Globally enable/disable natural assertions.
- .using_old_rspec? ⇒ Boolean
Class Method Details
.count_assertion(*args) ⇒ Object
Increment the number of assertions made in the framework.
82 83 84 |
# File 'lib/given/module_methods.rb', line 82 def self.count_assertion(*args) Given.framework.count_assertion(*args) end |
.detect_formatters(c) ⇒ Object
Detect the formatting requested in the given configuration object.
If the format requires it, source caching will be enabled.
29 30 31 32 |
# File 'lib/given/module_methods.rb', line 29 def self.detect_formatters(c) format_active = c.formatters.any? { |f| f.class.name !~ /ProgressFormatter/ } Given.source_caching_disabled = ! format_active end |
.explicit_assertions?(*args) ⇒ Boolean
Were there any explicit framework assertions made during the execution of the Then block?
77 78 79 |
# File 'lib/given/module_methods.rb', line 77 def self.explicit_assertions?(*args) Given.framework.explicit_assertions?(*args) end |
.fail_with(*args) ⇒ Object
Fail an example with the given messages.
66 67 68 |
# File 'lib/given/module_methods.rb', line 66 def self.fail_with(*args) Given.framework.fail_with(*args) end |
.framework ⇒ Object
10 11 12 |
# File 'lib/given/module_methods.rb', line 10 def self.framework @_gvn_framework end |
.framework=(framework) ⇒ Object
14 15 16 |
# File 'lib/given/module_methods.rb', line 14 def self.framework=(framework) @_gvn_framework = framework end |
.location_of(block) ⇒ Object
Return file and line number where the block is defined.
59 60 61 |
# File 'lib/given/module_methods.rb', line 59 def self.location_of(block) eval "[__FILE__, __LINE__]", block.binding end |
.natural_assertions_enabled? ⇒ Boolean
TRUE if natural assertions are globally enabled?
44 45 46 |
# File 'lib/given/module_methods.rb', line 44 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.
52 53 54 55 56 |
# File 'lib/given/module_methods.rb', line 52 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 the current framework to indicate a pending example.
88 89 90 |
# File 'lib/given/module_methods.rb', line 88 def self.pending_error Given.framework.pending_error end |
.source_caching_disabled ⇒ Object
18 19 20 |
# File 'lib/given/module_methods.rb', line 18 def self.source_caching_disabled @_gvn_source_caching_disabled end |
.source_caching_disabled=(value) ⇒ Object
22 23 24 |
# File 'lib/given/module_methods.rb', line 22 def self.source_caching_disabled=(value) @_gvn_source_caching_disabled = value end |
.start_evaluation(*args) ⇒ Object
Mark the start of a Then assertion evaluation.
71 72 73 |
# File 'lib/given/module_methods.rb', line 71 def self.start_evaluation(*args) Given.framework.start_evaluation(*args) 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.
38 39 40 41 |
# File 'lib/given/module_methods.rb', line 38 def self.use_natural_assertions(enabled=true) ok_to_use_natural_assertions(enabled) @natural_assertions_enabled = enabled end |
.using_old_rspec? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/given/rspec/all.rb', line 21 def self.using_old_rspec? defined?(Spec) && defined?(Spec::VERSION) && defined?(Spec::VERSION::SUMMARY) && Spec::VERSION::SUMMARY =~ /^rspec +1\./ end |