rspec-given 2.3.1.beta.1 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/rspec/given/extensions.rb +5 -5
- data/lib/rspec/given/failure.rb +11 -4
- data/lib/rspec/given/module_methods.rb +30 -4
- data/lib/rspec/given/version.rb +0 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -105,7 +105,7 @@ module RSpec
|
|
105
105
|
passed = instance_eval(&block)
|
106
106
|
if ! passed && _rg_na_configured? && ! RSpec::Given.matcher_called
|
107
107
|
nassert = NaturalAssertion.new(block, binding, self.class._rgc_lines)
|
108
|
-
|
108
|
+
RSpec::Given.fail_with nassert.message if _rg_need_na_message?(nassert)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -144,9 +144,9 @@ module RSpec
|
|
144
144
|
|
145
145
|
# *DEPRECATED:*
|
146
146
|
#
|
147
|
-
# The Scenario command is deprecated. Using Scenario in
|
148
|
-
# will result in a warning message. Eventually the
|
149
|
-
# be removed.
|
147
|
+
# The Scenario command is deprecated. Using Scenario in an
|
148
|
+
# example will result in a warning message. Eventually the
|
149
|
+
# command will be removed.
|
150
150
|
#
|
151
151
|
# Declare a scenario to contain Given/When/Then declarations. A
|
152
152
|
# Scenario is essentially an RSpec context, with the additional
|
@@ -206,7 +206,7 @@ module RSpec
|
|
206
206
|
begin
|
207
207
|
_rg_establish_givens
|
208
208
|
instance_eval(&block)
|
209
|
-
rescue RSpec::
|
209
|
+
rescue RSpec::Given.pending_error => ex
|
210
210
|
raise
|
211
211
|
rescue Exception => ex
|
212
212
|
Failure.new(ex)
|
data/lib/rspec/given/failure.rb
CHANGED
@@ -15,7 +15,7 @@ module RSpec
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def ==(other)
|
18
|
-
if
|
18
|
+
if failed_matcher?(other)
|
19
19
|
other.matches?(self)
|
20
20
|
else
|
21
21
|
die
|
@@ -23,20 +23,27 @@ module RSpec
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def !=(other)
|
26
|
-
if
|
26
|
+
if failed_matcher?(other)
|
27
27
|
! other.matches?(self)
|
28
28
|
else
|
29
29
|
die
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def method_missing(sym, *args, &block)
|
34
|
+
die
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
33
39
|
def die
|
34
40
|
::Kernel.raise @exception
|
35
41
|
end
|
36
42
|
|
37
|
-
def
|
38
|
-
|
43
|
+
def failed_matcher?(other)
|
44
|
+
other.is_a?(::RSpec::Given::HaveFailed::HaveFailedMatcher)
|
39
45
|
end
|
46
|
+
|
40
47
|
end
|
41
48
|
end
|
42
49
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Given
|
3
|
+
# Does this platform support natural assertions?
|
3
4
|
NATURAL_ASSERTIONS_SUPPORTED = ! defined?(JRUBY_VERSION)
|
4
5
|
|
5
6
|
def self.matcher_called
|
6
|
-
@
|
7
|
+
@_matcher_called
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.matcher_called=(value)
|
10
|
-
@
|
11
|
+
@_matcher_called = value
|
11
12
|
end
|
12
13
|
|
13
14
|
def self.source_caching_disabled
|
@@ -18,24 +19,49 @@ module RSpec
|
|
18
19
|
@_rg_source_caching_disabled = value
|
19
20
|
end
|
20
21
|
|
22
|
+
# Detect the formatting requested in the given configuration object.
|
23
|
+
#
|
24
|
+
# If the format requires it, source caching will be enabled.
|
21
25
|
def self.detect_formatters(c)
|
22
26
|
format_active = c.formatters.any? { |f| f.class.name !~ /ProgressFormatter/ }
|
23
27
|
RSpec::Given.source_caching_disabled = ! format_active
|
24
28
|
end
|
25
29
|
|
30
|
+
# Globally enable/disable natural assertions.
|
31
|
+
#
|
32
|
+
# There is a similar function in Extensions that works at a
|
33
|
+
# describe or context scope.
|
26
34
|
def self.use_natural_assertions(enabled=true)
|
27
35
|
ok_to_use_natural_assertions(enabled)
|
28
36
|
@natural_assertions_enabled = enabled
|
29
37
|
end
|
30
38
|
|
39
|
+
# TRUE if natural assertions are globally enabled?
|
40
|
+
def self.natural_assertions_enabled?
|
41
|
+
@natural_assertions_enabled
|
42
|
+
end
|
43
|
+
|
44
|
+
# Is is OK to use natural assertions on this platform.
|
45
|
+
#
|
46
|
+
# An error is raised if the the platform does not support natural
|
47
|
+
# assertions and the flag is attempting to enable them.
|
31
48
|
def self.ok_to_use_natural_assertions(enabled)
|
32
49
|
if enabled && ! NATURAL_ASSERTIONS_SUPPORTED
|
33
50
|
fail ArgumentError, "Natural Assertions are disabled for JRuby"
|
34
51
|
end
|
35
52
|
end
|
36
53
|
|
37
|
-
|
38
|
-
|
54
|
+
# Fail an example with the given messages.
|
55
|
+
#
|
56
|
+
# This should be the only place we reference the RSpec function.
|
57
|
+
# Everywhere else in rspec-given should be calling this function.
|
58
|
+
def self.fail_with(*args)
|
59
|
+
::RSpec::Expectations.fail_with(*args)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Error object used by RSpec to indicate a pending example.
|
63
|
+
def self.pending_error
|
64
|
+
RSpec::Core::Pending::PendingDeclaredInExample
|
39
65
|
end
|
40
66
|
end
|
41
67
|
end
|
data/lib/rspec/given/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-given
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.1
|
5
|
-
prerelease:
|
4
|
+
version: 2.3.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jim Weirich
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -138,9 +138,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
140
140
|
requirements:
|
141
|
-
- - ! '
|
141
|
+
- - ! '>='
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
143
|
+
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project: given
|
146
146
|
rubygems_version: 1.8.24
|