contact_us 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Contact Us page' do
4
+
5
+ before do
6
+ visit contact_us_path
7
+ end
8
+
9
+ it 'displays contact form' do
10
+ page.should have_selector "form#new_contact_us_contact"
11
+ end
12
+
13
+ it "displays an input for email" do
14
+ page.should have_selector "input#contact_us_contact_email"
15
+ end
16
+
17
+ it "displays a textarea for message" do
18
+ page.should have_selector "textarea#contact_us_contact_message"
19
+ end
20
+
21
+ it "displays a submit button" do
22
+ page.should have_selector "input#contact_us_contact_submit"
23
+ end
24
+
25
+ context "Submitting the form" do
26
+ after { ActionMailer::Base.deliveries = [] }
27
+
28
+ context "when valid" do
29
+ before do
30
+ fill_in 'Email', :with => 'test@example.com'
31
+ fill_in 'Message', :with => 'howdy'
32
+ click_button 'Submit'
33
+ end
34
+
35
+ it "I should be redirected to the homepage" do
36
+ current_path.should == "/"
37
+ end
38
+
39
+ it "An email should have been sent" do
40
+ ActionMailer::Base.deliveries.size.should == 1
41
+ end
42
+
43
+ it "The email should have the correct attributes" do
44
+ mail = ActionMailer::Base.deliveries.last
45
+ mail.to.should == [ContactUs.mailer_to]
46
+ mail.from.should == ['test@example.com']
47
+ mail.body.should match 'howdy'
48
+ end
49
+ end
50
+
51
+ context "when invalid" do
52
+ context "Email and message are invalid" do
53
+ before do
54
+ fill_in 'Email', :with => 'a'
55
+ fill_in 'Message', :with => ''
56
+ click_button 'Submit'
57
+ end
58
+
59
+ it "I should see two error messages" do
60
+ page.should have_content "is invalid"
61
+ page.should have_content "can't be blank"
62
+ end
63
+
64
+ it "An email should not have been sent" do
65
+ ActionMailer::Base.deliveries.size.should == 0
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -28,7 +28,7 @@ describe ContactUs::ContactMailer do
28
28
  end
29
29
 
30
30
  it "should have the message in the body" do
31
- @mailer.body.should match("<p>Thanks!<p>")
31
+ @mailer.body.should match("<p>Thanks!</p>")
32
32
  end
33
33
 
34
34
  it "should deliver successfully" do
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ContactUs::Contact do
4
+ it_should_behave_like 'ActiveModel'
4
5
 
5
6
  describe "Validations" do
6
7
 
data/spec/spec_helper.rb CHANGED
@@ -32,6 +32,10 @@ Capybara.default_selector = :css
32
32
  # Run any available migration
33
33
  ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
34
34
 
35
+ # Requires supporting files with custom matchers and macros, etc,
36
+ # in ./support/ and its subdirectories.
37
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
38
+
35
39
  RSpec.configure do |config|
36
40
  # Remove this line if you don't want RSpec's should and should_not methods or matchers
37
41
  require 'rspec/expectations'
@@ -0,0 +1,17 @@
1
+ # adapted from rspec-rails:
2
+ # http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb
3
+
4
+ shared_examples_for 'ActiveModel' do
5
+ include ActiveModel::Lint::Tests
6
+
7
+ # to_s is to support ruby-1.9
8
+ ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |m|
9
+ example m.gsub('_', ' ') do
10
+ send m
11
+ end
12
+ end
13
+
14
+ def model
15
+ subject
16
+ end
17
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: contact_us
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeff Dutil
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-01 00:00:00 -04:00
14
- default_executable:
13
+ date: 2011-08-18 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: capybara
@@ -128,13 +127,7 @@ files:
128
127
  - spec/dummy/config/locales/en.yml
129
128
  - spec/dummy/config/routes.rb
130
129
  - spec/dummy/config.ru
131
- - spec/dummy/db/development.sqlite3
132
- - spec/dummy/db/test.sqlite3
133
130
  - spec/dummy/Gemfile
134
- - spec/dummy/Gemfile.lock
135
- - spec/dummy/log/development.log
136
- - spec/dummy/log/production.log
137
- - spec/dummy/log/server.log
138
131
  - spec/dummy/log/test.log
139
132
  - spec/dummy/public/404.html
140
133
  - spec/dummy/public/422.html
