custom_rspec_matchers 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +41 -2
- data/custom_rspec_matchers.gemspec +2 -2
- data/lib/custom_rspec_matchers/matchers/filter_matcher.rb +13 -3
- data/lib/custom_rspec_matchers.rb +1 -0
- data/spec/custom_rspec_matchers/controllers/foo_controller_spec.rb +15 -18
- data/spec/custom_rspec_matchers/matchers/filter_matcher_spec.rb +1 -1
- metadata +4 -4
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,46 @@
|
|
1
1
|
= custom_rspec_matchers
|
2
2
|
|
3
|
-
|
3
|
+
This project contains a few custom rspec matchers that we have built to help us with our project.
|
4
|
+
|
5
|
+
== Active Model Callback Examples
|
6
|
+
|
7
|
+
describe Duck do
|
8
|
+
|
9
|
+
it { should have_after_create_callback(:after_create_callback) }
|
10
|
+
it { should have_around_create_callback(:around_create_callback) }
|
11
|
+
it { should have_before_create_callback(:before_create_callback) }
|
12
|
+
|
13
|
+
it { should have_after_save_callback(:after_save_callback) }
|
14
|
+
it { should have_around_save_callback(:around_save_callback) }
|
15
|
+
it { should have_before_save_callback(:before_save_callback) }
|
16
|
+
|
17
|
+
it { should have_after_update_callback(:after_update_callback) }
|
18
|
+
it { should have_around_update_callback(:around_update_callback) }
|
19
|
+
it { should have_before_update_callback(:before_update_callback) }
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
== Action Controller Filter Examples
|
25
|
+
|
26
|
+
# checks for an after filter that does not specify the only or except option
|
27
|
+
it { should include_after_filter(:for_all_methods) }
|
28
|
+
|
29
|
+
# checks for an after filter that specifies the only option
|
30
|
+
it { should include_after_filter(:after_filter_only_create).only_on(:create) }
|
31
|
+
|
32
|
+
# checks for an after filter that specifies the only option with more than one methods
|
33
|
+
it { should include_after_filter(:after_filter_only_show_and_create).only_on([:show, :create]) }
|
34
|
+
|
35
|
+
# checks for an after filter with except specified for one method
|
36
|
+
it { should include_after_filter(:after_filter_except_create).except_on(:create) }
|
37
|
+
|
38
|
+
# checks for an after filter with except specified for more than one method
|
39
|
+
it { should include_after_filter(:after_filter_except_show_and_create).except_on([:show, :create]) }
|
40
|
+
|
41
|
+
# also works for before filter
|
42
|
+
it { should include_before_filter(:before_filter_only_show_and_create).only_on([:show, :create]) }
|
43
|
+
it { should include_before_filter(:before_filter_except_show_and_create).except_on([:show, :create]) }
|
4
44
|
|
5
45
|
== Note on Patches/Pull Requests
|
6
46
|
|
@@ -10,7 +50,6 @@ Description goes here.
|
|
10
50
|
future version unintentionally.
|
11
51
|
* Commit, do not mess with rakefile, version, or history.
|
12
52
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
14
53
|
|
15
54
|
== Copyright
|
16
55
|
|
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "custom_rspec_matchers"
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.2'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["kenny ortmann", "matt simpson", "amos king"]
|
9
9
|
s.email = ['kenny.ortmann@gmail.com', 'matt.simpson@asolutions.com', 'amos.king@asolutions.com']
|
10
|
-
s.homepage = ""
|
10
|
+
s.homepage = "https://github.com/asynchrony/custom_rspec_matchers"
|
11
11
|
s.summary = %q{a few custom rspec matchers we have created to help with testing}
|
12
12
|
s.description = %q{custopm rspec mathcers }
|
13
13
|
|
@@ -63,12 +63,22 @@ module CustomRspecMatchers
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
66
|
+
def have_before_filter(expected_filter)
|
67
67
|
FilterMatcher.new :before, expected_filter
|
68
68
|
end
|
69
|
+
|
70
|
+
def include_before_filter(expected_filter)
|
71
|
+
RSpec.deprecate("include_before_filter","have_before_filter")
|
72
|
+
have_before_filter(expected_filter)
|
73
|
+
end
|
69
74
|
|
70
|
-
def
|
75
|
+
def have_after_filter(expected_filter)
|
71
76
|
FilterMatcher.new :after, expected_filter
|
72
|
-
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def include_after_filter(expected_filter)
|
80
|
+
RSpec.deprecate("include_after_filter","have_after_filter")
|
81
|
+
have_after_filter(expected_filter)
|
82
|
+
end
|
73
83
|
end
|
74
84
|
end
|
@@ -2,51 +2,48 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FooController do
|
4
4
|
describe "before all methods filter" do
|
5
|
-
it { should
|
5
|
+
it { should have_before_filter(:for_all_methods) }
|
6
6
|
end
|
7
7
|
describe "after all methods filter" do
|
8
|
-
it { should
|
8
|
+
it { should have_after_filter(:for_all_methods) }
|
9
9
|
end
|
10
10
|
describe "after_filters only create" do
|
11
|
-
it { should
|
11
|
+
it { should have_after_filter(:after_filter_only_create).only_on(:create) }
|
12
12
|
end
|
13
13
|
describe "after_filters only show" do
|
14
|
-
it { should
|
14
|
+
it { should have_after_filter(:after_filter_only_show).only_on(:show) }
|
15
15
|
end
|
16
16
|
describe "after_filters only show and create" do
|
17
|
-
it { should
|
17
|
+
it { should have_after_filter(:after_filter_only_show_and_create).only_on([:show, :create]) }
|
18
18
|
end
|
19
19
|
describe "after_filters only show and create without array" do
|
20
|
-
it { should
|
20
|
+
it { should have_after_filter(:after_filter_only_show_and_create).only_on(:show, :create) }
|
21
21
|
end
|
22
22
|
describe "after_filters only show and create with params flipped" do
|
23
|
-
it { should
|
23
|
+
it { should have_after_filter(:after_filter_only_show_and_create).only_on([:create, :show]) }
|
24
24
|
end
|
25
25
|
describe "after_filters except create" do
|
26
|
-
it { should
|
26
|
+
it { should have_after_filter(:after_filter_except_create).except_on(:create) }
|
27
27
|
end
|
28
28
|
describe "after_filters except show" do
|
29
|
-
it { should
|
29
|
+
it { should have_after_filter(:after_filter_except_show).except_on(:show) }
|
30
30
|
end
|
31
31
|
describe "after_filters except show and create" do
|
32
|
-
it { should
|
32
|
+
it { should have_after_filter(:after_filter_except_show_and_create).except_on([:show, :create]) }
|
33
33
|
end
|
34
34
|
describe "before_filters only create" do
|
35
|
-
it { should
|
35
|
+
it { should have_before_filter(:before_filter_only_create).only_on(:create) }
|
36
36
|
end
|
37
37
|
describe "before_filters only show" do
|
38
|
-
it { should
|
38
|
+
it { should have_before_filter(:before_filter_only_show).only_on(:show) }
|
39
39
|
end
|
40
40
|
describe "before_filters only show and create" do
|
41
|
-
it { should
|
41
|
+
it { should have_before_filter(:before_filter_only_show_and_create).only_on([:show, :create]) }
|
42
42
|
end
|
43
43
|
describe "before_filters except create" do
|
44
|
-
it { should
|
44
|
+
it { should have_before_filter(:before_filter_except_create).except_on(:create) }
|
45
45
|
end
|
46
46
|
describe "before_filters except show" do
|
47
|
-
it { should
|
48
|
-
end
|
49
|
-
describe "before_filters except show and create" do
|
50
|
-
it { should include_before_filter(:before_filter_except_show_and_create).except_on([:show, :create]) }
|
47
|
+
it { should have_before_filter(:before_filter_except_show).except_on(:show) }
|
51
48
|
end
|
52
49
|
end
|
@@ -62,7 +62,7 @@ describe 'FilterMatcher' do
|
|
62
62
|
it "has the correct failure message" do
|
63
63
|
@matcher.failure_message.should == ""
|
64
64
|
end
|
65
|
-
it { @controller.should
|
65
|
+
it { @controller.should have_before_filter(:another_before_filter) }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- kenny ortmann
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-15 00:00:00 -06:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -113,7 +113,7 @@ files:
|
|
113
113
|
- spec/fixtures/models/duck.rb
|
114
114
|
- spec/spec_helper.rb
|
115
115
|
has_rdoc: true
|
116
|
-
homepage:
|
116
|
+
homepage: https://github.com/asynchrony/custom_rspec_matchers
|
117
117
|
licenses: []
|
118
118
|
|
119
119
|
post_install_message:
|