rspec-given 2.3.0.beta.2 → 2.3.0.beta.3
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.rb +1 -0
- data/lib/rspec/given/extensions.rb +3 -2
- data/lib/rspec/given/module_methods.rb +8 -0
- data/lib/rspec/given/monkey.rb +40 -0
- data/lib/rspec/given/natural_assertion.rb +2 -1
- data/lib/rspec/given/version.rb +1 -1
- metadata +7 -6
data/README.md
CHANGED
data/lib/rspec/given.rb
CHANGED
@@ -47,7 +47,7 @@ module RSpec
|
|
47
47
|
return false unless nassert.has_content?
|
48
48
|
use_na = _rg_na_configured?
|
49
49
|
return true if use_na == :always
|
50
|
-
return false if nassert.using_rspec_assertion?
|
50
|
+
return false if !RSpec::Given::MONKEY && nassert.using_rspec_assertion?
|
51
51
|
use_na
|
52
52
|
end
|
53
53
|
|
@@ -101,8 +101,9 @@ module RSpec
|
|
101
101
|
|
102
102
|
# Evaluate a Then, And, or Invariant assertion.
|
103
103
|
def _rg_evaluate(block) # :nodoc:
|
104
|
+
RSpec::Given.matcher_called = false
|
104
105
|
passed = instance_eval(&block)
|
105
|
-
if ! passed && _rg_na_configured?
|
106
|
+
if ! passed && _rg_na_configured? && ! RSpec::Given.matcher_called
|
106
107
|
nassert = NaturalAssertion.new(block, binding, self.class._rgc_lines)
|
107
108
|
::RSpec::Expectations.fail_with nassert.message if _rg_need_na_message?(nassert)
|
108
109
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
# Monkey patch RSpec to detect matchers used in expectations.
|
4
|
+
|
5
|
+
unless defined?(RSpec::Given::MONKEY)
|
6
|
+
|
7
|
+
if defined?(RSpec::Expectations::PositiveExpectationHandler) &&
|
8
|
+
defined?(RSpec::Expectations::NegativeExpectationHandler)
|
9
|
+
|
10
|
+
RSpec::Given::MONKEY = true
|
11
|
+
|
12
|
+
module RSpec
|
13
|
+
module Expectations
|
14
|
+
class PositiveExpectationHandler
|
15
|
+
class << self
|
16
|
+
alias _rg_rspec_original_handle_matcher handle_matcher
|
17
|
+
def handle_matcher(actual, matcher, message=nil, &block)
|
18
|
+
RSpec::Given.matcher_called = true
|
19
|
+
_rg_rspec_original_handle_matcher(actual, matcher, message, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class NegativeExpectationHandler
|
25
|
+
class << self
|
26
|
+
alias _rg_rspec_original_handle_matcher handle_matcher
|
27
|
+
def handle_matcher(actual, matcher, message=nil, &block)
|
28
|
+
RSpec::Given.matcher_called = true
|
29
|
+
_rg_rspec_original_handle_matcher(actual, matcher, message, &block)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
else
|
37
|
+
RSpec::Given::MONKEY = false
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ripper'
|
2
2
|
require 'sorcerer'
|
3
|
+
require 'rspec/given/monkey'
|
3
4
|
|
4
5
|
module RSpec
|
5
6
|
module Given
|
@@ -97,7 +98,7 @@ module RSpec
|
|
97
98
|
end
|
98
99
|
|
99
100
|
def source
|
100
|
-
@line_extractor.line(@code_file, @code_line)
|
101
|
+
@source ||= @line_extractor.line(@code_file, @code_line)
|
101
102
|
end
|
102
103
|
|
103
104
|
def set_file_and_line
|
data/lib/rspec/given/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-given
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.0.beta.
|
4
|
+
version: 2.3.0.beta.3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- - ! '
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '2.11'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- - ! '
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '2.11'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: sorcerer
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/rspec/given/have_failed.rb
|
116
116
|
- lib/rspec/given/line_extractor.rb
|
117
117
|
- lib/rspec/given/module_methods.rb
|
118
|
+
- lib/rspec/given/monkey.rb
|
118
119
|
- lib/rspec/given/natural_assertion.rb
|
119
120
|
- lib/rspec/given/rspec1_given.rb
|
120
121
|
- lib/rspec/given/version.rb
|