shoulda-kept-respond-with-content-type 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a8cce8136241c3ace032a21780777de8518b155b
4
+ data.tar.gz: 79f6fbde5a4cc26e709f869f72a822338919712e
5
+ SHA512:
6
+ metadata.gz: be4e18088a54fcc4b8c3107a3d4f85357fb4c639795d7b680fa0105b59282427538d39a94789ea9ec8a2e18bb2d4b6ab627435972a4ba2d9460b6dd1824e1e8f
7
+ data.tar.gz: d584c0a933631a2f755b49007eaeef47f3a50bf9fedfe4ed35cab79e5a448b78417e7ac56e4f3b7f9411b4b6a5e487a3369dac226b2bd873d8ea142d1ab00071
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ test/*/log/*.log
2
+ doc
3
+ coverage
4
+ .svn/
5
+ pkg
6
+ *.swp
7
+ *.swo
8
+ tags
9
+ tmp
10
+ .bundle
11
+ *.rbc
data/Appraisals ADDED
@@ -0,0 +1,15 @@
1
+ appraise '3.0' do
2
+ gem 'rails', '~> 3.0'
3
+ end
4
+
5
+ appraise '3.1' do
6
+ gem 'rails', '~> 3.1'
7
+ gem 'jquery-rails'
8
+ gem 'sass-rails'
9
+ end
10
+
11
+ appraise '3.2' do
12
+ gem 'rails', '~> 3.2'
13
+ gem 'jquery-rails'
14
+ gem 'sass-rails'
15
+ end
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,41 @@
1
+ We love pull requests. Here's a quick guide:
2
+
3
+ 1. Fork the repo.
4
+
5
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
6
+ to know that you have a clean slate: `bundle && rake`
7
+
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+
12
+ 4. Make the test pass.
13
+
14
+ 5. Update NEWS.md with a brief description of your changes under the HEAD
15
+ heading.
16
+
17
+ 6. Push to your fork and submit a pull request.
18
+
19
+
20
+ At this point you're waiting on us. We like to at least comment on, if not
21
+ accept, pull requests within three business days (and, typically, one business
22
+ day). We may suggest some changes or improvements or alternatives.
23
+
24
+ Some things that will increase the chance that your pull request is accepted,
25
+ taken straight from the Ruby on Rails guide:
26
+
27
+ * Use Rails idioms and helpers
28
+ * Include tests that fail without your code, and pass with it
29
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
30
+ whatever is affected by your contribution
31
+
32
+ Syntax:
33
+
34
+ * Two spaces, no tabs.
35
+ * No trailing whitespace. Blank lines should not have any space.
36
+ * Prefer &&/|| over and/or.
37
+ * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
38
+ * a = b and not a=b.
39
+ * Follow the conventions you see used in the source already.
40
+
41
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,116 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ shoulda-kept-respond-with-content-type (1.0.0)
5
+ shoulda-matchers (>= 2.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.17)
11
+ actionpack (= 3.2.17)
12
+ mail (~> 2.5.4)
13
+ actionpack (3.2.17)
14
+ activemodel (= 3.2.17)
15
+ activesupport (= 3.2.17)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.5)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.17)
24
+ activesupport (= 3.2.17)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.17)
27
+ activemodel (= 3.2.17)
28
+ activesupport (= 3.2.17)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.17)
32
+ activemodel (= 3.2.17)
33
+ activesupport (= 3.2.17)
34
+ activesupport (3.2.17)
35
+ i18n (~> 0.6, >= 0.6.4)
36
+ multi_json (~> 1.0)
37
+ appraisal (0.5.2)
38
+ bundler
39
+ rake
40
+ arel (3.0.3)
41
+ builder (3.0.4)
42
+ diff-lcs (1.2.5)
43
+ erubis (2.7.0)
44
+ hike (1.2.3)
45
+ i18n (0.6.9)
46
+ journey (1.0.4)
47
+ json (1.8.1)
48
+ mail (2.5.4)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ mime-types (1.25.1)
52
+ multi_json (1.9.0)
53
+ polyglot (0.3.4)
54
+ rack (1.4.5)
55
+ rack-cache (1.2)
56
+ rack (>= 0.4)
57
+ rack-ssl (1.3.3)
58
+ rack
59
+ rack-test (0.6.2)
60
+ rack (>= 1.0)
61
+ rails (3.2.17)
62
+ actionmailer (= 3.2.17)
63
+ actionpack (= 3.2.17)
64
+ activerecord (= 3.2.17)
65
+ activeresource (= 3.2.17)
66
+ activesupport (= 3.2.17)
67
+ bundler (~> 1.0)
68
+ railties (= 3.2.17)
69
+ railties (3.2.17)
70
+ actionpack (= 3.2.17)
71
+ activesupport (= 3.2.17)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (>= 0.14.6, < 2.0)
76
+ rake (10.1.1)
77
+ rdoc (3.12.2)
78
+ json (~> 1.4)
79
+ rspec-core (2.14.8)
80
+ rspec-expectations (2.14.5)
81
+ diff-lcs (>= 1.1.3, < 2.0)
82
+ rspec-mocks (2.14.6)
83
+ rspec-rails (2.14.1)
84
+ actionpack (>= 3.0)
85
+ activemodel (>= 3.0)
86
+ activesupport (>= 3.0)
87
+ railties (>= 3.0)
88
+ rspec-core (~> 2.14.0)
89
+ rspec-expectations (~> 2.14.0)
90
+ rspec-mocks (~> 2.14.0)
91
+ shoulda-matchers (2.5.0)
92
+ activesupport (>= 3.0.0)
93
+ sprockets (2.2.2)
94
+ hike (~> 1.2)
95
+ multi_json (~> 1.0)
96
+ rack (~> 1.0)
97
+ tilt (~> 1.1, != 1.3.0)
98
+ sqlite3 (1.3.9)
99
+ thor (0.18.1)
100
+ tilt (1.4.1)
101
+ treetop (1.4.15)
102
+ polyglot
103
+ polyglot (>= 0.3.1)
104
+ tzinfo (0.3.38)
105
+
106
+ PLATFORMS
107
+ ruby
108
+
109
+ DEPENDENCIES
110
+ appraisal
111
+ bundler
112
+ rails (~> 3)
113
+ rake
114
+ rspec-rails
115
+ shoulda-kept-respond-with-content-type!
116
+ sqlite3
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2006-2013, Tammer Saleh, thoughtbot, inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Shoulda-Kept-Assign-To
2
+
3
+ Shoulda-matchers, ([official Git repo](https://github.com/thoughtbot/shoulda-matchers)), removed the respond_with_content_type matcher in version 2.0.0. We missed it dearly, enough to bring it back. This gem includes all of the current version of shoulda-matchers, and it adds the 'respond_with_content_type' matcher back in, just the way it was before it was mercilessly destroyed.
4
+
5
+ ## Example (from shoulda-matchers, v1.5)
6
+
7
+ ```ruby
8
+ describe PostsController, "#show" do
9
+ it { should permit(:title, :body).for(:create) }
10
+
11
+ context "for a fictional user" do
12
+ before do
13
+ get :show, :id => 1
14
+ end
15
+
16
+ it { should respond_with_content_type(:json) }
17
+ end
18
+ end
19
+ ```
20
+
21
+ ## Installation
22
+
23
+ In Rails 3 and Bundler, add the following to your Gemfile:
24
+
25
+ ```ruby
26
+ group :test do
27
+ gem "shoulda-kept-respond-with-content-type"
28
+ end
29
+
30
+ Shoulda will automatically include matchers into the appropriate example groups.
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+ require 'appraisal'
5
+
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.pattern = "spec/**/*_spec.rb"
8
+ t.rspec_opts = '--color --format progress'
9
+ t.verbose = false
10
+ end
11
+
12
+ task :default do |t|
13
+ if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
14
+ exec 'rake spec'
15
+ else
16
+ Rake::Task['appraise'].execute
17
+ end
18
+ end
19
+
20
+ task :appraise => ['appraisal:install'] do |t|
21
+ exec 'rake appraisal'
22
+ end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,116 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ shoulda-kept-respond-with-content-type (1.0.0)
5
+ shoulda-matchers (>= 2.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.17)
11
+ actionpack (= 3.2.17)
12
+ mail (~> 2.5.4)
13
+ actionpack (3.2.17)
14
+ activemodel (= 3.2.17)
15
+ activesupport (= 3.2.17)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.5)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.17)
24
+ activesupport (= 3.2.17)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.17)
27
+ activemodel (= 3.2.17)
28
+ activesupport (= 3.2.17)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.17)
32
+ activemodel (= 3.2.17)
33
+ activesupport (= 3.2.17)
34
+ activesupport (3.2.17)
35
+ i18n (~> 0.6, >= 0.6.4)
36
+ multi_json (~> 1.0)
37
+ appraisal (0.5.2)
38
+ bundler
39
+ rake
40
+ arel (3.0.3)
41
+ builder (3.0.4)
42
+ diff-lcs (1.2.5)
43
+ erubis (2.7.0)
44
+ hike (1.2.3)
45
+ i18n (0.6.9)
46
+ journey (1.0.4)
47
+ json (1.8.1)
48
+ mail (2.5.4)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ mime-types (1.25.1)
52
+ multi_json (1.9.0)
53
+ polyglot (0.3.4)
54
+ rack (1.4.5)
55
+ rack-cache (1.2)
56
+ rack (>= 0.4)
57
+ rack-ssl (1.3.3)
58
+ rack
59
+ rack-test (0.6.2)
60
+ rack (>= 1.0)
61
+ rails (3.2.17)
62
+ actionmailer (= 3.2.17)
63
+ actionpack (= 3.2.17)
64
+ activerecord (= 3.2.17)
65
+ activeresource (= 3.2.17)
66
+ activesupport (= 3.2.17)
67
+ bundler (~> 1.0)
68
+ railties (= 3.2.17)
69
+ railties (3.2.17)
70
+ actionpack (= 3.2.17)
71
+ activesupport (= 3.2.17)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (>= 0.14.6, < 2.0)
76
+ rake (10.1.1)
77
+ rdoc (3.12.2)
78
+ json (~> 1.4)
79
+ rspec-core (2.14.8)
80
+ rspec-expectations (2.14.5)
81
+ diff-lcs (>= 1.1.3, < 2.0)
82
+ rspec-mocks (2.14.6)
83
+ rspec-rails (2.14.1)
84
+ actionpack (>= 3.0)
85
+ activemodel (>= 3.0)
86
+ activesupport (>= 3.0)
87
+ railties (>= 3.0)
88
+ rspec-core (~> 2.14.0)
89
+ rspec-expectations (~> 2.14.0)
90
+ rspec-mocks (~> 2.14.0)
91
+ shoulda-matchers (2.5.0)
92
+ activesupport (>= 3.0.0)
93
+ sprockets (2.2.2)
94
+ hike (~> 1.2)
95
+ multi_json (~> 1.0)
96
+ rack (~> 1.0)
97
+ tilt (~> 1.1, != 1.3.0)
98
+ sqlite3 (1.3.9)
99
+ thor (0.18.1)
100
+ tilt (1.4.1)
101
+ treetop (1.4.15)
102
+ polyglot
103
+ polyglot (>= 0.3.1)
104
+ tzinfo (0.3.38)
105
+
106
+ PLATFORMS
107
+ ruby
108
+
109
+ DEPENDENCIES
110
+ appraisal
111
+ bundler
112
+ rails (~> 3.0)
113
+ rake
114
+ rspec-rails
115
+ shoulda-kept-respond-with-content-type!
116
+ sqlite3
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.1"
6
+ gem "jquery-rails"
7
+ gem "sass-rails"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ shoulda-kept-respond-with-content-type (1.0.0)
5
+ shoulda-matchers (>= 2.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.17)
11
+ actionpack (= 3.2.17)
12
+ mail (~> 2.5.4)
13
+ actionpack (3.2.17)
14
+ activemodel (= 3.2.17)
15
+ activesupport (= 3.2.17)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.5)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.17)
24
+ activesupport (= 3.2.17)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.17)
27
+ activemodel (= 3.2.17)
28
+ activesupport (= 3.2.17)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.17)
32
+ activemodel (= 3.2.17)
33
+ activesupport (= 3.2.17)
34
+ activesupport (3.2.17)
35
+ i18n (~> 0.6, >= 0.6.4)
36
+ multi_json (~> 1.0)
37
+ appraisal (0.5.2)
38
+ bundler
39
+ rake
40
+ arel (3.0.3)
41
+ builder (3.0.4)
42
+ diff-lcs (1.2.5)
43
+ erubis (2.7.0)
44
+ hike (1.2.3)
45
+ i18n (0.6.9)
46
+ journey (1.0.4)
47
+ jquery-rails (3.1.0)
48
+ railties (>= 3.0, < 5.0)
49
+ thor (>= 0.14, < 2.0)
50
+ json (1.8.1)
51
+ mail (2.5.4)
52
+ mime-types (~> 1.16)
53
+ treetop (~> 1.4.8)
54
+ mime-types (1.25.1)
55
+ multi_json (1.9.0)
56
+ polyglot (0.3.4)
57
+ rack (1.4.5)
58
+ rack-cache (1.2)
59
+ rack (>= 0.4)
60
+ rack-ssl (1.3.3)
61
+ rack
62
+ rack-test (0.6.2)
63
+ rack (>= 1.0)
64
+ rails (3.2.17)
65
+ actionmailer (= 3.2.17)
66
+ actionpack (= 3.2.17)
67
+ activerecord (= 3.2.17)
68
+ activeresource (= 3.2.17)
69
+ activesupport (= 3.2.17)
70
+ bundler (~> 1.0)
71
+ railties (= 3.2.17)
72
+ railties (3.2.17)
73
+ actionpack (= 3.2.17)
74
+ activesupport (= 3.2.17)
75
+ rack-ssl (~> 1.3.2)
76
+ rake (>= 0.8.7)
77
+ rdoc (~> 3.4)
78
+ thor (>= 0.14.6, < 2.0)
79
+ rake (10.1.1)
80
+ rdoc (3.12.2)
81
+ json (~> 1.4)
82
+ rspec-core (2.14.8)
83
+ rspec-expectations (2.14.5)
84
+ diff-lcs (>= 1.1.3, < 2.0)
85
+ rspec-mocks (2.14.6)
86
+ rspec-rails (2.14.1)
87
+ actionpack (>= 3.0)
88
+ activemodel (>= 3.0)
89
+ activesupport (>= 3.0)
90
+ railties (>= 3.0)
91
+ rspec-core (~> 2.14.0)
92
+ rspec-expectations (~> 2.14.0)
93
+ rspec-mocks (~> 2.14.0)
94
+ sass (3.2.15)
95
+ sass-rails (3.2.6)
96
+ railties (~> 3.2.0)
97
+ sass (>= 3.1.10)
98
+ tilt (~> 1.3)
99
+ shoulda-matchers (2.5.0)
100
+ activesupport (>= 3.0.0)
101
+ sprockets (2.2.2)
102
+ hike (~> 1.2)
103
+ multi_json (~> 1.0)
104
+ rack (~> 1.0)
105
+ tilt (~> 1.1, != 1.3.0)
106
+ sqlite3 (1.3.9)
107
+ thor (0.18.1)
108
+ tilt (1.4.1)
109
+ treetop (1.4.15)
110
+ polyglot
111
+ polyglot (>= 0.3.1)
112
+ tzinfo (0.3.38)
113
+
114
+ PLATFORMS
115
+ ruby
116
+
117
+ DEPENDENCIES
118
+ appraisal
119
+ bundler
120
+ jquery-rails
121
+ rails (~> 3.1)
122
+ rake
123
+ rspec-rails
124
+ sass-rails
125
+ shoulda-kept-respond-with-content-type!
126
+ sqlite3
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2"
6
+ gem "jquery-rails"
7
+ gem "sass-rails"
8
+
9
+ gemspec :path=>"../"
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ shoulda-kept-respond-with-content-type (1.0.0)
5
+ shoulda-matchers (>= 2.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.17)
11
+ actionpack (= 3.2.17)
12
+ mail (~> 2.5.4)
13
+ actionpack (3.2.17)
14
+ activemodel (= 3.2.17)
15
+ activesupport (= 3.2.17)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.5)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.17)
24
+ activesupport (= 3.2.17)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.17)
27
+ activemodel (= 3.2.17)
28
+ activesupport (= 3.2.17)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.17)
32
+ activemodel (= 3.2.17)
33
+ activesupport (= 3.2.17)
34
+ activesupport (3.2.17)
35
+ i18n (~> 0.6, >= 0.6.4)
36
+ multi_json (~> 1.0)
37
+ appraisal (0.5.2)
38
+ bundler
39
+ rake
40
+ arel (3.0.3)
41
+ builder (3.0.4)
42
+ diff-lcs (1.2.5)
43
+ erubis (2.7.0)
44
+ hike (1.2.3)
45
+ i18n (0.6.9)
46
+ journey (1.0.4)
47
+ jquery-rails (3.1.0)
48
+ railties (>= 3.0, < 5.0)
49
+ thor (>= 0.14, < 2.0)
50
+ json (1.8.1)
51
+ mail (2.5.4)
52
+ mime-types (~> 1.16)
53
+ treetop (~> 1.4.8)
54
+ mime-types (1.25.1)
55
+ multi_json (1.9.0)
56
+ polyglot (0.3.4)
57
+ rack (1.4.5)
58
+ rack-cache (1.2)
59
+ rack (>= 0.4)
60
+ rack-ssl (1.3.3)
61
+ rack
62
+ rack-test (0.6.2)
63
+ rack (>= 1.0)
64
+ rails (3.2.17)
65
+ actionmailer (= 3.2.17)
66
+ actionpack (= 3.2.17)
67
+ activerecord (= 3.2.17)
68
+ activeresource (= 3.2.17)
69
+ activesupport (= 3.2.17)
70
+ bundler (~> 1.0)
71
+ railties (= 3.2.17)
72
+ railties (3.2.17)
73
+ actionpack (= 3.2.17)
74
+ activesupport (= 3.2.17)
75
+ rack-ssl (~> 1.3.2)
76
+ rake (>= 0.8.7)
77
+ rdoc (~> 3.4)
78
+ thor (>= 0.14.6, < 2.0)
79
+ rake (10.1.1)
80
+ rdoc (3.12.2)
81
+ json (~> 1.4)
82
+ rspec-core (2.14.8)
83
+ rspec-expectations (2.14.5)
84
+ diff-lcs (>= 1.1.3, < 2.0)
85
+ rspec-mocks (2.14.6)
86
+ rspec-rails (2.14.1)
87
+ actionpack (>= 3.0)
88
+ activemodel (>= 3.0)
89
+ activesupport (>= 3.0)
90
+ railties (>= 3.0)
91
+ rspec-core (~> 2.14.0)
92
+ rspec-expectations (~> 2.14.0)
93
+ rspec-mocks (~> 2.14.0)
94
+ sass (3.2.15)
95
+ sass-rails (3.2.6)
96
+ railties (~> 3.2.0)
97
+ sass (>= 3.1.10)
98
+ tilt (~> 1.3)
99
+ shoulda-matchers (2.5.0)
100
+ activesupport (>= 3.0.0)
101
+ sprockets (2.2.2)
102
+ hike (~> 1.2)
103
+ multi_json (~> 1.0)
104
+ rack (~> 1.0)
105
+ tilt (~> 1.1, != 1.3.0)
106
+ sqlite3 (1.3.9)
107
+ thor (0.18.1)
108
+ tilt (1.4.1)
109
+ treetop (1.4.15)
110
+ polyglot
111
+ polyglot (>= 0.3.1)
112
+ tzinfo (0.3.38)
113
+
114
+ PLATFORMS
115
+ ruby
116
+
117
+ DEPENDENCIES
118
+ appraisal
119
+ bundler
120
+ jquery-rails
121
+ rails (~> 3.2)
122
+ rake
123
+ rspec-rails
124
+ sass-rails
125
+ shoulda-kept-respond-with-content-type!
126
+ sqlite3
@@ -0,0 +1,2 @@
1
+ require 'shoulda/matchers'
2
+ require 'shoulda/matchers/action_controller/respond_with_content_type_matcher'
@@ -0,0 +1,80 @@
1
+ module Shoulda # :nodoc:
2
+ module Matchers
3
+ module ActionController # :nodoc:
4
+
5
+ # Ensures a controller responded with expected 'response' content type.
6
+ #
7
+ # You can pass an explicit content type such as 'application/rss+xml'
8
+ # or its symbolic equivalent :rss
9
+ # or a regular expression such as /rss/
10
+ #
11
+ # Example:
12
+ #
13
+ # it { should respond_with_content_type(:xml) }
14
+ # it { should respond_with_content_type(:csv) }
15
+ # it { should respond_with_content_type(:atom) }
16
+ # it { should respond_with_content_type(:yaml) }
17
+ # it { should respond_with_content_type(:text) }
18
+ # it { should respond_with_content_type('application/rss+xml') }
19
+ # it { should respond_with_content_type(/json/) }
20
+ def respond_with_content_type(content_type)
21
+ RespondWithContentTypeMatcher.new(content_type)
22
+ end
23
+
24
+ class RespondWithContentTypeMatcher # :nodoc:
25
+ def initialize(content_type)
26
+ @content_type = look_up_content_type(content_type)
27
+ end
28
+
29
+ def description
30
+ "respond with content type of #{@content_type}"
31
+ end
32
+
33
+ def matches?(controller)
34
+ @controller = controller
35
+ content_type_matches_regexp? || content_type_matches_string?
36
+ end
37
+
38
+ def failure_message_for_should
39
+ "Expected #{expectation}"
40
+ end
41
+
42
+ def failure_message_for_should_not
43
+ "Did not expect #{expectation}"
44
+ end
45
+
46
+ protected
47
+
48
+ def content_type_matches_regexp?
49
+ if @content_type.is_a?(Regexp)
50
+ response_content_type =~ @content_type
51
+ end
52
+ end
53
+
54
+ def content_type_matches_string?
55
+ response_content_type == @content_type
56
+ end
57
+
58
+ def response_content_type
59
+ @controller.response.content_type.to_s
60
+ end
61
+
62
+ def look_up_by_extension(extension)
63
+ Mime::Type.lookup_by_extension(extension.to_s).to_s
64
+ end
65
+
66
+ def look_up_content_type(content_type)
67
+ if content_type.is_a?(Symbol)
68
+ look_up_by_extension(content_type)
69
+ else
70
+ content_type
71
+ end
72
+ end
73
+
74
+ def expectation
75
+ "content type to be #{@content_type}, but was #{response_content_type}"
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "shoulda-kept-respond-with-content-type"
5
+ s.version = '1.0.0'
6
+ s.authors = ["Ben Sedat"]
7
+ s.date = Time.now.strftime("%Y-%m-%d")
8
+ s.email = "engineers@tinfoilsecurity.com"
9
+ s.homepage = "https://www.tinfoilsecurity.com"
10
+ s.summary = "We miss the respond_with_content_type matcher in shoulda-matchers."
11
+ s.license = "MIT"
12
+ s.description = "We miss the respond_with_content_type matcher in shoulda-matchers."
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.required_ruby_version = '>= 1.9.2'
20
+ s.add_dependency('shoulda-matchers', '>= 2.1.0')
21
+
22
+ s.add_development_dependency('bundler')
23
+ s.add_development_dependency('rake')
24
+ s.add_development_dependency('appraisal')
25
+ s.add_development_dependency('rails', '~> 3')
26
+ s.add_development_dependency('sqlite3')
27
+ s.add_development_dependency('rspec-rails')
28
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shoulda::Matchers::ActionController::RespondWithContentTypeMatcher do
4
+ it 'generates the correct description' do
5
+ expected = 'respond with content type of application/xml'
6
+
7
+ respond_with_content_type(:xml).description.should == expected
8
+ end
9
+
10
+ it 'accepts responding with content type as symbol' do
11
+ xml_controller.should respond_with_content_type(:xml)
12
+ end
13
+
14
+ it 'accepts responding with qualified MIME-style content type' do
15
+ xml_controller.should respond_with_content_type('application/xml')
16
+ end
17
+
18
+ it 'accepts responding with a regex matching the content type' do
19
+ xml_controller.should respond_with_content_type(/xml/)
20
+ end
21
+
22
+ it 'rejects responding with another content type' do
23
+ xml_controller.should_not respond_with_content_type(:json)
24
+ end
25
+
26
+ def xml_controller
27
+ build_response do
28
+ render :xml => { :user => 'thoughtbot' }.to_xml
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ # Create Rails environment based on the version given from Appraisal
2
+ TESTAPP_ROOT = File.join(File.dirname(__FILE__), '..', 'tmp', 'testapp')
3
+ FileUtils.rm_rf(TESTAPP_ROOT) if File.exists?(TESTAPP_ROOT)
4
+ `rails new #{TESTAPP_ROOT}`
5
+
6
+ ENV['RAILS_ENV'] = 'test'
7
+ ENV['BUNDLE_GEMFILE'] ||= TESTAPP_ROOT + '/Gemfile'
8
+
9
+ require "#{TESTAPP_ROOT}/config/environment"
10
+ require 'shoulda-matchers'
11
+ require 'rspec/rails'
12
+
13
+ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
14
+
15
+ $LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
16
+
17
+ Dir[File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')].each { |file| require(file) }
18
+
19
+ # Run the migrations
20
+ ActiveRecord::Migration.verbose = false
21
+ ActiveRecord::Migrator.migrate(Rails.root.join('db/migrate'))
22
+
23
+ RSpec.configure do |config|
24
+ config.include Shoulda::Matchers::ActionController,
25
+ :example_group => { :file_path => /action_controller/ }
26
+ end
@@ -0,0 +1,42 @@
1
+ module ClassBuilder
2
+ def self.included(example_group)
3
+ example_group.class_eval do
4
+ after do
5
+ teardown_defined_constants
6
+ end
7
+ end
8
+ end
9
+
10
+ def define_class(class_name, base = Object, &block)
11
+ class_name = class_name.to_s.camelize
12
+
13
+ # FIXME: ActionMailer 3.2 calls `name.underscore` immediately upon
14
+ # subclassing. Class.new.name == nil. So, Class.new(ActionMailer::Base)
15
+ # errors out since it's trying to do `nil.underscore`. This is very ugly but
16
+ # allows us to test against ActionMailer 3.2.x.
17
+ eval <<-A_REAL_CLASS_FOR_ACTION_MAILER_3_2
18
+ class ::#{class_name} < #{base}
19
+ end
20
+ A_REAL_CLASS_FOR_ACTION_MAILER_3_2
21
+
22
+ Object.const_get(class_name).tap do |constant_class|
23
+ constant_class.unloadable
24
+
25
+ if block_given?
26
+ constant_class.class_eval(&block)
27
+ end
28
+
29
+ if constant_class.respond_to?(:reset_column_information)
30
+ constant_class.reset_column_information
31
+ end
32
+ end
33
+ end
34
+
35
+ def teardown_defined_constants
36
+ ActiveSupport::Dependencies.clear
37
+ end
38
+ end
39
+
40
+ RSpec.configure do |config|
41
+ config.include ClassBuilder
42
+ end
@@ -0,0 +1,104 @@
1
+ module ControllerBuilder
2
+ TMP_VIEW_PATH = File.expand_path(File.join(TESTAPP_ROOT, 'tmp',
3
+ 'views')).freeze
4
+
5
+ def self.included(example_group)
6
+ example_group.class_eval do
7
+ after do
8
+ delete_temporary_views
9
+ restore_original_routes
10
+ end
11
+ end
12
+ end
13
+
14
+ def define_controller(class_name, &block)
15
+ class_name = class_name.to_s
16
+ class_name << 'Controller' unless class_name =~ /Controller$/
17
+ define_class(class_name, ActionController::Base, &block)
18
+ end
19
+
20
+ def define_routes(&block)
21
+ Rails.application.routes.draw(&block)
22
+ @routes = Rails.application.routes
23
+ class << self
24
+ include ActionDispatch::Assertions
25
+ end
26
+ end
27
+
28
+ def build_response(opts = {}, &block)
29
+ action = opts[:action] || 'example'
30
+ partial = opts[:partial] || '_partial'
31
+ block ||= lambda { render :nothing => true }
32
+ controller_class = define_controller('Examples') do
33
+ layout false
34
+ define_method(action, &block)
35
+ end
36
+ controller_class.view_paths = [TMP_VIEW_PATH]
37
+
38
+ define_routes do
39
+ get 'examples', :to => "examples##{action}"
40
+ end
41
+
42
+ create_view("examples/#{action}.html.erb", 'action')
43
+ create_view("examples/#{partial}.html.erb", 'partial')
44
+
45
+ setup_rails_controller_test(controller_class)
46
+ get action
47
+
48
+ @controller
49
+ end
50
+
51
+ def setup_rails_controller_test(controller_class)
52
+ @controller = controller_class.new
53
+ @request = ::ActionController::TestRequest.new
54
+ @response = ::ActionController::TestResponse.new
55
+
56
+ class << self
57
+ include ActionController::TestCase::Behavior
58
+ end
59
+ end
60
+
61
+ def create_view(path, contents)
62
+ full_path = File.join(TMP_VIEW_PATH, path)
63
+ FileUtils.mkdir_p(File.dirname(full_path))
64
+ File.open(full_path, 'w') { |file| file.write(contents) }
65
+ end
66
+
67
+ def controller_for_resource_with_strong_parameters(&block)
68
+ define_model "User"
69
+ controller_class = define_controller "Users" do
70
+ def new
71
+ @user = User.new
72
+ render :nothing => true
73
+ end
74
+
75
+ def create
76
+ @user = User.create(user_params)
77
+ render :nothing => true
78
+ end
79
+
80
+ private
81
+ define_method :user_params, &block
82
+ end
83
+
84
+ setup_rails_controller_test(controller_class)
85
+
86
+ define_routes { resources :users }
87
+
88
+ controller_class
89
+ end
90
+
91
+ private
92
+
93
+ def delete_temporary_views
94
+ FileUtils.rm_rf(TMP_VIEW_PATH)
95
+ end
96
+
97
+ def restore_original_routes
98
+ Rails.application.reload_routes!
99
+ end
100
+ end
101
+
102
+ RSpec.configure do |config|
103
+ config.include ControllerBuilder
104
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shoulda-kept-respond-with-content-type
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Sedat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: shoulda-matchers
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: appraisal
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: We miss the respond_with_content_type matcher in shoulda-matchers.
112
+ email: engineers@tinfoilsecurity.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - Appraisals
119
+ - CONTRIBUTING.md
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - MIT-LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - gemfiles/3.0.gemfile
126
+ - gemfiles/3.0.gemfile.lock
127
+ - gemfiles/3.1.gemfile
128
+ - gemfiles/3.1.gemfile.lock
129
+ - gemfiles/3.2.gemfile
130
+ - gemfiles/3.2.gemfile.lock
131
+ - lib/shoulda-kept-respond-with-content-type.rb
132
+ - lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb
133
+ - shoulda-kept-respond-with-content-type.gemspec
134
+ - spec/shoulda/matchers/action_controller/respond_with_content_type_matcher_spec.rb
135
+ - spec/spec_helper.rb
136
+ - spec/support/class_builder.rb
137
+ - spec/support/controller_builder.rb
138
+ homepage: https://www.tinfoilsecurity.com
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: 1.9.2
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.2.2
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: We miss the respond_with_content_type matcher in shoulda-matchers.
162
+ test_files:
163
+ - spec/shoulda/matchers/action_controller/respond_with_content_type_matcher_spec.rb
164
+ - spec/spec_helper.rb
165
+ - spec/support/class_builder.rb
166
+ - spec/support/controller_builder.rb