warp 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -10
  3. data/Appraisals +2 -3
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +3 -5
  6. data/README.md +2 -3
  7. data/gemfiles/rails_3.2_rspec_3.0.gemfile +2 -6
  8. data/gemfiles/rails_3.2_rspec_3.1.gemfile +2 -6
  9. data/gemfiles/rails_3.2_rspec_3.2.gemfile +2 -6
  10. data/gemfiles/{rails_3.2_rspec_2.99.gemfile → rails_3.2_rspec_3.3.gemfile} +3 -7
  11. data/gemfiles/rails_4.0_rspec_3.0.gemfile +2 -6
  12. data/gemfiles/rails_4.0_rspec_3.1.gemfile +2 -6
  13. data/gemfiles/rails_4.0_rspec_3.2.gemfile +2 -6
  14. data/gemfiles/{rails_4.0_rspec_2.99.gemfile → rails_4.0_rspec_3.3.gemfile} +3 -7
  15. data/gemfiles/rails_4.1_rspec_3.0.gemfile +2 -6
  16. data/gemfiles/rails_4.1_rspec_3.1.gemfile +2 -6
  17. data/gemfiles/rails_4.1_rspec_3.2.gemfile +2 -6
  18. data/gemfiles/{rails_4.1_rspec_2.99.gemfile → rails_4.1_rspec_3.3.gemfile} +3 -7
  19. data/gemfiles/rails_4.2_rspec_3.0.gemfile +2 -6
  20. data/gemfiles/rails_4.2_rspec_3.1.gemfile +2 -6
  21. data/gemfiles/rails_4.2_rspec_3.2.gemfile +2 -6
  22. data/gemfiles/{rails_4.2_rspec_2.99.gemfile → rails_4.2_rspec_3.3.gemfile} +3 -7
  23. data/lib/warp/action_matchers/create_matcher.rb +6 -14
  24. data/lib/warp/action_matchers/destroy_matcher.rb +6 -14
  25. data/lib/warp/action_matchers/matcher.rb +7 -1
  26. data/lib/warp/action_matchers/update_matcher.rb +6 -14
  27. data/lib/warp/controller_matchers/assign_matcher.rb +127 -48
  28. data/lib/warp/instrument.rb +8 -26
  29. data/lib/warp/matcher.rb +2 -27
  30. data/lib/warp/version.rb +2 -2
  31. data/spec/spec_helper.rb +0 -11
  32. data/spec/warp/action_matchers/create_matcher_spec.rb +1 -1
  33. data/spec/warp/action_matchers/destroy_matcher_spec.rb +1 -1
  34. data/spec/warp/action_matchers/update_matcher_spec.rb +1 -1
  35. data/spec/warp/controller_matchers/assign_matcher_spec.rb +132 -88
  36. metadata +7 -7
@@ -4,12 +4,12 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
4
4
  with_contexts do
5
5
  context "with implicit controller" do
6
6
  build_controller(:controller)
7
-
7
+
8
8
  let(:_controller) { controller }
9
9
 
10
10
  subject { matcher.tap {|m| m.matches?(Object.new) } }
11
11
  end
12
-
12
+
13
13
  context "with explicit controller" do
14
14
  build_controller(:other_controller)
15
15
  let(:controller) { double("fake controller") }
@@ -18,7 +18,7 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
18
18
 
19
19
  subject { matcher.tap {|m| m.matches?(other_controller) } }
20
20
  end
21
-
21
+
22
22
  behaviour do
23
23
  let(:matcher) { assign(:assign) }
24
24
 
@@ -34,7 +34,7 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
34
34
  end
35
35
 
36
36
  specify { expect(subject).to match(_controller) }
37
-
37
+
38
38
  describe_failure_message_when_negated do
39
39
  specify { expect(subject).to eq "expected @assign to not be assigned" }
40
40
  end
@@ -46,18 +46,13 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
46
46
  end
47
47
 
48
48
  specify { expect(subject).to_not match(_controller) }
49
-
49
+
50
50
  describe_failure_message do
51
51
  specify { expect(subject).to eq "expected @assign to be assigned" }
52
52
  end
53
53
  end
54
54
 
55
55
  describe "#with" do
56
- controller_action do
57
- @assign = spec.actual_assign_value
58
- end
59
-
60
- let(:actual_assign_value) { "foobar" }
61
56
  let(:expected_assign_value) { "foobar" }