@@ -148,12 +141,12 @@ files:
148
141
  - spec/dummy/public/javascripts/rails.js
149
142
  - spec/dummy/Rakefile
150
143
  - spec/dummy/script/rails
151
- - spec/integration/navigation_spec.rb
144
+ - spec/integration/contact_us_lint_spec.rb
152
145
  - spec/lib/install_spec.rb
153
146
  - spec/mailers/contact_us/contact_mailer_spec.rb
154
147
  - spec/models/contact_us/contact_spec.rb
155
148
  - spec/spec_helper.rb
156
- has_rdoc: true
149
+ - spec/support/active_model_lint.rb
157
150
  homepage: https://github.com/jdutil/contact_us
158
151
  licenses: []
159
152
 
@@ -167,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
160
  requirements:
168
161
  - - ">="
169
162
  - !ruby/object:Gem::Version
170
- hash: -389592616240735892
163
+ hash: 2145858243867173170
171
164
  segments:
172
165
  - 0
173
166
  version: "0"
@@ -176,14 +169,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
169
  requirements:
177
170
  - - ">="
178
171
  - !ruby/object:Gem::Version
179
- hash: -389592616240735892
172
+ hash: 2145858243867173170
180
173
  segments:
181
174
  - 0
182
175
  version: "0"
183
176
  requirements: []
184
177
 
185
178
  rubyforge_project: contact_us
186
- rubygems_version: 1.6.2
179
+ rubygems_version: 1.8.8
187
180
  signing_key:
188
181
  specification_version: 3
189
182
  summary: Gem providing simple Contact Us functionality with a Rails 3+ Engine.
@@ -208,13 +201,7 @@ test_files:
208
201
  - spec/dummy/config/locales/en.yml
209
202
  - spec/dummy/config/routes.rb
210
203
  - spec/dummy/config.ru
211
- - spec/dummy/db/development.sqlite3
212
- - spec/dummy/db/test.sqlite3
213
204
  - spec/dummy/Gemfile
214
- - spec/dummy/Gemfile.lock
215
- - spec/dummy/log/development.log
216
- - spec/dummy/log/production.log
217
- - spec/dummy/log/server.log
218
205
  - spec/dummy/log/test.log
219
206
  - spec/dummy/public/404.html
220
207
  - spec/dummy/public/422.html
@@ -228,8 +215,9 @@ test_files:
228
215
  - spec/dummy/public/javascripts/rails.js
229
216
  - spec/dummy/Rakefile
230
217
  - spec/dummy/script/rails
231
- - spec/integration/navigation_spec.rb
218
+ - spec/integration/contact_us_lint_spec.rb
232
219
  - spec/lib/install_spec.rb
233
220
  - spec/mailers/contact_us/contact_mailer_spec.rb
234
221
  - spec/models/contact_us/contact_spec.rb
235
222
  - spec/spec_helper.rb
