rspec-given 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51d4d0b65e5c61f3e4477ba071cbb662baf9a641
4
- data.tar.gz: 025e3eca40c723c210f09afa21a05a5bc36af8a2
3
+ metadata.gz: 1d5e73181cf61bc93071d7161a925ed327343dc9
4
+ data.tar.gz: 608ea8d31f28616d28f82724eb687c67b0f31d88
5
5
  SHA512:
6
- metadata.gz: 4a72c0d1a81c7a4c232ff99ba00409fd5511a9b43522292b62c3c891075592e21323083db75312c0ebd05ef11409f172b76af0e69245b984baae2c77d8e3fdf0
7
- data.tar.gz: fd9dfa5be45391c50a84b6ddccc3d9455a15f312dbe3733a4731d12164e3ae0cceeea0184803eb6134056a5076e1f80e26f41911394ceccdce85b1b1e701c46e
6
+ metadata.gz: 91305932206df20bc225b9e4c81ba5147c24ba288b687055bdc2265a7e8eba4e4085c39e37e0fb326b98274ceb6cb5ae69446bae063201dca032fe9fb5761749
7
+ data.tar.gz: 111ba753e7988ba157c844da3d3628713b3b13ec2567c25089bc890946c8eb91b90c35b3c505dbe9c8177f7484dc6783502b4ffef7e270217c854f158a09f6e0
@@ -1,21 +1,24 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.2.4)
5
- minitest (5.0.6)
6
- rake (10.0.4)
7
- rspec (2.14.1)
8
- rspec-core (~> 2.14.0)
9
- rspec-expectations (~> 2.14.0)
10
- rspec-mocks (~> 2.14.0)
11
- rspec-core (2.14.1)
12
- rspec-expectations (2.14.0)
4
+ diff-lcs (1.2.5)
5
+ minitest (4.3.2)
6
+ rake (0.9.6)
7
+ rspec (3.0.0.beta1)
8
+ rspec-core (= 3.0.0.beta1)
9
+ rspec-expectations (= 3.0.0.beta1)
10
+ rspec-mocks (= 3.0.0.beta1)
11
+ rspec-core (3.0.0.beta1)
12
+ rspec-support (= 3.0.0.beta1)
13
+ rspec-expectations (3.0.0.beta1)
13
14
  diff-lcs (>= 1.1.3, < 2.0)
14
- rspec-mocks (2.14.1)
15
- sorcerer (0.3.10)
15
+ rspec-support (= 3.0.0.beta1)
16
+ rspec-mocks (3.0.0.beta1)
17
+ rspec-support (= 3.0.0.beta1)
18
+ rspec-support (3.0.0.beta1)
19
+ sorcerer (1.0.2)
16
20
 
17
21
  PLATFORMS
18
- java
19
22
  ruby
20
23
 