62
57
 
63
58
  let(:matcher) { super().with(expected_assign_value) }
@@ -68,32 +63,47 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
68
63
  specify { expect(subject).to eq "assign @assign with #{expected_assign_value.inspect}" }
69
64
  end
70
65
 
71
- context "with the right value" do
72
- specify { expect(subject).to match(_controller) }
73
-
74
- describe_failure_message_when_negated do
75
- specify { expect(subject).to eq "expected @assign to not be assigned with #{expected_assign_value.inspect}" }
66
+ context "when assigned" do
67
+ controller_action do
68
+ @assign = spec.actual_assign_value
69
+ end
70
+
71
+ context "with the right value" do
72
+ let(:actual_assign_value) { expected_assign_value }
73
+
74
+ specify { expect(subject).to match(_controller) }
75
+
76
+ describe_failure_message_when_negated do
77
+ specify { expect(subject).to eq "expected @assign to not be assigned with #{expected_assign_value.inspect}" }
78
+ end
79
+ end
80
+
81
+ context "with the wrong value" do
82
+ let(:actual_assign_value) { "foobaz" }
83
+
84
+ specify { expect(subject).to_not match(_controller) }
85
+
86
+ describe_failure_message do
87
+ specify { expect(subject).to eq "expected @assign to be assigned with #{expected_assign_value.inspect} but was assigned with #{actual_assign_value.inspect}" }
88
+ end
76
89
  end
77
90
  end
78
91
 
79
- context "with the wrong value" do
80
- let(:expected_assign_value) { "foobaz" }
92
+ context "when not assigned" do
93
+ controller_action do
94
+ # no assign
95
+ end
81
96
 
82
97
  specify { expect(subject).to_not match(_controller) }
83
-
98
+
84
99
  describe_failure_message do
85
- specify { expect(subject).to eq "expected @assign to be assigned with #{expected_assign_value.inspect} but was assigned with #{actual_assign_value.inspect}" }
100
+ specify { expect(subject).to eq "expected @assign to be assigned with #{expected_assign_value.inspect} but was not assigned" }
86
101
  end
87
102
  end
88
103
  end
89
104
 
90
105
  describe "#with_a" do
91
- controller_action do
92
- @assign = spec.actual_assign_class.new
93
- end
94
-
95
- let(:actual_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "FooClass" } } }
96
- let(:expected_assign_class) { actual_assign_class }
106
+ let(:expected_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "FooClass" } } }
97
107
 
98
108
  let(:matcher) { super().with_a(expected_assign_class) }
99
109
 
@@ -103,40 +113,48 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
103
113
  specify { expect(subject).to eq "assign @assign with an instance of #{expected_assign_class.name}" }
104
114
  end
105
115
 
106
- context "with the right class" do
107
- specify { expect(subject).to match(_controller) }
108
-
109
- describe_failure_message_when_negated do
110
- specify { expect(subject).to eq "expected @assign to not be assigned with an instance of #{expected_assign_class.name}" }
116
+ context "when assigned" do
117
+ controller_action do
118
+ @assign = spec.actual_assign_class.new
119
+ end
120
+
121
+ context "with the right class" do
122
+ let(:actual_assign_class) { expected_assign_class }
123
+
124
+ specify { expect(subject).to match(_controller) }
125
+
126
+ describe_failure_message_when_negated do
127
+ specify { expect(subject).to eq "expected @assign to not be assigned with an instance of #{expected_assign_class.name}" }
128
+ end
129
+ end
130
+
131
+ context "with the wrong class" do
132
+ let(:actual_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "BarClass" } } }
133
+
134
+ specify { expect(subject).to_not match(_controller) }
135
+
136
+ describe_failure_message do
137
+ specify { expect(subject).to eq "expected @assign to be assigned with an instance of #{expected_assign_class.name} but was assigned with an instance of #{actual_assign_class.name}"
138
+ }
139
+ end
111
140
  end
112
141
  end
113
142
 
114
- context "with the wrong class" do
115
- let(:expected_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "BarClass" } } }
143
+ context "when not assigned" do
144
+ controller_action do
145
+ # no assign
146
+ end
116
147
 
117
148
  specify { expect(subject).to_not match(_controller) }
118
-
149
+
119
150
  describe_failure_message do
