warp 1.3.2 → 1.3.3
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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +18 -8
- data/Appraisals +3 -3
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -4
- data/README.md +10 -2
- data/gemfiles/rails_3.2_rspec_2.99.gemfile +1 -1
- data/gemfiles/{rails_3.2_rspec_2.14.gemfile → rails_3.2_rspec_3.0.gemfile} +2 -2
- data/gemfiles/rails_3.2_rspec_3.1.gemfile +1 -1
- data/gemfiles/rails_3.2_rspec_3.2.gemfile +24 -0
- data/gemfiles/rails_4.0_rspec_2.99.gemfile +1 -1
- data/gemfiles/{rails_4.0_rspec_2.14.gemfile → rails_4.0_rspec_3.0.gemfile} +2 -2
- data/gemfiles/rails_4.0_rspec_3.1.gemfile +1 -1
- data/gemfiles/rails_4.0_rspec_3.2.gemfile +24 -0
- data/gemfiles/rails_4.1_rspec_2.99.gemfile +1 -1
- data/gemfiles/{rails_4.1_rspec_2.14.gemfile → rails_4.1_rspec_3.0.gemfile} +2 -2
- data/gemfiles/rails_4.1_rspec_3.1.gemfile +1 -1
- data/gemfiles/{rails_4.2.rc1_rspec_2.14.gemfile → rails_4.1_rspec_3.2.gemfile} +6 -5
- data/gemfiles/{rails_4.2.rc1_rspec_2.99.gemfile → rails_4.2_rspec_2.99.gemfile} +4 -4
- data/gemfiles/rails_4.2_rspec_3.0.gemfile +24 -0
- data/gemfiles/{rails_4.2.rc1_rspec_3.1.gemfile → rails_4.2_rspec_3.1.gemfile} +4 -4
- data/gemfiles/rails_4.2_rspec_3.2.gemfile +24 -0
- data/lib/warp/action_matchers.rb +2 -1
- data/lib/warp/action_matchers/create_matcher.rb +7 -16
- data/lib/warp/action_matchers/destroy_matcher.rb +7 -16
- data/lib/warp/action_matchers/matcher.rb +12 -1
- data/lib/warp/action_matchers/update_matcher.rb +38 -0
- data/lib/warp/version.rb +1 -1
- data/spec/warp/action_matchers/create_matcher_spec.rb +4 -4
- data/spec/warp/action_matchers/destroy_matcher_spec.rb +3 -3
- data/spec/warp/action_matchers/update_matcher_spec.rb +61 -0
- metadata +16 -10
- data/Guardfile +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 234f92d48b702feb43c71ce8c211f33c0687a378
|
|
4
|
+
data.tar.gz: ca6886e9dc93730648b7a9452bd8a7b12c31df0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6eba1f4a1659d02da2cf3bc157988d615451d382ded9de35301042aa0f360b32dffc3052d33815bfbfdba82eb956823a1fc092f00ebefb60da614c95f59afbba
|
|
7
|
+
data.tar.gz: bff3a54600d2103708d7ce985a1bdd66c547392b07feb5570b8d2387653223e0f99be502939c9a02769c0ff752fc951d658bb98039849d1f78c9ec86bb02e588
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-2.1
|
|
1
|
+
ruby-2.2.1
|
data/.travis.yml
CHANGED
|
@@ -6,22 +6,32 @@ env:
|
|
|
6
6
|
|
|
7
7
|
rvm:
|
|
8
8
|
- 1.9.3
|
|
9
|
-
- 2.1
|
|
9
|
+
- 2.2.1
|
|
10
10
|
|
|
11
11
|
gemfile:
|
|
12
|
-
- gemfiles/rails_3.2_rspec_2.14.gemfile
|
|
13
12
|
- gemfiles/rails_3.2_rspec_2.99.gemfile
|
|
13
|
+
- gemfiles/rails_3.2_rspec_3.0.gemfile
|
|
14
14
|
- gemfiles/rails_3.2_rspec_3.1.gemfile
|
|
15
|
-
- gemfiles/
|
|
15
|
+
- gemfiles/rails_3.2_rspec_3.2.gemfile
|
|
16
16
|
- gemfiles/rails_4.0_rspec_2.99.gemfile
|
|
17
|
+
- gemfiles/rails_4.0_rspec_3.0.gemfile
|
|
17
18
|
- gemfiles/rails_4.0_rspec_3.1.gemfile
|
|
18
|
-
- gemfiles/rails_4.
|
|
19
|
+
- gemfiles/rails_4.0_rspec_3.2.gemfile
|
|
19
20
|
- gemfiles/rails_4.1_rspec_2.99.gemfile
|
|
21
|
+
- gemfiles/rails_4.1_rspec_3.0.gemfile
|
|
20
22
|
- gemfiles/rails_4.1_rspec_3.1.gemfile
|
|
21
|
-
- gemfiles/rails_4.2.
|
|
22
|
-
- gemfiles/rails_4.
|
|
23
|
-
- gemfiles/rails_4.
|
|
23
|
+
- gemfiles/rails_4.1_rspec_3.2.gemfile
|
|
24
|
+
- gemfiles/rails_4.2_rspec_2.99.gemfile
|
|
25
|
+
- gemfiles/rails_4.2_rspec_3.0.gemfile
|
|
26
|
+
- gemfiles/rails_4.2_rspec_3.1.gemfile
|
|
27
|
+
- gemfiles/rails_4.2_rspec_3.2.gemfile
|
|
28
|
+
|
|
24
29
|
|
|
25
30
|
bundler_args: --without tools
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
before_install:
|
|
33
|
+
- gem uninstall bundler
|
|
34
|
+
- gem install bundler
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
script: bundle exec rspec -b
|
data/Appraisals
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
["3.2", "4.0", "4.1", "4.2
|
|
2
|
-
["2.
|
|
1
|
+
["3.2", "4.0", "4.1", "4.2"].each do |rails|
|
|
2
|
+
["2.99", "3.0", "3.1", "3.2"].each do |rspec|
|
|
3
3
|
appraise "rails-#{rails}-rspec-#{rspec}" do
|
|
4
4
|
rails_v = "~> #{rails}"
|
|
5
5
|
rspec_v = "~> #{rspec}"
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
gem "rspec", rspec_v
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
|
-
end
|
|
15
|
+
end
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
|
@@ -14,8 +14,6 @@ gem "simplecov", require: false
|
|
|
14
14
|
gem "coveralls", require: false
|
|
15
15
|
|
|
16
16
|
group :tools do
|
|
17
|
-
gem "
|
|
18
|
-
gem "guard-rspec"
|
|
19
|
-
gem "byebug", platform: [:ruby_20, :ruby_21]
|
|
17
|
+
gem "byebug", platform: [:ruby_20, :ruby_21, :ruby_22]
|
|
20
18
|
gem "debugger", platform: :ruby_19
|
|
21
|
-
end
|
|
19
|
+
end
|
data/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Warp provides a selection of inteligent RSpec matchers for your model, controlle
|
|
|
10
10
|
Warp's matchers are written to be intuitive, easy to use, and to avoid testing Rails itself. The matchers also take advantage of RSpec's [composing matchers](http://www.rubydoc.info/gems/rspec-expectations/frames#Composing_Matchers) wherever possible.
|
|
11
11
|
|
|
12
12
|
Compatible with:
|
|
13
|
-
- Ruby 1.9.
|
|
13
|
+
- Ruby 1.9.3 and greater
|
|
14
14
|
- Rails 3.2 and greater
|
|
15
15
|
- RSpec 2.99 and greater
|
|
16
16
|
|
|
@@ -218,7 +218,7 @@ Ensures that a `validates_uniqueness_of` validator is present on the attribute.
|
|
|
218
218
|
specify { expect(user).to validate_uniqueness_of(:email, scope: :company) }
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
###
|
|
221
|
+
### Action Matchers
|
|
222
222
|
|
|
223
223
|
#### create
|
|
224
224
|
|
|
@@ -228,6 +228,14 @@ Ensures that a record is created.
|
|
|
228
228
|
specify { expect{post :create, params}.to create(Post) }
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
+
#### update
|
|
232
|
+
|
|
233
|
+
Ensures that a record is updated.
|
|
234
|
+
|
|
235
|
+
```ruby
|
|
236
|
+
specify { expect{post :update, params}.to update(Post) }
|
|
237
|
+
```
|
|
238
|
+
|
|
231
239
|
#### destroy
|
|
232
240
|
|
|
233
241
|
Ensures that a record is destroyed.
|
|
@@ -12,12 +12,12 @@ gem "coveralls", :require => false
|
|
|
12
12
|
gem "activesupport", "~> 3.2", :require => "active_support/all"
|
|
13
13
|
gem "actionpack", "~> 3.2", :require => "action_controller"
|
|
14
14
|
gem "activerecord", "~> 3.2", :require => "active_record"
|
|
15
|
-
gem "rspec", "~>
|
|
15
|
+
gem "rspec", "~> 3.0"
|
|
16
16
|
|
|
17
17
|
group :tools do
|
|
18
18
|
gem "guard"
|
|
19
19
|
gem "guard-rspec"
|
|
20
|
-
gem "byebug", :platform => [:ruby_20, :ruby_21]
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
21
|
gem "debugger", :platform => :ruby_19
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "bundler"
|
|
6
|
+
gem "appraisal"
|
|
7
|
+
gem "jamjar"
|
|
8
|
+
gem "rake"
|
|
9
|
+
gem "fuubar"
|
|
10
|
+
gem "simplecov", :require => false
|
|
11
|
+
gem "coveralls", :require => false
|
|
12
|
+
gem "activesupport", "~> 3.2", :require => "active_support/all"
|
|
13
|
+
gem "actionpack", "~> 3.2", :require => "action_controller"
|
|
14
|
+
gem "activerecord", "~> 3.2", :require => "active_record"
|
|
15
|
+
gem "rspec", "~> 3.2"
|
|
16
|
+
|
|
17
|
+
group :tools do
|
|
18
|
+
gem "guard"
|
|
19
|
+
gem "guard-rspec"
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
|
+
gem "debugger", :platform => :ruby_19
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
gemspec :path => "../"
|
|
@@ -12,12 +12,12 @@ gem "coveralls", :require => false
|
|
|
12
12
|
gem "activesupport", "~> 4.0", :require => "active_support/all"
|
|
13
13
|
gem "actionpack", "~> 4.0", :require => "action_controller"
|
|
14
14
|
gem "activerecord", "~> 4.0", :require => "active_record"
|
|
15
|
-
gem "rspec", "~>
|
|
15
|
+
gem "rspec", "~> 3.0"
|
|
16
16
|
|
|
17
17
|
group :tools do
|
|
18
18
|
gem "guard"
|
|
19
19
|
gem "guard-rspec"
|
|
20
|
-
gem "byebug", :platform => [:ruby_20, :ruby_21]
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
21
|
gem "debugger", :platform => :ruby_19
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "bundler"
|
|
6
|
+
gem "appraisal"
|
|
7
|
+
gem "jamjar"
|
|
8
|
+
gem "rake"
|
|
9
|
+
gem "fuubar"
|
|
10
|
+
gem "simplecov", :require => false
|
|
11
|
+
gem "coveralls", :require => false
|
|
12
|
+
gem "activesupport", "~> 4.0", :require => "active_support/all"
|
|
13
|
+
gem "actionpack", "~> 4.0", :require => "action_controller"
|
|
14
|
+
gem "activerecord", "~> 4.0", :require => "active_record"
|
|
15
|
+
gem "rspec", "~> 3.2"
|
|
16
|
+
|
|
17
|
+
group :tools do
|
|
18
|
+
gem "guard"
|
|
19
|
+
gem "guard-rspec"
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
|
+
gem "debugger", :platform => :ruby_19
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
gemspec :path => "../"
|
|
@@ -13,12 +13,12 @@ gem "activesupport", "~> 4.1", :require => "active_support/all"
|
|
|
13
13
|
gem "actionpack", "~> 4.1", :require => "action_controller"
|
|
14
14
|
gem "activerecord", "~> 4.1", :require => "active_record"
|
|
15
15
|
gem "actionview", "~> 4.1", :require => "action_view"
|
|
16
|
-
gem "rspec", "~>
|
|
16
|
+
gem "rspec", "~> 3.0"
|
|
17
17
|
|
|
18
18
|
group :tools do
|
|
19
19
|
gem "guard"
|
|
20
20
|
gem "guard-rspec"
|
|
21
|
-
gem "byebug", :platform => [:ruby_20, :ruby_21]
|
|
21
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
22
22
|
gem "debugger", :platform => :ruby_19
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -9,15 +9,16 @@ gem "rake"
|
|
|
9
9
|
gem "fuubar"
|
|
10
10
|
gem "simplecov", :require => false
|
|
11
11
|
gem "coveralls", :require => false
|
|
12
|
-
gem "activesupport", "~> 4.
|
|
13
|
-
gem "actionpack", "~> 4.
|
|
14
|
-
gem "activerecord", "~> 4.
|
|
15
|
-
gem "
|
|
12
|
+
gem "activesupport", "~> 4.1", :require => "active_support/all"
|
|
13
|
+
gem "actionpack", "~> 4.1", :require => "action_controller"
|
|
14
|
+
gem "activerecord", "~> 4.1", :require => "active_record"
|
|
15
|
+
gem "actionview", "~> 4.1", :require => "action_view"
|
|
16
|
+
gem "rspec", "~> 3.2"
|
|
16
17
|
|
|
17
18
|
group :tools do
|
|
18
19
|
gem "guard"
|
|
19
20
|
gem "guard-rspec"
|
|
20
|
-
gem "byebug", :platform => [:ruby_20, :ruby_21]
|
|
21
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
22
|
gem "debugger", :platform => :ruby_19
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -9,15 +9,15 @@ gem "rake"
|
|
|
9
9
|
gem "fuubar"
|
|
10
10
|
gem "simplecov", :require => false
|
|
11
11
|
gem "coveralls", :require => false
|
|
12
|
-
gem "activesupport", "~> 4.2
|
|
13
|
-
gem "actionpack", "~> 4.2
|
|
14
|
-
gem "activerecord", "~> 4.2
|
|
12
|
+
gem "activesupport", "~> 4.2", :require => "active_support/all"
|
|
13
|
+
gem "actionpack", "~> 4.2", :require => "action_controller"
|
|
14
|
+
gem "activerecord", "~> 4.2", :require => "active_record"
|
|
15
15
|
gem "rspec", "~> 2.99"
|
|
16
16
|
|
|
17
17
|
group :tools do
|
|
18
18
|
gem "guard"
|
|
19
19
|
gem "guard-rspec"
|
|
20
|
-
gem "byebug", :platform => [:ruby_20, :ruby_21]
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
21
|
gem "debugger", :platform => :ruby_19
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "bundler"
|
|
6
|
+
gem "appraisal"
|
|
7
|
+
gem "jamjar"
|
|
8
|
+
gem "rake"
|
|
9
|
+
gem "fuubar"
|
|
10
|
+
gem "simplecov", :require => false
|
|
11
|
+
gem "coveralls", :require => false
|
|
12
|
+
gem "activesupport", "~> 4.2", :require => "active_support/all"
|
|
13
|
+
gem "actionpack", "~> 4.2", :require => "action_controller"
|
|
14
|
+
gem "activerecord", "~> 4.2", :require => "active_record"
|
|
15
|
+
gem "rspec", "~> 3.0"
|
|
16
|
+
|
|
17
|
+
group :tools do
|
|
18
|
+
gem "guard"
|
|
19
|
+
gem "guard-rspec"
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
|
+
gem "debugger", :platform => :ruby_19
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
gemspec :path => "../"
|
|
@@ -9,15 +9,15 @@ gem "rake"
|
|
|
9
9
|
gem "fuubar"
|
|
10
10
|
gem "simplecov", :require => false
|
|
11
11
|
gem "coveralls", :require => false
|
|
12
|
-
gem "activesupport", "~> 4.2
|
|
13
|
-
gem "actionpack", "~> 4.2
|
|
14
|
-
gem "activerecord", "~> 4.2
|
|
12
|
+
gem "activesupport", "~> 4.2", :require => "active_support/all"
|
|
13
|
+
gem "actionpack", "~> 4.2", :require => "action_controller"
|
|
14
|
+
gem "activerecord", "~> 4.2", :require => "active_record"
|
|
15
15
|
gem "rspec", "~> 3.1"
|
|
16
16
|
|
|
17
17
|
group :tools do
|
|
18
18
|
gem "guard"
|
|
19
19
|
gem "guard-rspec"
|
|
20
|
-
gem "byebug", :platform => [:ruby_20, :ruby_21]
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
21
|
gem "debugger", :platform => :ruby_19
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "bundler"
|
|
6
|
+
gem "appraisal"
|
|
7
|
+
gem "jamjar"
|
|
8
|
+
gem "rake"
|
|
9
|
+
gem "fuubar"
|
|
10
|
+
gem "simplecov", :require => false
|
|
11
|
+
gem "coveralls", :require => false
|
|
12
|
+
gem "activesupport", "~> 4.2", :require => "active_support/all"
|
|
13
|
+
gem "actionpack", "~> 4.2", :require => "action_controller"
|
|
14
|
+
gem "activerecord", "~> 4.2", :require => "active_record"
|
|
15
|
+
gem "rspec", "~> 3.2"
|
|
16
|
+
|
|
17
|
+
group :tools do
|
|
18
|
+
gem "guard"
|
|
19
|
+
gem "guard-rspec"
|
|
20
|
+
gem "byebug", :platform => [:ruby_20, :ruby_21, :ruby_22]
|
|
21
|
+
gem "debugger", :platform => :ruby_19
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
gemspec :path => "../"
|
data/lib/warp/action_matchers.rb
CHANGED
|
@@ -3,8 +3,9 @@ unless defined?(ActiveModel)
|
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
require "warp/action_matchers/create_matcher"
|
|
6
|
+
require "warp/action_matchers/update_matcher"
|
|
6
7
|
require "warp/action_matchers/destroy_matcher"
|
|
7
8
|
|
|
8
9
|
RSpec.configure do |config|
|
|
9
10
|
config.include Warp::ActionMatchers
|
|
10
|
-
end
|
|
11
|
+
end
|
|
@@ -4,10 +4,12 @@ require "warp/instrument"
|
|
|
4
4
|
module Warp
|
|
5
5
|
module ActionMatchers
|
|
6
6
|
class CreateMatcher < Warp::ActionMatchers::Matcher
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
def self.instrument_method
|
|
8
|
+
if ActiveRecord::Base.private_method_defined?(:_create_record)
|
|
9
|
+
:_create_record
|
|
10
|
+
else
|
|
11
|
+
:create
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
attr_reader :model
|
|
@@ -16,17 +18,6 @@ module Warp
|
|
|
16
18
|
@model = model
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def matches?(actual)
|
|
20
|
-
check_callable!(actual)
|
|
21
|
-
|
|
22
|
-
instrument = Warp::Instrument.for(model, CREATE_METHOD)
|
|
23
|
-
|
|
24
|
-
instrument.reset
|
|
25
|
-
instrument.run { actual.call }
|
|
26
|
-
|
|
27
|
-
instrument.calls.size > 0
|
|
28
|
-
end
|
|
29
|
-
|
|
30
21
|
def description
|
|
31
22
|
"create a #{model_name}"
|
|
32
23
|
end
|
|
@@ -44,4 +35,4 @@ module Warp
|
|
|
44
35
|
CreateMatcher.new(model)
|
|
45
36
|
end
|
|
46
37
|
end
|
|
47
|
-
end
|
|
38
|
+
end
|
|
@@ -4,10 +4,12 @@ require "warp/instrument"
|
|
|
4
4
|
module Warp
|
|
5
5
|
module ActionMatchers
|
|
6
6
|
class DestroyMatcher < Warp::ActionMatchers::Matcher
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
def self.instrument_method
|
|
8
|
+
if ActiveRecord::Base.private_method_defined?(:destroy_row)
|
|
9
|
+
:destroy_row
|
|
10
|
+
else
|
|
11
|
+
:destroy
|
|
12
|
+
end
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
attr_reader :model
|
|
@@ -16,17 +18,6 @@ module Warp
|
|
|
16
18
|
@model = model
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def matches?(actual)
|
|
20
|
-
check_callable!(actual)
|
|
21
|
-
|
|
22
|
-
instrument = Warp::Instrument.for(model, DESTROY_METHOD)
|
|
23
|
-
|
|
24
|
-
instrument.reset
|
|
25
|
-
instrument.run { actual.call }
|
|
26
|
-
|
|
27
|
-
instrument.calls.size > 0
|
|
28
|
-
end
|
|
29
|
-
|
|
30
21
|
def description
|
|
31
22
|
"destroy a #{model_name}"
|
|
32
23
|
end
|
|
@@ -44,4 +35,4 @@ module Warp
|
|
|
44
35
|
DestroyMatcher.new(model)
|
|
45
36
|
end
|
|
46
37
|
end
|
|
47
|
-
end
|
|
38
|
+
end
|
|
@@ -3,6 +3,17 @@ require "warp/matcher"
|
|
|
3
3
|
module Warp
|
|
4
4
|
module ActionMatchers
|
|
5
5
|
class Matcher < Warp::Matcher
|
|
6
|
+
def matches?(actual)
|
|
7
|
+
check_callable!(actual)
|
|
8
|
+
|
|
9
|
+
instrument = Warp::Instrument.for(model, self.class.instrument_method)
|
|
10
|
+
|
|
11
|
+
instrument.reset
|
|
12
|
+
instrument.run { actual.call }
|
|
13
|
+
|
|
14
|
+
instrument.calls.size > 0
|
|
15
|
+
end
|
|
16
|
+
|
|
6
17
|
private
|
|
7
18
|
|
|
8
19
|
def check_callable!(object)
|
|
@@ -16,4 +27,4 @@ module Warp
|
|
|
16
27
|
end
|
|
17
28
|
end
|
|
18
29
|
end
|
|
19
|
-
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require "warp/action_matchers/matcher"
|
|
2
|
+
require "warp/instrument"
|
|
3
|
+
|
|
4
|
+
module Warp
|
|
5
|
+
module ActionMatchers
|
|
6
|
+
class UpdateMatcher < Warp::ActionMatchers::Matcher
|
|
7
|
+
def self.instrument_method
|
|
8
|
+
if ActiveRecord::Base.private_method_defined?(:_create_record)
|
|
9
|
+
:_update_record
|
|
10
|
+
else
|
|
11
|
+
:update
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
attr_reader :model
|
|
16
|
+
|
|
17
|
+
def initialize(model)
|
|
18
|
+
@model = model
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def description
|
|
22
|
+
"update a #{model_name}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def failure_message
|
|
26
|
+
"expected a #{model_name} to be updated"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def failure_message_when_negated
|
|
30
|
+
"expected no #{model_name} to be updated"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update(model)
|
|
35
|
+
UpdateMatcher.new(model)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/warp/version.rb
CHANGED
|
@@ -9,7 +9,7 @@ describe Warp::ActionMatchers::CreateMatcher do
|
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
before { Warp::Instrument.for(model, Warp::ActionMatchers::CreateMatcher
|
|
12
|
+
before { Warp::Instrument.for(model, Warp::ActionMatchers::CreateMatcher.instrument_method).calls << Object.new }
|
|
13
13
|
|
|
14
14
|
subject { create(model) }
|
|
15
15
|
|
|
@@ -24,14 +24,14 @@ describe Warp::ActionMatchers::CreateMatcher do
|
|
|
24
24
|
|
|
25
25
|
behaviour do
|
|
26
26
|
context "with a valid record" do
|
|
27
|
-
let(:params) { {foo: "bar"} }
|
|
27
|
+
let(:params) { {foo: "bar"} }
|
|
28
28
|
|
|
29
29
|
specify { expect(subject).to match block }
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
context "with an invalid record" do
|
|
33
33
|
let(:params) { {} }
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
specify { expect(subject).to_not match block }
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -56,4 +56,4 @@ describe Warp::ActionMatchers::CreateMatcher do
|
|
|
56
56
|
describe_failure_message_when_negated do
|
|
57
57
|
specify { expect(subject).to eq "expected no TestModel to be created" }
|
|
58
58
|
end
|
|
59
|
-
end
|
|
59
|
+
end
|
|
@@ -5,7 +5,7 @@ describe Warp::ActionMatchers::DestroyMatcher do
|
|
|
5
5
|
|
|
6
6
|
let!(:instance) { model.create }
|
|
7
7
|
|
|
8
|
-
before { Warp::Instrument.for(model, Warp::ActionMatchers::DestroyMatcher
|
|
8
|
+
before { Warp::Instrument.for(model, Warp::ActionMatchers::DestroyMatcher.instrument_method).calls << Object.new }
|
|
9
9
|
|
|
10
10
|
subject { destroy(model) }
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ describe Warp::ActionMatchers::DestroyMatcher do
|
|
|
18
18
|
let(:block) { -> { model.destroy_all } }
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
behaviour do
|
|
21
|
+
behaviour do
|
|
22
22
|
specify { expect(subject).to match block }
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -42,4 +42,4 @@ describe Warp::ActionMatchers::DestroyMatcher do
|
|
|
42
42
|
describe_failure_message_when_negated do
|
|
43
43
|
specify { expect(subject).to eq "expected no TestModel to be destroyed" }
|
|
44
44
|
end
|
|
45
|
-
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Warp::ActionMatchers::UpdateMatcher do
|
|
4
|
+
let(:model) do
|
|
5
|
+
JamJar.model do
|
|
6
|
+
column :foo, :string
|
|
7
|
+
|
|
8
|
+
validates :foo, presence: true
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before { Warp::Instrument.for(model, Warp::ActionMatchers::UpdateMatcher.instrument_method).calls << Object.new }
|
|
13
|
+
|
|
14
|
+
let(:instance) { model.create(foo: "bar") }
|
|
15
|
+
|
|
16
|
+
subject { update(model) }
|
|
17
|
+
|
|
18
|
+
with_contexts do
|
|
19
|
+
context "when updated with #update_attributes" do
|
|
20
|
+
let(:block) { -> { instance.update_attributes(params) } }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "when updated with #save" do
|
|
24
|
+
let(:block) { -> { instance.foo = params[:foo]; instance.save } }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
behaviour do
|
|
28
|
+
context "with a valid record" do
|
|
29
|
+
let(:params) { {foo: "baz"} }
|
|
30
|
+
|
|
31
|
+
specify { expect(subject).to match block }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "with an invalid record" do
|
|
35
|
+
let(:params) { {foo: nil} }
|
|
36
|
+
|
|
37
|
+
specify { expect(subject).to_not match block }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context "when nothing is updated" do
|
|
43
|
+
let(:block) { -> { return } }
|
|
44
|
+
|
|
45
|
+
specify { expect(subject).to_not match block }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#desciption" do
|
|
49
|
+
subject { super().description }
|
|
50
|
+
|
|
51
|
+
specify { expect(subject).to eq "update a TestModel" }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe_failure_message do
|
|
55
|
+
specify { expect(subject).to eq "expected a TestModel to be updated" }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe_failure_message_when_negated do
|
|
59
|
+
specify { expect(subject).to eq "expected no TestModel to be updated" }
|
|
60
|
+
end
|
|
61
|
+
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.
|
|
4
|
+
version: 1.3.3
|
|
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:
|
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -40,27 +40,31 @@ files:
|
|
|
40
40
|
- Appraisals
|
|
41
41
|
- CHANGELOG.md
|
|
42
42
|
- Gemfile
|
|
43
|
-
- Guardfile
|
|
44
43
|
- LICENSE
|
|
45
44
|
- README.md
|
|
46
45
|
- Rakefile
|
|
47
|
-
- gemfiles/rails_3.2_rspec_2.14.gemfile
|
|
48
46
|
- gemfiles/rails_3.2_rspec_2.99.gemfile
|
|
47
|
+
- gemfiles/rails_3.2_rspec_3.0.gemfile
|
|
49
48
|
- gemfiles/rails_3.2_rspec_3.1.gemfile
|
|
50
|
-
- gemfiles/
|
|
49
|
+
- gemfiles/rails_3.2_rspec_3.2.gemfile
|
|
51
50
|
- gemfiles/rails_4.0_rspec_2.99.gemfile
|
|
51
|
+
- gemfiles/rails_4.0_rspec_3.0.gemfile
|
|
52
52
|
- gemfiles/rails_4.0_rspec_3.1.gemfile
|
|
53
|
-
- gemfiles/rails_4.
|
|
53
|
+
- gemfiles/rails_4.0_rspec_3.2.gemfile
|
|
54
54
|
- gemfiles/rails_4.1_rspec_2.99.gemfile
|
|
55
|
+
- gemfiles/rails_4.1_rspec_3.0.gemfile
|
|
55
56
|
- gemfiles/rails_4.1_rspec_3.1.gemfile
|
|
56
|
-
- gemfiles/rails_4.2.
|
|
57
|
-
- gemfiles/rails_4.
|
|
58
|
-
- gemfiles/rails_4.
|
|
57
|
+
- gemfiles/rails_4.1_rspec_3.2.gemfile
|
|
58
|
+
- gemfiles/rails_4.2_rspec_2.99.gemfile
|
|
59
|
+
- gemfiles/rails_4.2_rspec_3.0.gemfile
|
|
60
|
+
- gemfiles/rails_4.2_rspec_3.1.gemfile
|
|
61
|
+
- gemfiles/rails_4.2_rspec_3.2.gemfile
|
|
59
62
|
- lib/warp.rb
|
|
60
63
|
- lib/warp/action_matchers.rb
|
|
61
64
|
- lib/warp/action_matchers/create_matcher.rb
|
|
62
65
|
- lib/warp/action_matchers/destroy_matcher.rb
|
|
63
66
|
- lib/warp/action_matchers/matcher.rb
|
|
67
|
+
- lib/warp/action_matchers/update_matcher.rb
|
|
64
68
|
- lib/warp/controller_matchers.rb
|
|
65
69
|
- lib/warp/controller_matchers/assign_matcher.rb
|
|
66
70
|
- lib/warp/controller_matchers/set_flash_matcher.rb
|
|
@@ -80,6 +84,7 @@ files:
|
|
|
80
84
|
- spec/support/with_contexts_helpers.rb
|
|
81
85
|
- spec/warp/action_matchers/create_matcher_spec.rb
|
|
82
86
|
- spec/warp/action_matchers/destroy_matcher_spec.rb
|
|
87
|
+
- spec/warp/action_matchers/update_matcher_spec.rb
|
|
83
88
|
- spec/warp/controller_matchers/assign_matcher_spec.rb
|
|
84
89
|
- spec/warp/controller_matchers/set_flash_matcher_spec.rb
|
|
85
90
|
- spec/warp/instrument_spec.rb
|
|
@@ -107,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
107
112
|
version: '0'
|
|
108
113
|
requirements: []
|
|
109
114
|
rubyforge_project:
|
|
110
|
-
rubygems_version: 2.4.
|
|
115
|
+
rubygems_version: 2.4.6
|
|
111
116
|
signing_key:
|
|
112
117
|
specification_version: 4
|
|
113
118
|
summary: Awesome RSpec matchers for testing your Rails applications.
|
|
@@ -119,6 +124,7 @@ test_files:
|
|
|
119
124
|
- spec/support/with_contexts_helpers.rb
|
|
120
125
|
- spec/warp/action_matchers/create_matcher_spec.rb
|
|
121
126
|
- spec/warp/action_matchers/destroy_matcher_spec.rb
|
|
127
|
+
- spec/warp/action_matchers/update_matcher_spec.rb
|
|
122
128
|
- spec/warp/controller_matchers/assign_matcher_spec.rb
|
|
123
129
|
- spec/warp/controller_matchers/set_flash_matcher_spec.rb
|
|
124
130
|
- spec/warp/instrument_spec.rb
|