rails_apps_testing 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2fb7540e115f41fded77bfa902e5c64fdca2ecce
4
+ data.tar.gz: 78b787c1c2a71c8b930b6f73ee89da1759b556b7
5
+ SHA512:
6
+ metadata.gz: 3e4096bd8495eed4b5b6a036152e296d0c9a2fee2d92e1a783a6784aa53eec710502b2826cb619502fab4f52743a18fcb74f199e40c3c4d8a1983cad99709e63
7
+ data.tar.gz: d15ba5272e3255e0f8d15a03a6fff0f2f124c3fdd051d010cb4254469a5dbe435c8499624307b84042f558afb9fad2b92a863f3ff298f00bbb758bad56e60fbe
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .DS_Store
data/CHANGELOG.textile ADDED
@@ -0,0 +1,5 @@
1
+ h1. CHANGELOG
2
+
3
+ h3. 0.1.0 April 26, 2014
4
+
5
+ * set up RSpec and friends in a Rails application
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_apps_testing.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Daniel Kehoe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,191 @@
1
+ h1. !http://railsapps.github.io/images/rails-36x36.jpg(RailsAppsTesting Gem)! RailsAppsTesting Gem
2
+
3
+ Use this gem to set up a testing framework. The gem modifies a Rails application and configures:
4
+
5
+ * "RSpec Rails":https://github.com/rspec/rspec-rails – installs RSpec gems with support for Rails
6
+ * "Capybara":https://github.com/jnicklas/capybara – tests web pages
7
+ * "Database Cleaner":https://github.com/bmabey/database_cleaner – a clean slate for databases
8
+ * "FactoryGirl Rails":https://github.com/thoughtbot/factory_girl_rails – creates test data
9
+ * "Launchy":https://github.com/copiousfreetime/launchy – view errors in your web browser
10
+ * "Selenium Webdriver":http://docs.seleniumhq.org/projects/webdriver/ – for tests that require JavaScript
11
+
12
+ This suite of gems is popular for testing Rails applications. Typically, a developer makes several small configuration changes when setting up a test framework with these gems. The configuration changes are easy to make manually, but this gem provides a generator to make the changes, for ease of use with an automated process such as an application template.
13
+
14
+ RailsAppsTesting is a utility gem to use during development. You can remove it after setting up your test framework. It was originally written for use by the "Rails Composer":http://railsapps.github.io/rails-composer/ tool. Use Rails Composer to build any of the "RailApps example applications":http://railsapps.github.io/ for use as starter apps.
15
+
16
+ h4. !http://railsapps.github.io/images/join/join-railsapps.png(Join RailsApps)!:http://railsapps.github.io/
17
+
18
+ h4. Support the RailsApps Project
19
+
20
+ If the RailsAppsTesting gem is useful to you, please accept our invitation to "join the RailsApps project":http://railsapps.github.io/. The RailsApps project provides example applications, tutorials, and starter tools, including the RailsAppsTesting gem.
21
+
22
+ h2. Install a Testing Framework
23
+
24
+ The RailsApps project offers a tutorial:
25
+
26
+ * "RSpec Tutorial":http://railsapps.github.io/rspec.html
27
+
28
+ To install a testing framework, add the gems you need. Then use the RailsAppsTesting gem. It will set up and configure your testing framework.
29
+
30
+ Add the gems you need to your Rails application Gemfile:
31
+
32
+ <pre>
33
+ group :development do
34
+ gem 'rails_apps_testing'
35
+ end
36
+ group :development, :test do
37
+ gem 'rspec-rails'
38
+ gem 'factory_girl_rails'
39
+ end
40
+ group :test do
41
+ gem 'capybara'
42
+ gem 'database_cleaner'
43
+ gem 'launchy'
44
+ gem 'selenium-webdriver'
45
+ end
46
+ </pre>
47
+
48
+ You don't need the RailsAppsTesting gem deployed to production, so put it in the @development@ group.
49
+
50
+ If you want to use a newer unreleased version from GitHub:
51
+
52
+ <pre>
53
+ group :development do
54
+ gem 'rails_apps_testing', github: 'RailsApps/rails_apps_testing'
55
+ end
56
+ </pre>
57
+
58
+ h4. Use Bundler
59
+
60
+ Use Bundler to install the gems:
61
+
62
+ <pre>
63
+ $ bundle install
64
+ </pre>
65
+
66
+ h2. Configure RSpec and Friends
67
+
68
+ To run the generator and configure the testing framework:
69
+
70
+ <pre>
71
+ $ rails generate testing:configure rspec
72
+ </pre>
73
+
74
+ Use @--force@ if you want to overwrite existing files:
75
+
76
+ <pre>
77
+ $ rails generate testing:configure rspec --force
78
+ </pre>
79
+
80
+ h3. RSpec Configuration
81
+
82
+ The RailsAppsTesting generator will remove the legacy *test/* folder if it exists (it is not needed for RSpec).
83
+
84
+ The RailsAppsTesting generator will run @rails generate rspec:install@ to create two files and a folder:
85
+
86
+ * *.rspec*
87
+ * *spec/*
88
+ * *spec/spec_helper.rb*
89
+
90
+ Then the RailsAppsTesting generator will configure RSpec.
91
+
92
+ It will modify the file *.rspec* to add:
93
+
94
+ <pre>
95
+ --format documentation
96
+ </pre>
97
+
98
+ It will modify the file *config/application.rb* to suppress creation of stub files that many developers don't use:
99
+
100
+ <pre>
101
+ config.generators do |g|
102
+ g.test_framework :rspec,
103
+ fixtures: true,
104
+ view_specs: false,
105
+ helper_specs: false,
106
+ routing_specs: false,
107
+ controller_specs: false,
108
+ request_specs: false
109
+ g.fixture_replacement :factory_girl, dir: "spec/factories"
110
+ end
111
+ </pre>
112
+
113
+ h3. Capybara and Launchy Configuration
114
+
115
+ The generator will set up Capybara and Launchy to display CSS and JavaScript with a file *spec/support/capybara.rb*:
116
+
117
+ <pre>
118
+ Capybara.asset_host = 'http://localhost:3000'
119
+ </pre>
120
+
121
+ h3. Database Cleaner Configuration
122
+
123
+ The generator will set up Database Cleaner to test JavaScript with a file *spec/support/database_cleaner.rb*:
124
+
125
+ <pre>
126
+ RSpec.configure do |config|
127
+ config.before(:suite) do
128
+ DatabaseCleaner.clean_with(:truncation)
129
+ end
130
+
131
+ config.before(:each) do
132
+ DatabaseCleaner.strategy = :transaction
133
+ end
134
+
135
+ config.before(:each, :js => true) do
136
+ DatabaseCleaner.strategy = :truncation
137
+ end
138
+
139
+ config.before(:each) do
140
+ DatabaseCleaner.start
141
+ end
142
+
143
+ config.append_after(:each) do
144
+ DatabaseCleaner.clean
145
+ end
146
+ end
147
+ </pre>
148
+
149
+ It will also modify *spec/spec_helper.rb*:
150
+
151
+ <pre>
152
+ config.use_transactional_fixtures = false
153
+ </pre>
154
+
155
+ h3. FactoryGirl Configuration
156
+
157
+ The generator will set up FactoryGirl shortcuts with a file *spec/support/factory_girl.rb*:
158
+
159
+ <pre>
160
+ RSpec.configure do |config|
161
+ config.include FactoryGirl::Syntax::Methods
162
+ end
163
+ </pre>
164
+
165
+ h3. Devise Configuration
166
+
167
+ If Devise in installed in your application, the generator will add a file *spec/support/devise.rb*:
168
+
169
+ <pre>
170
+ RSpec.configure do |config|
171
+ config.include Devise::TestHelpers, :type => :controller
172
+ end
173
+ </pre>
174
+
175
+ h2. Issues
176
+
177
+ Any issues? Please create an "issue":http://github.com/RailsApps/rails_apps_testing/issues on GitHub. Reporting issues (and patching!) helps everyone.
178
+
179
+ h2. Credits
180
+
181
+ Daniel Kehoe maintains this gem as part of the "RailsApps project":http://railsapps.github.io/.
182
+
183
+ Please see the "CHANGELOG":https://github.com/RailsApps/rails_apps_testing/blob/master/CHANGELOG.textile for a list of contributors.
184
+
185
+ Is the gem useful to you? Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps. I'd love to know you were helped out by the gem.
186
+
187
+ h2. MIT License
188
+
189
+ "MIT License":http://www.opensource.org/licenses/mit-license
190
+
191
+ Copyright © 2014 Daniel Kehoe
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,34 @@
1
+ require 'rails/generators'
2
+
3
+ module Testing
4
+ module Generators
5
+ class ConfigureGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ argument :framework_name, :type => :string, :default => "rspec"
8
+
9
+ desc "Sets up a testing framework."
10
+
11
+ attr_reader :app_name
12
+
13
+ def configure_framework
14
+ case framework_name
15
+ when 'rspec'
16
+ run 'rm -rf test/' # Removing test folder (not needed for RSpec)
17
+ generate 'rspec:install'
18
+ inject_into_file '.rspec', "--format documentation\n", :after => "--color\n"
19
+ tweaks = File.read(find_in_source_paths('application.rb'))
20
+ inject_into_file 'config/application.rb', tweaks + "\n", :after => "Rails::Application\n"
21
+ gsub_file 'spec/spec_helper.rb', /check_pending/, 'maintain_test_schema'
22
+ copy_file 'capybara.rb', 'spec/support/capybara.rb'
23
+ gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures = true/, "config.use_transactional_fixtures = false"
24
+ copy_file 'database_cleaner.rb', 'spec/support/database_cleaner.rb'
25
+ copy_file 'factory_girl.rb', 'spec/support/factory_girl.rb'
26
+ if File.exists?('config/initializers/devise.rb')
27
+ copy_file 'devise.rb', 'spec/support/devise.rb'
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+
2
+ config.generators do |g|
3
+ g.test_framework :rspec,
4
+ fixtures: true,
5
+ view_specs: false,
6
+ helper_specs: false,
7
+ routing_specs: false,
8
+ controller_specs: false,
9
+ request_specs: false
10
+ g.fixture_replacement :factory_girl, dir: "spec/factories"
11
+ end
@@ -0,0 +1 @@
1
+ Capybara.asset_host = 'http://localhost:3000'
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:truncation)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, :js => true) do
11
+ DatabaseCleaner.strategy = :truncation
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.append_after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include Devise::TestHelpers, :type => :controller
3
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,5 @@
1
+ require "rails_apps_testing/version"
2
+
3
+ module RailsAppsTesting
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAppsTesting
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_apps_testing/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_apps_testing"
8
+ spec.version = RailsAppsTesting::VERSION
9
+ spec.authors = ["Daniel Kehoe"]
10
+ spec.email = ["daniel@danielkehoe.com"]
11
+ spec.summary = %q{Sets up a testing framework for a Rails application.}
12
+ spec.description = %q{Configures a suite of gems used for testing Rails applications.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_apps_testing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Kehoe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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
+ description: Configures a suite of gems used for testing Rails applications.
42
+ email:
43
+ - daniel@danielkehoe.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - CHANGELOG.textile
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.textile
53
+ - Rakefile
54
+ - lib/generators/testing/configure/configure_generator.rb
55
+ - lib/generators/testing/configure/templates/application.rb
56
+ - lib/generators/testing/configure/templates/capybara.rb
57
+ - lib/generators/testing/configure/templates/database_cleaner.rb
58
+ - lib/generators/testing/configure/templates/devise.rb
59
+ - lib/generators/testing/configure/templates/factory_girl.rb
60
+ - lib/rails_apps_testing.rb
61
+ - lib/rails_apps_testing/version.rb
62
+ - rails_apps_testing.gemspec
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.2.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Sets up a testing framework for a Rails application.
87
+ test_files: []