120
- specify { expect(subject).to eq "expected @assign to be assigned with an instance of #{expected_assign_class.name} but was assigned with an instance of #{actual_assign_class.name}"
121
- }
151
+ specify { expect(subject).to eq "expected @assign to be assigned with an instance of #{expected_assign_class.name} but was not assigned" }
122
152
  end
123
153
  end
124
154
  end
125
155
 
126
156
  describe "#with_a_new" do
127
- controller_action do
128
- @assign = spec.actual_assign_class.new
129
- end
130
-
131
- let(:actual_persisted?) { false }
132
- let(:actual_assign_class) do
133
- Class.new.tap do |klass|
134
- allow(klass).to receive(:name) { "FooClass" }
135
- allow_any_instance_of(klass).to receive(:persisted?) { actual_persisted? }
136
- end
137
- end
138
-
139
- let(:expected_assign_class) { actual_assign_class }
157
+ let(:expected_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "FooClass" } } }
140
158
 
141
159
  let(:matcher) { super().with_a_new(expected_assign_class) }
142
160
 
@@ -146,64 +164,90 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
146
164
  specify { expect(subject).to eq "assign @assign with a new instance of #{expected_assign_class.name}" }
147
165
  end
148
166
 
149
- context "with a new object" do
150
- let(:actual_persisted?) { false }
167
+ context "when assigned" do
168
+ controller_action do
169
+ @assign = spec.actual_assign_class.new
170
+ end
151
171
 
152
- context "with the right class" do
153
- specify { expect(subject).to match(_controller) }
172
+ let(:actual_assign_class) { expected_assign_class }
154
173
 
155
- describe_failure_message_when_negated do
156
- specify { expect(subject).to eq "expected @assign to not be assigned with a new instance of #{expected_assign_class.name}" }
174
+ before do
175
+ actual_assign_class.tap do |klass|
176
+ allow_any_instance_of(klass).to receive(:persisted?) { actual_persisted? }
157
177
  end
158
178
  end
159
179
 
160
- context "with a descendant class" do
161
- let(:actual_assign_class) do
162
- Class.new(super())
180
+ context "with a new object" do
181
+ let(:actual_persisted?) { false }
182
+
183
+ context "with the right class" do
184
+ specify { expect(subject).to match(_controller) }
185
+
186
+ describe_failure_message_when_negated do
187
+ specify { expect(subject).to eq "expected @assign to not be assigned with a new instance of #{expected_assign_class.name}" }
188
+ end
163
189
  end
164
190
 
165
- specify { expect(subject).to match(_controller) }
191
+ context "with a descendant class" do
192
+ let(:actual_assign_class) do
193
+ Class.new(super())
194
+ end
166
195
 
167
- describe_failure_message_when_negated do
168
- specify { expect(subject).to eq "expected @assign to not be assigned with a new instance of #{expected_assign_class.name}" }
169
- end
170
- end
196
+ specify { expect(subject).to match(_controller) }
171
197
 
172
- context "with the wrong class" do
173
- let(:expected_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "BarClass" } } }
198
+ describe_failure_message_when_negated do
199
+ specify { expect(subject).to eq "expected @assign to not be assigned with a new instance of #{expected_assign_class.name}" }
200
+ end
201
+ end
174
202
 
175
- specify { expect(subject).to_not match(_controller) }
176
-
177
- describe_failure_message do
178
- specify { expect(subject).to eq "expected @assign to be assigned with a new instance of #{expected_assign_class.name} but was assigned with a new instance of #{actual_assign_class.name}"
179
- }
203
+ context "with the wrong class" do
204
+ let(:actual_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "BarClass" } } }
205
+
206
+ specify { expect(subject).to_not match(_controller) }
207
+
208
+ describe_failure_message do
209
+ specify { expect(subject).to eq "expected @assign to be assigned with a new instance of #{expected_assign_class.name} but was assigned with a new instance of #{actual_assign_class.name}"
210
+ }
211
+ end
180
212
  end
181
213
  end
182
- end
183
214
 
184
- context "with a persisted object" do
185
- let(:actual_persisted?) { true }
215
+ context "with a persisted object" do
216
+ let(:actual_persisted?) { true }
186
217
 