21
24
  DEPENDENCIES
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  | :----: |
5
5
  | [![Master Build Status](https://secure.travis-ci.org/jimweirich/rspec-given.png?branch=master)](https://travis-ci.org/jimweirich/rspec-given) |
6
6
 
7
- Covering rspec-given, minitest-given, and given-core, version 3.1.1.
7
+ Covering rspec-given, minitest-given, and given-core, version 3.2.0.
8
8
 
9
9
  rspec-given and minitest-given are extensions to your favorite testing
10
10
  framework to allow Given/When/Then notation when writing specs.
@@ -19,8 +19,7 @@ structure RSpec specifications.
19
19
 
20
20
  ## Status
21
21
 
22
- * rspec-given is ready for production use.
23
- * minitest-given is experimental.
22
+ * rspec-given and minitest-given are ready for production use.
24
23
 
25
24
  ### RSpec/Given
26
25
 
@@ -267,8 +266,10 @@ E.g.
267
266
 
268
267
  context "inner context" do
269
268
 
270
- # At this point, the _When_ of the outer context
271
- # should be treated as a _Given_ of the inner context
269
+ # At this point, the _When_ of the outer context will be run
270
+ # before the _When_ of then inner context (but after all the
271
+ # _Givens_ of all the contexts). You can think of the outer
272
+ # _When_ as a special given for the inner scope.
272
273
 
273
274
  When { code specified in the inner context }
274
275
  Then { assert something about the inner context }
@@ -309,12 +310,16 @@ specify that behavior:
309
310
 
310
311
  ```ruby
311
312
  When(:result) { stack.pop }
312
- Then { result.should have_failed(UnderflowError, /empty/) }
313
+ Then { expect(result).to have_failed(UnderflowError, /empty/) }
313
314
  ```
314
315
 
315
- Note that the arguments to the 'have_failed' matcher are the same as
316
+ The arguments to the 'have_failed' matcher are the same as
316
317
  those given to the standard RSpec matcher 'raise_error'.
317
318
 
319
+ *NOTE:* Prior to RSpec 3, the .should method worked with the failed
320
+ result. In RSpec 3 the <code>.should</code> method is deprecated and
321
+ should not be used with the failed result.
322
+
318
323
  ### Then
319
324
 
320
325
  The _Then_ clauses are the postconditions of the specification. These
@@ -625,7 +630,7 @@ context.
625
630
  context "Outer" do
626
631
  context "Inner" do
627
632
  Then { a == b } # Natural Assertions
628
- Then { a.should == b } # RSpec style
633
+ Then { a.should == b } # Deprecated RSpec style
629
634
  Then { expect(a).to eq(b) } # RSpec style
630
635
  Then { assert_equal b, a } # Minitest style
631
636
  Then { a.must_equal b } # Minitest style
@@ -709,7 +714,7 @@ For example, the following two Then clauses are equivalent:
709
714
 
710
715
  ```ruby
711
716
  # Using an RSpec matcher
712
- Then { result.should have_failed(StandardError, /message/) }
717
+ Then { expect(result).to have_failed(StandardError, /message/) }
713
718
 
714
719
  # Using natural assertions
715
720
  Then { result == Failure(StandardError, /message/) }
@@ -844,6 +849,10 @@ License. See the MIT-LICENSE file in the source distribution.
844
849
 
845
850
  # History
846
851
 
852
+ * Version 3.2.0
853
+
854
+ * Add support for RSpec 3 beta
855
+
847
856
  * Version 3.1.0
848
857
 
849
858
  * Add support for Precondition/Postcondition/Assert in non-spec
@@ -11,10 +11,10 @@ describe "Natural Assertions" do
11
11
  Given(:null) { nil }
12
12
  Then { foo+foo+2*foo == expected }
13
13
  Then { nil == "HI" && true && :symbol && 1}
14
- Then { foo.should == 2 }
14
+ Then { expect(foo).to eq(2) }
15
15
  Then { foo != 1 }
16
- Then { foo.should_not == 1 }
17
- Then { foo.should be_nil }
16
+ Then { expect(foo).to_not == 1 }
17
+ Then { expect(foo).to be_nil }
18
18
  Then { ary.empty? }
19
19
  Then { !null.nil? }
20
20
  Then { fail "OUCH" }
@@ -35,7 +35,7 @@ describe "And" do
35
35
  @message = ex.message
36
36
  end
37
37
 
38
- it "should define a message" do
38
+ it "defines a message" do
39
39
  message = self.class.instance_eval { @message }
40
40
  given_assert_match(/and.*without.*then/i, message)
41
41
  end
@@ -5,23 +5,23 @@ describe Given::BinaryOperation do
5
5
 
6
6
  context "with a valid binary sexp" do
7
7
  Given(:sexp) { [:binary, [:@ident, "a"], :==, [:@ident, "b"]] }
8
- Then { binary.left.should == [:@ident, "a"] }
9
- Then { binary.operator.should == :== }
10
- Then { binary.right.should == [:@ident, "b"] }
11
- Then { binary.explain.should == "to equal" }
8
+ Then { expect(binary.left).to eq([:@ident, "a"]) }
9
+ Then { expect(binary.operator).to eq(:==) }
10
+ Then { expect(binary.right).to eq([:@ident, "b"]) }
11
+ Then { expect(binary.explain).to eq("to equal") }
12
12
  end
13
13
 
14
14
  context "with a valid binary sexp using ===" do
15
15
  Given(:sexp) { [:binary, [:@ident, "a"], :===, [:@ident, "b"]] }
16
- Then { binary.left.should == [:@ident, "a"] }
17
- Then { binary.operator.should == :=== }
18
- Then { binary.right.should == [:@ident, "b"] }
19
- Then { binary.explain.should == "to be matched by" }
16
+ Then { expect(binary.left).to eq([:@ident, "a"]) }
17
+ Then { expect(binary.operator).to eq(:===) }
18
+ Then { expect(binary.right).to eq([:@ident, "b"]) }
19
+ Then { expect(binary.explain).to eq("to be matched by") }
20
20
  end
21
21
 
22
22
  context "with a non-binary sexp" do
23
23
  Given(:sexp) { [:something_else] }
24
- Then { binary.should be_nil }
24
+ Then { expect(binary).to be_nil }
25
25
  end
26
26
 
27
27
  end
@@ -6,10 +6,10 @@ describe "Environmental Access" do
6
6
  Given(:a) { 2 }
7
7
  FauxThen { X + a }
8
8
 
9
- Then { block_result.should == 3 }
10
- Then { ev.eval_string("X").should == "1" }
11
- Then { ev.eval_string("a").should == "2" }
12
- Then { ev.eval_string("X+a").should == "3" }
9
+ Then { expect(block_result).to eq(3) }
10
+ Then { expect(ev.eval_string("X")).to eq("1") }
11
+ Then { expect(ev.eval_string("a")).to eq("2") }
12
+ Then { expect(ev.eval_string("X+a")).to eq("3") }
13
13
  end
14
14
 
15
15
  module Nested
@@ -18,10 +18,10 @@ module Nested
18
18
  use_natural_assertions false
19
19
  Given(:a) { 2 }
20
20
  FauxThen { X + a }
21
- Then { block_result.should == 3 }
22
- Then { ev.eval_string("a").should == "2" }
23
- Then { ev.eval_string("X").should == "1" }
24
- Then { ev.eval_string("a+X").should == "3" }
21
+ Then { expect(block_result).to eq(3) }
22
+ Then { expect(ev.eval_string("a")).to eq("2") }
23
+ Then { expect(ev.eval_string("X")).to eq("1") }
24
+ Then { expect(ev.eval_string("a+X")).to eq("3") }
25
25
  end
26
26
  end
27
27
 
@@ -29,6 +29,6 @@ describe "Evaluator with error object" do
29
29
  use_natural_assertions false
30
30
  FauxThen { 1 }
31
31
  When(:result) { ev.eval_string("fail 'XYZ'") }
32
- Then { result.class.should == Given::EvalErr }
33
- Then { result.inspect.should == "RuntimeError: XYZ" }
32
+ Then { expect(result.class).to eq(Given::EvalErr) }
33
+ Then { expect(result.inspect).to eq("RuntimeError: XYZ") }
34
34
  end
@@ -6,20 +6,20 @@ describe Given::ClassExtensions do
6
6
  describe "Given with var" do
7
7
  context "with simple given" do
8
8
  Given(:a) { 1 }
9
- Then { a.should == 1 }
9
+ Then { expect(a).to eq(1) }
10
10
  end
11
11
 
12
12
  context "is lazy" do
13
13
  Given(:a) { trace << :given; 1 }
14
- Then { a.should == 1 }
15
- Then { trace.should == [] }
16
- Then { a; trace.should == [:given] }
14
+ Then { expect(a).to eq(1) }
15
+ Then { expect(trace).to eq([]) }
16
+ Then { a; expect(trace).to eq([:given]) }
17
17
 
18
18
  context "when nested" do
19
19
  Given(:a) { trace << :nested; 2 }
20
- Then { a.should == 2 }
21
- Then { trace.should == [] }
22
- Then { a; trace.should == [:nested] }
20
+ Then { expect(a).to eq(2) }
21
+ Then { expect(trace).to eq([]) }
22
+ Then { a; expect(trace).to eq([:nested]) }
23
23
  end
24
24
  end
25
25
  end
@@ -27,11 +27,11 @@ describe Given::ClassExtensions do
27
27
  describe "Given without var" do
28
28
  context "is lazy" do
29
29
  Given { trace << :given }
30
- Then { trace.should == [:given] }
30
+ Then { expect(trace).to eq([:given]) }
31
31
 
32
32
  context "when nested" do
33
33
  Given { trace << :nested }
34
- Then { trace.should == [:given, :nested] }
34
+ Then { expect(trace).to eq([:given, :nested]) }
35
35
  end
36
36
  end
37
37
  end
@@ -39,20 +39,20 @@ describe Given::ClassExtensions do
39
39
  describe "Given!" do
40
40
  context "with simple given" do
41
41
  Given!(:a) { 1 }
42
- Then { a.should == 1 }
42
+ Then { expect(a).to eq(1) }
43
43
  end
44
44
 
45
45
  context "is not lazy" do
46
46
  Given!(:a) { trace << :given; 1 }
47
- Then { a.should == 1 }
48
- Then { trace.should == [:given] }
49
- Then { a; trace.should == [:given] }
47
+ Then { expect(a).to eq(1) }
48
+ Then { expect(trace).to eq([:given]) }
49
+ Then { a; expect(trace).to eq([:given]) }
50
50
  end
51
51
 
52
52
  context "when preceeded by a Given block" do
53
53
  Given { trace << :given }
54
54
  Given!(:other) { trace << :given_bang }
55
- Then { trace.should == [:given, :given_bang] }
55
+ Then { expect(trace).to eq([:given, :given_bang]) }
56
56
  end
57
57
  end
58
58
 
@@ -65,12 +65,12 @@ describe Given::ClassExtensions do
65
65
  When(:result_outer) { trace << :when_result_outer }
66
66
 
67
67
  Then {
68
- trace.should == [
69
- :before_outer, :before2_outer,
70
- :given_outer, :given_bang_outer,
71
- :when_outer,
72
- :when_result_outer,
73
- ]
68
+ expect(trace).to eq([
69
+ :before_outer, :before2_outer,
70
+ :given_outer, :given_bang_outer,
71
+ :when_outer,
72
+ :when_result_outer,
73
+ ])
74
74
  }
75
75
 
76
76
  context "with a nested When" do
@@ -81,14 +81,14 @@ describe Given::ClassExtensions do
81
81
  When { trace << :when_inner }
82
82
 
83
83
  Then {
84
- trace.should == [
85
- :before_outer, :before2_outer,
86
- :given_outer, :given_bang_outer,
87
- :given_inner, :given_bang_inner,
88
- :when_outer, :when_result_outer,
89
- :before_inner,
90
- :when_result_inner, :when_inner,
91
- ]
84
+ expect(trace).to eq([
85
+ :before_outer, :before2_outer,
86
+ :given_outer, :given_bang_outer,
87
+ :given_inner, :given_bang_inner,
88
+ :when_outer, :when_result_outer,
89
+ :before_inner,
90
+ :when_result_inner, :when_inner,
91
+ ])
92
92
  }
93
93
  end
94
94
 
@@ -98,13 +98,13 @@ describe Given::ClassExtensions do
98
98
  Given!(:x_inner) { trace << :given_bang_inner }
99
99
 
100
100
  Then {
101
- trace.should == [
102
- :before_outer, :before2_outer,
103
- :given_outer, :given_bang_outer,
104
- :given_inner, :given_bang_inner,
105
- :when_outer, :when_result_outer,
106
- :before_inner,
107
- ]
101
+ expect(trace).to eq([
102
+ :before_outer, :before2_outer,
103
+ :given_outer, :given_bang_outer,
104
+ :given_inner, :given_bang_inner,
105
+ :when_outer, :when_result_outer,
106
+ :before_inner,
107
+ ])
108
108
  }
109
109
  end
110
110
  end
@@ -112,62 +112,62 @@ describe Given::ClassExtensions do
112
112
  describe "When without result" do
113
113
  Given { trace << :given }
114
114
  When { trace << :when }
115
- Then { trace.should == [:given, :when] }
115
+ Then { expect(trace).to eq([:given, :when]) }
116
116
 
117
117
  context "with nesting" do
118
118
  Given { trace << :nested }
119
- Then { trace.should == [:given, :nested, :when] }
119
+ Then { expect(trace).to eq([:given, :nested, :when]) }
120
120
  end
121
121
 
122
122
  context "with nesting of When" do
123
123
  Given { trace << :nested }
124
124
  When { trace << :when_nested }
125
- Then { trace.should == [:given, :nested, :when, :when_nested] }
125
+ Then { expect(trace).to eq([:given, :nested, :when, :when_nested]) }
126
126
  end
127
127
  end
128
128
 
129
129
  describe "When with result" do
130
130
  Given { trace << :given }
131
131
  When(:result) { trace << :when; :result }
132
- Invariant { result.should == :result }
132
+ Invariant { expect(result).to eq(:result) }
133
133
 
134
- Then { trace.should == [:given, :when] }
134
+ Then { expect(trace).to eq([:given, :when]) }
135
135
 
136
136
  context "with nesting" do
137
137
  Given { trace << :nested }
138
- Then { trace.should == [:given, :nested, :when] }
138
+ Then { expect(trace).to eq([:given, :nested, :when]) }
139
139
  end
140
140
 
141
141
  context "with nesting of When" do
142
142
  Given { trace << :nested }
143
143
  When { trace << :when_nested }
144
- Then { trace.should == [:given, :nested, :when, :when_nested] }
144
+ Then { expect(trace).to eq([:given, :nested, :when, :when_nested]) }
145
145
  end
146
146
  end
147
147
 
148
148
  describe "When with unreferenced result" do
149
149
  Given { trace << :given }
150
150
  When(:result) { trace << :when; :result }
151
- Then { trace.should == [:given, :when] }
151
+ Then { expect(trace).to eq([:given, :when]) }
152
152
  end
153
153
 
154
154
  describe "Invariant with When" do
155
155
  Given { trace << :given }
156
156
  Invariant { trace << :invariant }
157
157
  When { trace << :when }
158
- Then { trace.should == [:given, :when, :invariant] }
158
+ Then { expect(trace).to eq([:given, :when, :invariant]) }
159
159
  end
160
160
 
161
161
  describe "Invariant without When" do
162
162
  Given { trace << :given }
163
163
  Invariant { trace << :invariant }
164
- Then { trace.should == [:given, :invariant] }
164
+ Then { expect(trace).to eq([:given, :invariant]) }
165
165
  end
166
166
 
167
167
  describe "Then" do
168
168
  Given { trace << :given }
169
169
  Then { trace << :then }
170
- And { trace.should == [:given, :then] }
170
+ And { expect(trace).to eq([:given, :then]) }
171
171
  end
172
172
 
173
173
  describe "Then referencing givens" do
@@ -184,7 +184,7 @@ describe Given::ClassExtensions do
184
184
  Given { trace << :given }
185
185
  Then { trace << :then }
186
186
  And { trace << :and}
187
- And { trace.should == [:given, :then, :and] }
187
+ And { expect(trace).to eq([:given, :then, :and]) }
188
188
  end
189
189
 
190
190
  end
@@ -196,9 +196,9 @@ describe "use_natural_assertions" do
196
196
  When(:result) { CONTEXT.use_natural_assertions }
197
197
 
198
198
  if ::Given::NATURAL_ASSERTIONS_SUPPORTED
199
- Then { result.should_not have_failed }
199
+ Then { expect(result).to_not have_failed }
200
200
  else
201
- Then { result.should have_failed(ArgumentError) }
201
+ Then { expect(result).to have_failed(ArgumentError) }
202
202
  end
203
203
  end
204
204
  end
@@ -8,7 +8,7 @@ describe Given::Failure do
8
8
  Given(:exception) { StandardError.new("Oops") }
9
9
  Given(:failure) { Given::Failure.new(exception) }
10
10
 
11
- Then { failure.is_a?(Given::Failure).should be_true }
11
+ Then { expect(failure.is_a?(Given::Failure)).to eq(true) }
12
12
 
13
13
  describe "general operations" do
14
14
  Then { expect { failure.to_s }.to raise_error(StandardError, "Oops") }
@@ -20,10 +20,10 @@ describe Given::Failure do
20
20
  Then { expect { ! failure }.to raise_error(StandardError, "Oops") }
21
21
  end
22
22
 
23
- describe "should raise error" do
24
- Then { failure.should raise_error(StandardError, "Oops") }
25
- Then { failure.should raise_error(StandardError) }
26
- Then { failure.should raise_error }
23
+ describe "raising error" do
24
+ Then { expect(failure).to raise_error(StandardError, "Oops") }
25
+ Then { expect(failure).to raise_error(StandardError) }
26
+ Then { expect(failure).to raise_error }
27
27
  end
28
28
 
29
29
  describe "== have_failed" do