223
+ - spec/support/active_model_lint.rb
@@ -1,86 +0,0 @@
1
- PATH
2
- remote: ../../
3
- specs:
4
- contact_us (0.0.7)
5
- formtastic (>= 1.2.0)
6
- rails (>= 3.0.0)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- abstract (1.0.0)
12
- actionmailer (3.0.9)
13
- actionpack (= 3.0.9)
14
- mail (~> 2.2.19)
15
- actionpack (3.0.9)
16
- activemodel (= 3.0.9)
17
- activesupport (= 3.0.9)
18
- builder (~> 2.1.2)
19
- erubis (~> 2.6.6)
20
- i18n (~> 0.5.0)
21
- rack (~> 1.2.1)
22
- rack-mount (~> 0.6.14)
23
- rack-test (~> 0.5.7)
24
- tzinfo (~> 0.3.23)
25
- activemodel (3.0.9)
26
- activesupport (= 3.0.9)
27
- builder (~> 2.1.2)
28
- i18n (~> 0.5.0)
29
- activerecord (3.0.9)
30
- activemodel (= 3.0.9)
31
- activesupport (= 3.0.9)
32
- arel (~> 2.0.10)
33
- tzinfo (~> 0.3.23)
34
- activeresource (3.0.9)
35
- activemodel (= 3.0.9)
36
- activesupport (= 3.0.9)
37
- activesupport (3.0.9)
38
- arel (2.0.10)
39
- builder (2.1.2)
40
- erubis (2.6.6)
41
- abstract (>= 1.0.0)
42
- formtastic (1.2.4)
43
- actionpack (>= 2.3.7)
44
- activesupport (>= 2.3.7)
45
- i18n (~> 0.4)
46
- i18n (0.5.0)
47
- mail (2.2.19)
48
- activesupport (>= 2.3.6)
49
- i18n (>= 0.4.0)
50
- mime-types (~> 1.16)
51
- treetop (~> 1.4.8)
52
- mime-types (1.16)
53
- polyglot (0.3.1)
54
- rack (1.2.3)
55
- rack-mount (0.6.14)
56
- rack (>= 1.0.0)
57
- rack-test (0.5.7)
58
- rack (>= 1.0)
59
- rails (3.0.9)
60
- actionmailer (= 3.0.9)
61
- actionpack (= 3.0.9)
62
- activerecord (= 3.0.9)
63
- activeresource (= 3.0.9)
64
- activesupport (= 3.0.9)
65
- bundler (~> 1.0)
66
- railties (= 3.0.9)
67
- railties (3.0.9)
68
- actionpack (= 3.0.9)
69
- activesupport (= 3.0.9)
70
- rake (>= 0.8.7)
71
- rdoc (~> 3.4)
72
- thor (~> 0.14.4)
73
- rake (0.9.2)
74
- rdoc (3.8)
75
- thor (0.14.6)
76
- treetop (1.4.9)
77
- polyglot (>= 0.3.1)
78
- tzinfo (0.3.29)
79
-
80
- PLATFORMS
81
- ruby
82
-
83
- DEPENDENCIES
84
- contact_us!
85
- formtastic (>= 1.2.0)
86
- rails (= 3.0.9)
File without changes
Binary file
@@ -1,9 +0,0 @@
1
-
2
-
3
- Started GET "/" for 127.0.0.1 at 2011-07-17 16:09:59 -0400
4
-
5
- ActionController::RoutingError (No route matches "/"):
6
-
7
-
8
- Rendered /Users/JD/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (2.2ms)
9
- DEPRECATION WARNING: config.action_view.debug_rjs will be removed in 3.1, from 3.1 onwards you will need to install prototype-rails to continue to use RJS templates . (called from <top (required)> at /Users/JD/contact_us/spec/dummy/config/environment.rb:5)
File without changes
File without changes
@@ -1,73 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Navigation" do
4
-
5
- it "should be a valid app" do
6
- ::Rails.application.should be_a(Dummy::Application)
7
- end
8
-
9
- describe "Sending a contact email" do
10
- context "I'm on the contact page" do
11
- before { visit new_contact_url }
12
-
13
- it "I should see an input for email" do
14
- page.should have_selector "input#contact_us_contact_email"
15
- end
16
-
17
- it "I should see a textarea for message" do
18
- page.should have_selector "textarea#contact_us_contact_message"
19
- end
20
-
21
- it "I should see a submit button" do
22
- page.should have_selector "input#contact_us_contact_submit"
23
- end
24
-
25
- context "Submitting a form" do
26
- after { ActionMailer::Base.deliveries = [] }
27
-
28
- context "Submitting a valid form" do
29
- before do
30
- fill_in 'Email', :with => 'test@example.com'
31
- fill_in 'Message', :with => 'howdy'
32
- click_button 'Submit'
33
- end
34
-
35
- it "I should be redirected to the homepage" do
36
- current_path.should == "/"
37
- end
38
-
39
- it "An email should have been sent" do
40
- ActionMailer::Base.deliveries.size.should == 1
41
- end
42
-
43
- it "The email should have the correct attributes" do
44
- mail = ActionMailer::Base.deliveries.last
45
- mail.to.should == [ContactUs.mailer_to]
46
- mail.from.should == ['test@example.com']
47
- mail.body.should match 'howdy'
48
- end
49
- end
50
-
51
- context "Submitting an invalid form" do
52
- context "Email and message are invalid" do
53
- before do
54
- fill_in 'Email', :with => 'a'
55
- fill_in 'Message', :with => ''
56
- click_button 'Submit'
57
- end
58
-
59
- it "I should see two error messages" do
60
- page.should have_content "is invalid"
61
- page.should have_content "can't be blank"
62
- end
63
-
64
- it "An email should not have been sent" do
65
- ActionMailer::Base.deliveries.size.should == 0
66
- end
67
- end
68
- end
69
- end
70
- end
71
- end
72
-
73
- end