187
- context "with the right class" do
188
- specify { expect(subject).to_not match(_controller) }
189
-
190
- describe_failure_message do
191
- specify { expect(subject).to eq "expected @assign to be assigned with a new instance of #{expected_assign_class.name} but was assigned with a persisted instance of #{actual_assign_class.name}"
192
- }
218
+ context "with the right class" do
219
+ specify { expect(subject).to_not match(_controller) }
220
+
221
+ describe_failure_message do
222
+ specify { expect(subject).to eq "expected @assign to be assigned with a new instance of #{expected_assign_class.name} but was assigned with a persisted instance of #{actual_assign_class.name}"
223
+ }
224
+ end
193
225
  end
194
- end
195
226
 
196
- context "with the wrong class" do
197
- let(:expected_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "BarClass" } } }
227
+ context "with the wrong class" do
228
+ let(:actual_assign_class) { Class.new.tap {|klass| allow(klass).to receive(:name) { "BarClass" } } }
198
229
 
199
- specify { expect(subject).to_not match(_controller) }
200
-
201
- describe_failure_message do
202
- specify { expect(subject).to eq "expected @assign to be assigned with a new instance of #{expected_assign_class.name} but was assigned with a persisted instance of #{actual_assign_class.name}"
203
- }
230
+ specify { expect(subject).to_not match(_controller) }
231
+
232
+ describe_failure_message do
233
+ specify { expect(subject).to eq "expected @assign to be assigned with a new instance of #{expected_assign_class.name} but was assigned with a persisted instance of #{actual_assign_class.name}"
234
+ }
235
+ end
204
236
  end
205
237
  end
206
238
  end
239
+
240
+ context "when not assigned" do
241
+ controller_action do
242
+ # no assign
243
+ end
244
+
245
+ specify { expect(subject).to_not match(_controller) }
246
+
247
+ describe_failure_message do
248
+ specify { expect(subject).to eq "expected @assign to be assigned with a new instance of #{expected_assign_class.name} but was not assigned" }
249
+ end
250
+ end
207
251
  end
208
252
 
209
253
  context "multiple assertions" do
@@ -225,10 +269,10 @@ describe Warp::ControllerMatchers::AssignMatcher, type: :controller do
225
269
  end
226
270
 
227
271
  behaviour do
228
- specify { expect{ subject }.to raise_error("Only one of .with, .with_a, and .with_a_new can be used with the assigns matcher.") }
272
+ specify { expect{ subject }.to raise_error(NoMethodError) }
229
273
  end
230
274
  end
231
275
  end
232
276
  end
233
277
  end
234
- end
278
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Drake-Brockman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -43,22 +43,22 @@ files:
43
43
  - LICENSE
44
44
  - README.md
45
45
  - Rakefile
46
- - gemfiles/rails_3.2_rspec_2.99.gemfile
47
46
  - gemfiles/rails_3.2_rspec_3.0.gemfile
48
47
  - gemfiles/rails_3.2_rspec_3.1.gemfile
49
48
  - gemfiles/rails_3.2_rspec_3.2.gemfile
50
- - gemfiles/rails_4.0_rspec_2.99.gemfile
49
+ - gemfiles/rails_3.2_rspec_3.3.gemfile
51
50
  - gemfiles/rails_4.0_rspec_3.0.gemfile
52
51
  - gemfiles/rails_4.0_rspec_3.1.gemfile
53
52
  - gemfiles/rails_4.0_rspec_3.2.gemfile
54
- - gemfiles/rails_4.1_rspec_2.99.gemfile
53
+ - gemfiles/rails_4.0_rspec_3.3.gemfile
55
54
  - gemfiles/rails_4.1_rspec_3.0.gemfile
56
55
  - gemfiles/rails_4.1_rspec_3.1.gemfile
57
56
  - gemfiles/rails_4.1_rspec_3.2.gemfile
58
- - gemfiles/rails_4.2_rspec_2.99.gemfile
57
+ - gemfiles/rails_4.1_rspec_3.3.gemfile
59
58
  - gemfiles/rails_4.2_rspec_3.0.gemfile
60
59
  - gemfiles/rails_4.2_rspec_3.1.gemfile
61
60
  - gemfiles/rails_4.2_rspec_3.2.gemfile
61
+ - gemfiles/rails_4.2_rspec_3.3.gemfile
62
62
  - lib/warp.rb
63
63
  - lib/warp/action_matchers.rb
64
64
  - lib/warp/action_matchers/create_matcher.rb
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.4.6
115
+ rubygems_version: 2.4.8
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Awesome RSpec matchers for testing your Rails applications.