testing_rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Frédéric Mascaro
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = testing_rails
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to testing_rails
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Frédéric Mascaro. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,101 @@
1
+ # GENERATE BY WOOANDOO TESTING GEM
2
+
3
+ require 'rubygems'
4
+ require 'spork'
5
+
6
+ Spork.prefork do
7
+ # Loading more in this block will cause your tests to run faster. However,
8
+ # if you change any configuration or code from libraries loaded here, you'll
9
+ # need to restart spork for it take effect.
10
+
11
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
12
+ ENV["RAILS_ENV"] ||= 'test'
13
+ require File.expand_path("../../config/environment", __FILE__)
14
+ require 'rspec/rails'
15
+ require 'capybara/rspec'
16
+
17
+ Capybara.javascript_driver = :webkit
18
+
19
+ # Requires supporting ruby files with custom matchers and macros, etc,
20
+ # in spec/support/ and its subdirectories.
21
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
22
+ Dir[Rails.root.join("spec/macro/**/*.rb")].each {|f| require f}
23
+
24
+ RSpec.configure do |config|
25
+ # == Mock Framework
26
+ #
27
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
28
+ #
29
+ # config.mock_with :mocha
30
+ # config.mock_with :flexmock
31
+ # config.mock_with :rr
32
+ config.mock_with :rspec
33
+
34
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
35
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
36
+
37
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
38
+ # examples within a transaction, remove the following line or assign false
39
+ # instead of true.
40
+ config.use_transactional_fixtures = false
41
+
42
+ DatabaseCleaner.logger = Rails.logger
43
+
44
+ # config.before :suite do
45
+ # DatabaseCleaner.clean_with(:truncation)
46
+ # end
47
+
48
+ config.before :each do
49
+ DatabaseCleaner.clean_with(:truncation, :except => %w{countries states renter_categories renter_category_translations renter_types renter_type_translations})
50
+
51
+ # if Capybara.current_driver == :rack_test
52
+ # DatabaseCleaner.strategy = :transaction
53
+ # else
54
+ # DatabaseCleaner.strategy = :truncation
55
+ # end
56
+ # DatabaseCleaner.start
57
+ end
58
+
59
+ config.after :each do
60
+ # DatabaseCleaner.clean
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ Spork.each_run do
67
+ # This code will be run each time you run your specs.
68
+ # ApplicationName::Application.reload_routes!
69
+
70
+ FactoryGirl.factories.clear
71
+ Dir[Rails.root.join("spec/factories/**/*.rb")].each{|f| load f}
72
+ end
73
+
74
+ # --- Instructions ---
75
+ # Sort the contents of this file into a Spork.prefork and a Spork.each_run
76
+ # block.
77
+ #
78
+ # The Spork.prefork block is run only once when the spork server is started.
79
+ # You typically want to place most of your (slow) initializer code in here, in
80
+ # particular, require'ing any 3rd-party gems that you don't normally modify
81
+ # during development.
82
+ #
83
+ # The Spork.each_run block is run each time you run your specs. In case you
84
+ # need to load files that tend to change during development, require them here.
85
+ # With Rails, your application modules are loaded automatically, so sometimes
86
+ # this block can remain empty.
87
+ #
88
+ # Note: You can modify files loaded *from* the Spork.each_run block without
89
+ # restarting the spork server. However, this file itself will not be reloaded,
90
+ # so if you change any of the code inside the each_run block, you still need to
91
+ # restart the server. In general, if you have non-trivial code in this file,
92
+ # it's advisable to move it into a separate file so you can easily edit it
93
+ # without restarting spork. (For example, with RSpec, you could move
94
+ # non-trivial code into a file spec/support/my_helper.rb, making sure that the
95
+ # spec/support/* files are require'd from inside the each_run block.)
96
+ #
97
+ # Any code that is left outside the two blocks will be run during preforking
98
+ # *and* during each_run -- that's probably not what you want.
99
+ #
100
+ # These instructions should self-destruct in 10 seconds. If they don't, feel
101
+ # free to delete them.
@@ -0,0 +1,67 @@
1
+ puts "lib/generators/testing_generator.rb"
2
+
3
+ require "rails/generators/base"
4
+
5
+ module Wooandoo
6
+ module Generators
7
+ class TestingGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ def configure_rails_application_for_testing
11
+ add_gems
12
+ init_rspec
13
+ init_spork
14
+ init_guard
15
+ end
16
+
17
+ # ----------------------------------------------------------------
18
+ protected
19
+ # ----------------------------------------------------------------
20
+
21
+ def add_gems
22
+ append_to_file "Gemfile", "\n\n# GEM FOR TESTING\n"
23
+
24
+ gem "rspec-rails", :group => [:test, :development]
25
+
26
+ gem "capybara", :group => :test
27
+
28
+ gem "factory_girl_rails", :group => :test
29
+
30
+ gem 'database_cleaner', :group => :test
31
+
32
+ gem 'timecop', :group => :test
33
+
34
+ gem "guard-rspec", :group => :test
35
+ gem 'guard-spork', :group => :test
36
+ gem 'spork', '~> 0.9.0.rc9', :group => :test
37
+ end
38
+
39
+ # ----------------------------------------------------------------
40
+
41
+ def init_rspec
42
+ generate "rspec:install"
43
+
44
+ %w{spec/support spec/models spec/routing spec/macro spec/factories}.each do |path|
45
+ empty_directory path
46
+ end
47
+
48
+ end
49
+
50
+ # ----------------------------------------------------------------
51
+
52
+ def init_spork
53
+ run "spork --bootstrap"
54
+ template "spec_helper.rb", "spec/spec_helper.rb", :force => true
55
+ end
56
+
57
+ # ----------------------------------------------------------------
58
+
59
+ def init_guard
60
+ run "guard init spork"
61
+ run "guard init rspec"
62
+
63
+ gsub_file "Guardfile", /guard 'rspec'.*? do/, "guard 'rspec', :version => 2, :cli => \"--drb -f d\" do"
64
+ end
65
+ end
66
+ end
67
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testing_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Frédéric Mascaro
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-17 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70231520458520 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.3.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70231520458520
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70231520457200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70231520457200
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &70231520454560 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.6.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70231520454560
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &70231520452180 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70231520452180
58
+ description: Initialize the configuration of the rails application to be tested.
59
+ email: frederic.mascaro@wo-oo.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files:
63
+ - LICENSE.txt
64
+ - README.rdoc
65
+ files:
66
+ - lib/generators/wooandoo/testing/templates/spec_helper.rb
67
+ - lib/generators/wooandoo/testing/testing_generator.rb
68
+ - LICENSE.txt
69
+ - README.rdoc
70
+ homepage: http://github.com/wooandoo/testing_rails
71
+ licenses:
72
+ - MIT
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ segments:
84
+ - 0
85
+ hash: -4461404137241955678
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.10
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Initialize the configuration of the rails application to be tested.
98
+ test_files: []