rspec-given 2.4.5 → 3.0.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -2
- data/Gemfile.lock +8 -10
- data/README.md +50 -34
- data/README.old +720 -0
- data/Rakefile +23 -17
- data/TODO +13 -0
- data/examples/example_helper.rb +8 -1
- data/examples/integration/and_spec.rb +6 -11
- data/examples/integration/focused_line_spec.rb +2 -1
- data/examples/integration/given_spec.rb +19 -9
- data/examples/integration/invariant_spec.rb +6 -6
- data/examples/integration/then_spec.rb +0 -1
- data/examples/loader.rb +4 -0
- data/examples/minitest_helper.rb +38 -0
- data/examples/stack/stack_spec.rb +2 -3
- data/lib/given.rb +2 -0
- data/lib/rspec/given.rb +1 -19
- data/rakelib/bundler_fix.rb +17 -0
- data/rakelib/gemspec.rake +161 -0
- data/rakelib/metrics.rake +30 -0
- data/rakelib/preview.rake +14 -0
- data/spec/lib/{rspec/given → given}/evaluator_spec.rb +1 -1
- data/spec/lib/{rspec/given → given}/ext/numeric_spec.rb +2 -2
- data/spec/lib/{rspec/given → given}/ext/numeric_specifications.rb +0 -0
- data/spec/lib/{rspec/given → given}/extensions_spec.rb +2 -2
- data/spec/lib/given/failure_matcher_spec.rb +77 -0
- data/spec/lib/given/failure_spec.rb +49 -0
- data/spec/lib/given/file_cache_spec.rb +26 -0
- data/spec/lib/{rspec/given → given}/fuzzy_number_spec.rb +2 -2
- data/spec/lib/{rspec/given → given}/have_failed_spec.rb +5 -4
- data/spec/lib/{rspec/given → given}/lexical_purity_spec.rb +0 -0
- data/spec/lib/given/line_extractor_spec.rb +84 -0
- data/spec/lib/{rspec/given → given}/module_methods_spec.rb +2 -2
- data/spec/lib/{rspec/given → given}/natural_assertion_spec.rb +4 -36
- data/spec/lib/{rspec/given → given}/options_spec.rb +33 -33
- data/spec/spec_helper.rb +20 -0
- data/spec/support/faux_then.rb +2 -2
- data/spec/support/natural_assertion_control.rb +1 -1
- metadata +35 -42
- data/examples/integration/failing_spec.rb +0 -5
- data/lib/rspec/given/configure.rb +0 -20
- data/lib/rspec/given/core.rb +0 -9
- data/lib/rspec/given/evaluator.rb +0 -39
- data/lib/rspec/given/ext/numeric.rb +0 -32
- data/lib/rspec/given/extensions.rb +0 -262
- data/lib/rspec/given/failure.rb +0 -53
- data/lib/rspec/given/file_cache.rb +0 -19
- data/lib/rspec/given/fuzzy_number.rb +0 -70
- data/lib/rspec/given/fuzzy_shortcuts.rb +0 -1
- data/lib/rspec/given/have_failed.rb +0 -77
- data/lib/rspec/given/line_extractor.rb +0 -43
- data/lib/rspec/given/module_methods.rb +0 -70
- data/lib/rspec/given/monkey.rb +0 -42
- data/lib/rspec/given/natural_assertion.rb +0 -193
- data/lib/rspec/given/rspec1_given.rb +0 -11
- data/lib/rspec/given/version.rb +0 -10
- data/spec/lib/rspec/given/failure_spec.rb +0 -17
- data/spec/lib/rspec/given/file_cache_spec.rb +0 -28
- data/spec/lib/rspec/given/line_extractor_spec.rb +0 -86
@@ -5,33 +5,33 @@ describe "Configuration Options" do
|
|
5
5
|
|
6
6
|
describe "inherited options" do
|
7
7
|
context "Outer" do
|
8
|
-
|
9
|
-
|
8
|
+
_Gvn_context_info[:name] = "Outer"
|
9
|
+
_Gvn_context_info[:outer] = true
|
10
10
|
|
11
|
-
Then {
|
12
|
-
Then {
|
13
|
-
Then {
|
11
|
+
Then { _gvn_info(:name).should == "Outer" }
|
12
|
+
Then { _gvn_info(:outer).should == true }
|
13
|
+
Then { _gvn_info(:inner).should == nil }
|
14
14
|
|
15
15
|
context "Inner" do
|
16
|
-
|
17
|
-
|
16
|
+
_Gvn_context_info[:name] = "Inner"
|
17
|
+
_Gvn_context_info[:inner] = true
|
18
18
|
|
19
|
-
Then {
|
20
|
-
Then {
|
21
|
-
Then {
|
19
|
+
Then { _gvn_info(:name).should == "Inner" }
|
20
|
+
Then { _gvn_info(:outer).should == true }
|
21
|
+
Then { _gvn_info(:inner).should == true }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "Global natural assertion configuration" do
|
27
|
-
unless
|
27
|
+
unless Given::NATURAL_ASSERTIONS_SUPPORTED
|
28
28
|
before do
|
29
29
|
pending "Natural assertions are not supported in JRuby"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
before do
|
34
|
-
|
34
|
+
Given.use_natural_assertions false
|
35
35
|
end
|
36
36
|
|
37
37
|
Given(:rspec) { false }
|
@@ -39,25 +39,25 @@ describe "Configuration Options" do
|
|
39
39
|
Given(:nassert) { double(:using_rspec_assertion? => rspec, :has_content? => content) }
|
40
40
|
|
41
41
|
after do
|
42
|
-
|
42
|
+
Given.use_natural_assertions false
|
43
43
|
end
|
44
44
|
|
45
45
|
context "with no explicit word on natural assertions" do
|
46
|
-
Then {
|
46
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
47
47
|
|
48
48
|
context "overridden locally" do
|
49
49
|
use_natural_assertions_if_supported
|
50
|
-
Then {
|
50
|
+
Then { _gvn_need_na_message?(nassert).should be_true }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
context "with global configuration enabled" do
|
55
|
-
When {
|
56
|
-
Then {
|
55
|
+
When { Given.use_natural_assertions }
|
56
|
+
Then { _gvn_need_na_message?(nassert).should be_true }
|
57
57
|
|
58
58
|
context "overridden locally" do
|
59
59
|
use_natural_assertions false
|
60
|
-
Then {
|
60
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
61
61
|
end
|
62
62
|
|
63
63
|
context "with rspec assertion" do
|
@@ -67,71 +67,71 @@ describe "Configuration Options" do
|
|
67
67
|
# If RSpec was successfully patched to record matchers,
|
68
68
|
# then the "need NA" logic will ignore possible matches in
|
69
69
|
# the source code.
|
70
|
-
|
70
|
+
_gvn_need_na_message?(nassert).should be_true
|
71
71
|
else
|
72
72
|
# If RSpec was not successfully patched to record
|
73
73
|
# matchers, then the "need NA" logic will check for
|
74
74
|
# should/expect in the source.
|
75
|
-
|
75
|
+
_gvn_need_na_message?(nassert).should be_false
|
76
76
|
end
|
77
77
|
}
|
78
78
|
end
|
79
79
|
|
80
80
|
context "without rspec assertion" do
|
81
81
|
Given(:rspec) { false }
|
82
|
-
Then {
|
82
|
+
Then { _gvn_need_na_message?(nassert).should be_true }
|
83
83
|
end
|
84
84
|
|
85
85
|
context "without rspec assertion and no content" do
|
86
86
|
Given(:rspec) { false }
|
87
87
|
Given(:content) { false }
|
88
|
-
Then {
|
88
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
context "with global configuration set to always" do
|
93
|
-
When {
|
94
|
-
Then {
|
93
|
+
When { Given.use_natural_assertions :always }
|
94
|
+
Then { _gvn_need_na_message?(nassert).should be_true }
|
95
95
|
|
96
96
|
context "overridden locally" do
|
97
97
|
use_natural_assertions false
|
98
|
-
Then {
|
98
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
99
99
|
end
|
100
100
|
|
101
101
|
context "with rspec assertion" do
|
102
102
|
Given(:rspec) { true }
|
103
|
-
Then {
|
103
|
+
Then { _gvn_need_na_message?(nassert).should be_true }
|
104
104
|
end
|
105
105
|
|
106
106
|
context "without rspec assertion" do
|
107
107
|
Given(:rspec) { false }
|
108
|
-
Then {
|
108
|
+
Then { _gvn_need_na_message?(nassert).should be_true }
|
109
109
|
end
|
110
110
|
|
111
111
|
context "without rspec assertion and no content" do
|
112
112
|
Given(:rspec) { false }
|
113
113
|
Given(:content) { false }
|
114
|
-
Then {
|
114
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
context "with global configuration disabled" do
|
119
|
-
When {
|
120
|
-
Then {
|
119
|
+
When { Given.use_natural_assertions false }
|
120
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
121
121
|
|
122
122
|
context "overridden locally" do
|
123
123
|
use_natural_assertions_if_supported(true)
|
124
|
-
Then {
|
124
|
+
Then { _gvn_need_na_message?(nassert).should be_true }
|
125
125
|
end
|
126
126
|
|
127
127
|
context "with rspec assertion" do
|
128
128
|
Given(:rspec) { true }
|
129
|
-
Then {
|
129
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
130
130
|
end
|
131
131
|
|
132
132
|
context "without rspec assertion" do
|
133
133
|
Given(:rspec) { false }
|
134
|
-
Then {
|
134
|
+
Then { _gvn_need_na_message?(nassert).should be_false }
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
data/spec/spec_helper.rb
CHANGED
@@ -6,3 +6,23 @@ dir = File.dirname(__FILE__)
|
|
6
6
|
Dir[dir + "/support/*.rb"].each do |fn|
|
7
7
|
load fn
|
8
8
|
end
|
9
|
+
|
10
|
+
def given_assert_equal(expected, actual)
|
11
|
+
actual.should == expected
|
12
|
+
end
|
13
|
+
|
14
|
+
def given_assert(cond)
|
15
|
+
cond.should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
def given_assert_match(pattern, actual)
|
19
|
+
actual.should =~ pattern
|
20
|
+
end
|
21
|
+
|
22
|
+
def given_assert_not_match(pattern, actual)
|
23
|
+
actual.should_not =~ pattern
|
24
|
+
end
|
25
|
+
|
26
|
+
def given_assert_raises(error, pattern=nil, &block)
|
27
|
+
block.should raise_error(error, pattern)
|
28
|
+
end
|
data/spec/support/faux_then.rb
CHANGED
@@ -37,11 +37,11 @@ module Faux
|
|
37
37
|
|
38
38
|
def na
|
39
39
|
block = self.class.the_block
|
40
|
-
|
40
|
+
Given::NaturalAssertion.new("FauxThen", block, self, self.class._Gvn_lines)
|
41
41
|
end
|
42
42
|
|
43
43
|
def ev
|
44
|
-
|
44
|
+
Given::Evaluator.new(self, self.class.the_block)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module NaturalAssertionControl
|
2
2
|
def use_natural_assertions_if_supported(enabled=true)
|
3
|
-
if enabled && !
|
3
|
+
if enabled && ! Given::NATURAL_ASSERTIONS_SUPPORTED
|
4
4
|
Given {
|
5
5
|
pending "Natural assertions are not supported in JRuby"
|
6
6
|
}
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-given
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: given_core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0.beta.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.0.beta.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '2.12'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '2.12'
|
41
41
|
description: |
|
42
42
|
Given is an RSpec extension that allows the use of Given/When/Then
|
43
43
|
terminology when defining specifications.
|
@@ -50,40 +50,32 @@ files:
|
|
50
50
|
- Gemfile.lock
|
51
51
|
- MIT-LICENSE
|
52
52
|
- README.md
|
53
|
+
- README.old
|
53
54
|
- Rakefile
|
55
|
+
- TODO
|
56
|
+
- lib/given.rb
|
54
57
|
- lib/rspec-given.rb
|
55
58
|
- lib/rspec/given.rb
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
- lib/rspec/given/extensions.rb
|
61
|
-
- lib/rspec/given/failure.rb
|
62
|
-
- lib/rspec/given/file_cache.rb
|
63
|
-
- lib/rspec/given/fuzzy_number.rb
|
64
|
-
- lib/rspec/given/fuzzy_shortcuts.rb
|
65
|
-
- lib/rspec/given/have_failed.rb
|
66
|
-
- lib/rspec/given/line_extractor.rb
|
67
|
-
- lib/rspec/given/module_methods.rb
|
68
|
-
- lib/rspec/given/monkey.rb
|
69
|
-
- lib/rspec/given/natural_assertion.rb
|
70
|
-
- lib/rspec/given/rspec1_given.rb
|
71
|
-
- lib/rspec/given/version.rb
|
59
|
+
- rakelib/bundler_fix.rb
|
60
|
+
- rakelib/gemspec.rake
|
61
|
+
- rakelib/metrics.rake
|
62
|
+
- rakelib/preview.rake
|
72
63
|
- test/before_test.rb
|
73
64
|
- test/meme_test.rb
|
74
|
-
- spec/lib/
|
75
|
-
- spec/lib/
|
76
|
-
- spec/lib/
|
77
|
-
- spec/lib/
|
78
|
-
- spec/lib/
|
79
|
-
- spec/lib/
|
80
|
-
- spec/lib/
|
81
|
-
- spec/lib/
|
82
|
-
- spec/lib/
|
83
|
-
- spec/lib/
|
84
|
-
- spec/lib/
|
85
|
-
- spec/lib/
|
86
|
-
- spec/lib/
|
65
|
+
- spec/lib/given/evaluator_spec.rb
|
66
|
+
- spec/lib/given/ext/numeric_spec.rb
|
67
|
+
- spec/lib/given/ext/numeric_specifications.rb
|
68
|
+
- spec/lib/given/extensions_spec.rb
|
69
|
+
- spec/lib/given/failure_matcher_spec.rb
|
70
|
+
- spec/lib/given/failure_spec.rb
|
71
|
+
- spec/lib/given/file_cache_spec.rb
|
72
|
+
- spec/lib/given/fuzzy_number_spec.rb
|
73
|
+
- spec/lib/given/have_failed_spec.rb
|
74
|
+
- spec/lib/given/lexical_purity_spec.rb
|
75
|
+
- spec/lib/given/line_extractor_spec.rb
|
76
|
+
- spec/lib/given/module_methods_spec.rb
|
77
|
+
- spec/lib/given/natural_assertion_spec.rb
|
78
|
+
- spec/lib/given/options_spec.rb
|
87
79
|
- spec/spec_helper.rb
|
88
80
|
- spec/support/faux_then.rb
|
89
81
|
- spec/support/natural_assertion_control.rb
|
@@ -95,11 +87,12 @@ files:
|
|
95
87
|
- examples/integration/failing/module_nesting_spec.rb
|
96
88
|
- examples/integration/failing/undefined_method_spec.rb
|
97
89
|
- examples/integration/failing_messages_spec.rb
|
98
|
-
- examples/integration/failing_spec.rb
|
99
90
|
- examples/integration/focused_line_spec.rb
|
100
91
|
- examples/integration/given_spec.rb
|
101
92
|
- examples/integration/invariant_spec.rb
|
102
93
|
- examples/integration/then_spec.rb
|
94
|
+
- examples/loader.rb
|
95
|
+
- examples/minitest_helper.rb
|
103
96
|
- examples/other/line_example.rb
|
104
97
|
- examples/stack/stack.rb
|
105
98
|
- examples/stack/stack_spec.rb
|
@@ -126,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
119
|
version: 1.9.2
|
127
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
121
|
requirements:
|
129
|
-
- - '
|
122
|
+
- - '>'
|
130
123
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
124
|
+
version: 1.3.1
|
132
125
|
requirements: []
|
133
126
|
rubyforge_project: given
|
134
127
|
rubygems_version: 2.0.3
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'rspec/given/extensions'
|
3
|
-
require 'rspec/given/fuzzy_number'
|
4
|
-
require 'rspec/given/have_failed'
|
5
|
-
require 'rspec/given/module_methods'
|
6
|
-
|
7
|
-
RSpec.configure do |c|
|
8
|
-
c.extend(RSpec::Given::ClassExtensions)
|
9
|
-
c.include(RSpec::Given::InstanceExtensions)
|
10
|
-
c.include(RSpec::Given::HaveFailed)
|
11
|
-
c.include(RSpec::Given::Fuzzy)
|
12
|
-
|
13
|
-
if c.respond_to?(:backtrace_exclusion_patterns)
|
14
|
-
c.backtrace_exclusion_patterns << /lib\/rspec\/given/
|
15
|
-
else
|
16
|
-
c.backtrace_clean_patterns << /lib\/rspec\/given/
|
17
|
-
end
|
18
|
-
|
19
|
-
RSpec::Given.detect_formatters(c)
|
20
|
-
end
|
data/lib/rspec/given/core.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Given
|
3
|
-
class EvalErr
|
4
|
-
def initialize(str)
|
5
|
-
@string = str
|
6
|
-
end
|
7
|
-
def size
|
8
|
-
inspect.size
|
9
|
-
end
|
10
|
-
def to_s
|
11
|
-
@string
|
12
|
-
end
|
13
|
-
def inspect
|
14
|
-
@string
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Evaluator
|
19
|
-
def initialize(example, block)
|
20
|
-
@example = example
|
21
|
-
@block = block
|
22
|
-
end
|
23
|
-
|
24
|
-
def eval_string(exp_string)
|
25
|
-
eval_in_context(exp_string).inspect
|
26
|
-
rescue StandardError => ex
|
27
|
-
EvalErr.new("#{ex.class}: #{ex.message}")
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def eval_in_context(exp_string)
|
33
|
-
exp_proc = "proc { #{exp_string} }"
|
34
|
-
blk = eval(exp_proc, @block.binding)
|
35
|
-
@example.instance_eval(&blk)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
module RSpec
|
3
|
-
module Given
|
4
|
-
module Ext
|
5
|
-
module Numeric
|
6
|
-
|
7
|
-
def ±(del=nil)
|
8
|
-
result = RSpec::Given::Fuzzy::FuzzyNumber.new(self)
|
9
|
-
result.delta(del) if del
|
10
|
-
result
|
11
|
-
end
|
12
|
-
|
13
|
-
def ‰(percentage=nil)
|
14
|
-
result = RSpec::Given::Fuzzy::FuzzyNumber.new(self)
|
15
|
-
result.percent(percentage) if percentage
|
16
|
-
result
|
17
|
-
end
|
18
|
-
|
19
|
-
def €(neps=nil)
|
20
|
-
result = RSpec::Given::Fuzzy::FuzzyNumber.new(self)
|
21
|
-
result.epsilon(neps) if neps
|
22
|
-
result
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class Numeric
|
31
|
-
include RSpec::Given::Ext::Numeric
|
32
|
-
end
|