Skip to content

Commit 6e0f7cb

Browse files
committed
advanced setup to guardfile and gemfile
1 parent 6778597 commit 6e0f7cb

File tree

7 files changed

+127
-33
lines changed

7 files changed

+127
-33
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
# Ignore all logfiles and tempfiles.
1414
/log/*.log
1515
/tmp
16-
.DS_Store
16+
.DS_Store
17+
bundler_stubs/

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ group :test do
3030
gem 'guard-spork', '0.3.2'
3131
gem 'spork', '0.9.0'
3232
gem 'launchy', '2.1.0'
33-
# gem 'rb-fsevent', '0.9.1', :require => false
34-
# gem 'growl', '1.0.3'
33+
gem 'rb-fsevent', '0.9.1', :require => false
34+
gem 'growl', '1.0.3'
3535
end
3636

3737
group :production do

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ GEM
7575
ffi (1.0.11)
7676
gherkin (2.10.0)
7777
json (>= 1.4.6)
78+
growl (1.0.3)
7879
guard (1.1.1)
7980
listen (>= 0.4.2)
8081
thor (>= 0.14.6)
@@ -194,12 +195,14 @@ DEPENDENCIES
194195
database_cleaner (= 0.7.0)
195196
factory_girl_rails (= 1.4.0)
196197
faker (= 1.0.1)
198+
growl (= 1.0.3)
197199
guard-rspec (= 0.5.5)
198200
guard-spork (= 0.3.2)
199201
jquery-rails (= 2.0.0)
200202
launchy (= 2.1.0)
201203
pg (= 0.12.2)
202204
rails (= 3.2.5)
205+
rb-fsevent (= 0.9.1)
203206
rspec-rails (= 2.10.0)
204207
sass-rails (= 3.2.4)
205208
spork (= 0.9.0)

Guardfile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
#Begin advanced addition code
5+
require 'active_support/core_ext'
6+
guard 'rspec', :version => 2, :all_after_pass => false do
7+
8+
9+
10+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
11+
["spec/routing/#{m[1]}_routing_spec.rb",
12+
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
13+
"spec/acceptance/#{m[1]}_spec.rb",
14+
(m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
15+
"spec/requests/#{m[1].singularize}_pages_spec.rb")]
16+
end
17+
watch(%r{^app/views/(.+)/}) do |m|
18+
"spec/requests/#{m[1].singularize}_pages_spec.rb"
19+
end
20+
21+
end
22+
#End advanced addition code
23+
24+
25+
26+
27+
28+
guard 'rspec', :version => 2 do
29+
watch(%r{^spec/.+_spec\.rb$})
30+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
31+
watch('spec/spec_helper.rb') { "spec" }
32+
33+
# Rails example
34+
watch(%r{^spec/.+_spec\.rb$})
35+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
36+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
37+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
38+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
39+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
40+
watch('spec/spec_helper.rb') { "spec" }
41+
watch('config/routes.rb') { "spec/routing" }
42+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
43+
# Capybara request specs
44+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
45+
end
46+
47+
48+
guard 'rspec', :version => 2 do
49+
watch(%r{^spec/.+_spec\.rb$})
50+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
51+
watch('spec/spec_helper.rb') { "spec" }
52+
53+
# Rails example
54+
watch(%r{^spec/.+_spec\.rb$})
55+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
56+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
57+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
58+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
59+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
60+
watch('spec/spec_helper.rb') { "spec" }
61+
watch('config/routes.rb') { "spec/routing" }
62+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
63+
# Capybara request specs
64+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
65+
end
66+
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
<h1>StaticPages#home</h1>
2-
<p>Find me in app/views/static_pages/home.html.erb</p>
1+
<h1>Sample App</h1>
2+
<p>
3+
This is the home page for the <a href="http://railstutorial.org">Ruby on rail tutorial</a>
4+
sample application.
5+
</p>

spec/requests/static_pages_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'spec_helper'
2+
3+
describe "Static pages" do
4+
5+
describe "Home page" do
6+
7+
it "should have the content 'Sample App'" do
8+
9+
10+
visit '/static_pages/home'
11+
page.should have_content('Sample App')
12+
end
13+
end
14+
15+
16+
describe "Help page" do
17+
18+
it "should have the content 'Help'" do
19+
20+
21+
visit '/static_pages/help'
22+
page.should have_content('Help')
23+
end
24+
end
25+
26+
end

spec/spec_helper.rb

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
# This file is copied to spec/ when you run 'rails generate rspec:install'
2-
ENV["RAILS_ENV"] ||= 'test'
1+
require 'rubygems'
2+
require 'spork'
3+
Spork.prefork do
4+
# Loading more in this block will cause your tests to run faster. However,
5+
# if you change any configuration or code from libraries loaded here, you'll # need to restart spork for it take effect.
6+
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test'
37
require File.expand_path("../../config/environment", __FILE__)
48
require 'rspec/rails'
59
require 'rspec/autorun'
6-
7-
# Requires supporting ruby files with custom matchers and macros, etc,
8-
# in spec/support/ and its subdirectories.
9-
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10-
10+
# Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
1111
RSpec.configure do |config|
12-
# ## Mock Framework
13-
#
14-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15-
#
16-
# config.mock_with :mocha
17-
# config.mock_with :flexmock
18-
# config.mock_with :rr
19-
20-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21-
config.fixture_path = "#{::Rails.root}/spec/fixtures"
22-
23-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
24-
# examples within a transaction, remove the following line or assign false
25-
# instead of true.
26-
config.use_transactional_fixtures = true
27-
28-
# If true, the base class of anonymous controllers will be inferred
29-
# automatically. This will be the default behavior in future versions of
30-
# rspec-rails.
31-
config.infer_base_class_for_anonymous_controllers = false
32-
end
12+
# == Mock Framework
13+
#
14+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: #
15+
# config.mock_with :mocha
16+
# config.mock_with :flexmock # config.mock_with :rr config.mock_with :rspec
17+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
18+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
19+
# If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true.
20+
config.use_transactional_fixtures = true
21+
# If true, the base class of anonymous controllers will be inferred
22+
# automatically. This will be the default behavior in future versions of # rspec-rails.
23+
config.infer_base_class_for_anonymous_controllers = false
24+
end end
25+
Spork.each_run do
26+
# This code will be run each time you run your specs.
27+
end

0 commit comments

Comments
 (0)