gyst 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ Gemfile.lock
2
+ *.gem
3
+ .bundle/
4
+ .yardoc/
5
+ _site/
6
+ doc/
7
+ pkg/
8
+ tmp/
data/Changelog.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.0.2 (May 27, 2011) - Happy Birthday Mom.
2
+
3
+ Features:
4
+
5
+ - scripts: rakee, raket
6
+ - patches: gyst/factory_girl
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gys.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'factory_girl' # not in gemspec since use of factory_girl patch is optional
8
+ end
9
+
10
+ group :blog do
11
+ gem 'jekyll', '0.10.0' # version for gh_pages
12
+ gem 'liquid', '2.0.0' # version for gh_pages (http://support.github.com/discussions/site/3216-github-pages-liquid-template-tags-not-being-parsed)
13
+ gem 'rdiscount' # I haven't found the gh_pages specific version yet.
14
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2011 Matthew Scilipoti
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.
21
+
data/README.md ADDED
@@ -0,0 +1,161 @@
1
+ Grease Your Suite Toolkit (gyst)
2
+ ================================
3
+
4
+ Purpose
5
+ --------
6
+ A suite of helpers to aid in speeding up your tests; including scripts,
7
+ existing libraries, and patches.
8
+
9
+ Inspired by Nick Gauthier's ["Grease-Your-Suite" presentation(s)][gys_showoff].
10
+
11
+ Faster tests? Good.
12
+
13
+ Install
14
+ --------
15
+ This will be released to rubygems.org once we have a little more
16
+ functionality.
17
+ **NOTE:** in order to use the bash scripts, you must use the `--no-wrapper`
18
+ argument.
19
+ gem install pkg/gyst-0.0.1.gem --no-wrappers
20
+
21
+
22
+ Dependencies
23
+ ------------
24
+
25
+ No runtime dependencies (except for the libraries you choose to patch).
26
+
27
+
28
+ Scripts
29
+ --------
30
+ Various helper scripts.
31
+
32
+ rakee # runs rake tasks with REE configured for tests
33
+ raket # hydra helper, runs rake tasks with RAILS_ENV=test and REE configured for tests
34
+ grease_your_suite.sh # configures REE (different for linux/osx?
35
+
36
+
37
+ ### rakee
38
+ ---
39
+ `rakee` configures REE for testing, then runs the task(s). It simply executes grease_your_suite.sh before running the rake task.
40
+
41
+ Usage:
42
+
43
+ rakee # runs all tests after configuring REE
44
+ rakee test:units
45
+ rakee features
46
+
47
+
48
+ ### raket
49
+ ---
50
+ `raket` is a helper for the [hydra gem](https://github.com/ngauthier/hydra). Hydra requires that `RAILS_ENV=test`. `raket` sets RAILS_ENV and configures REE for testing, then runs the task(s).
51
+
52
+ Usage:
53
+
54
+ raket hydra
55
+ raket hydra:specs
56
+
57
+
58
+ ### grease_your_suite.sh (gys)
59
+ ---
60
+ This script configures Ruby Enterprise Edition (REE) for testing,
61
+ as [suggested here][gys_showoff].
62
+ Usually used as a helper script for rake tasks.
63
+ Also useful for a group of specs.
64
+
65
+ We recommend you use an alias:
66
+
67
+ alias gys=grease_your_suite.sh
68
+
69
+ Usage:
70
+
71
+ gys cucumber
72
+ gys rspec spec
73
+ gys rspec -cfs spec/a_sub_dir
74
+
75
+
76
+ ***API***
77
+ ---
78
+
79
+ ### Libraries
80
+ ---
81
+ <strong>As of 2011-05, "`require 'gyst'`" is a noop.</strong>
82
+ You must require the pieces the you want. We'll turn this on once more pieces are available, otherwise we will probably break things with each release.
83
+ Patch factory_girl to use :build, break stuff.
84
+ Add 'db_null', break stuff.
85
+ Simply by using "require 'gyst'"? Let's wait.
86
+
87
+ ---
88
+
89
+ We are using "selective requires" for the libraries and scripts. Want everything, simply:
90
+ require 'gyst' # (TODO) enables all the libraries and applies all the patches
91
+
92
+ You can also just `require` the pieces you want.
93
+
94
+ #### DbNull
95
+ Yells if you try to access the db
96
+
97
+ require 'gyst/db_null' # (TODO)
98
+
99
+
100
+ ### Patches
101
+ ---
102
+
103
+ #### Factory Girl
104
+ Sets default_strategy to :build. Creating models in the db is slow.
105
+ Don't do it if you don't have to.
106
+
107
+
108
+ require 'gyst/factory_girl' # all factory_girl enhancements (rspec, test_unit, etc)
109
+ require 'gyst/factory_girl/rspec' # (TODO) just patch for rspec
110
+ require 'gyst/factory_girl/test_unit' # (TODO) just patch for Test::Unit
111
+
112
+
113
+ Tested On
114
+ --------------
115
+ Ruby 1.9.2 (p180)
116
+
117
+
118
+ Contribute
119
+ -----------
120
+ Contributions and discussions are welcome.
121
+ Feel free to add sugggestions and bugs to our [issues on github](https://github.com/mattscilipoti/gyst/issues).
122
+
123
+ * Fork the project.
124
+ * `bundle install`. Run all tests with `rakee`
125
+ * Make your feature addition or bug fix.
126
+ * Add tests for it. This is important so I don't break it in a
127
+ future version unintentionally. Note: the existing tests may fail
128
+ with pre-1.9 versions of ruby; upgrade to get clean runs.
129
+ * Commit, do not mess with rakefile, version, or history.
130
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
131
+ * Send me a pull request. Bonus points for topic branches.
132
+
133
+ *NOTE*: when adding a new shell script
134
+
135
+ * add to git index
136
+ * `rake build`
137
+ * gem install pkg/gyst-0.0.?.gem --no-wrappers
138
+
139
+ References
140
+ -----------
141
+ * https://github.com/ngauthier/Grease-Your-Suite
142
+ * http://m.onkey.org/make-your-shoulda-tests-faster-with-fast_context
143
+ * http://37signals.com/svn/posts/2742-the-road-to-faster-tests
144
+ * http://ola-bini.blogspot.com/2007/12/your-ruby-tests-are-memory-leaks.html
145
+ * http://makandra.com/notes/950-speed-up-rspec-by-deferring-garbage-collection
146
+
147
+
148
+
149
+ TODO
150
+ -----
151
+ * Add to rdoc.info
152
+ * CI at travis
153
+ * Multi-ruby testing:
154
+ * http://rails-bestpractices.com/blog/posts/11-test-your-rubygem-under-different-rubies
155
+ * https://github.com/tomas-stefano/infinity_test
156
+
157
+
158
+ [gys_showoff]: http://grease-your-suite.heroku.com/ "Grease Your Suites"
159
+
160
+ ____
161
+ Copyright (c) 2011 Matthew Scilipoti, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+
5
+ require 'rake/testtask'
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.pattern = "test/*_spec.rb"
9
+ end
10
+
11
+
12
+ require 'cucumber'
13
+ require 'cucumber/rake/task'
14
+
15
+ Cucumber::Rake::Task.new(:features) do |t|
16
+ t.cucumber_opts = "features --format pretty"
17
+ end
18
+
19
+ task :default => [:test, :features]
20
+
21
+
22
+ # rake tasks for testing
23
+ task :pass do
24
+ puts "PASSED"
25
+ end
26
+
27
+ task :fail do
28
+ fail "EXPECTED FAILURE"
29
+ end
30
+
@@ -0,0 +1,13 @@
1
+ #!/bin/sh
2
+
3
+ # Note: to generate this without the ruby gems wrapper,
4
+ # we used the --no-wrapper arg
5
+ echo "INFO: Configuring REE (re: grease_your_suite)"
6
+ export RUBY_HEAP_MIN_SLOTS=1000000
7
+ export RUBY_HEAP_SLOTS_INCREMENT=1000000
8
+ export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
9
+ export RUBY_GC_MALLOC_LIMIT=1000000000
10
+ export RUBY_HEAP_FREE_MIN=500000111
11
+
12
+ time $@
13
+
data/bin/rakee ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ grease_your_suite.sh rake $@
4
+
data/bin/raket ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ ## Hydra needs test env.
3
+ echo "Loading test environment..."
4
+ RAILS_ENV=test rakee $*
5
+
@@ -0,0 +1,17 @@
1
+ Feature: the grease_your_suite script sets configuration options for REE
2
+
3
+ In order to speed up tests, the gys script should
4
+ assign the environment values
5
+ to configure GC appropriately for testing
6
+
7
+
8
+ Scenario: the script sets Environment Variables
9
+ When I run `grease_your_suite.sh`
10
+ # output includes message and output from `time`
11
+ Then it should pass with:
12
+ """
13
+ INFO: Configuring REE (re: grease_your_suite)
14
+
15
+ real 0m0
16
+ """
17
+
@@ -0,0 +1,9 @@
1
+ Feature: rakee
2
+ In order to run testing quickly from rake tasks
3
+ We want to configure REE
4
+
5
+ Scenario: rakee pass
6
+ When I successfully run `rakee pass`
7
+ Then the output should contain "Configuring REE"
8
+ And the output should contain "PASS"
9
+ And the output should contain "real 0m0"
@@ -0,0 +1,11 @@
1
+ Feature: raket
2
+ In order to run hydra quickly from rake tasks
3
+ We want to configure REE and set RAILS_ENV
4
+
5
+ Scenario: raket pass
6
+ When I successfully run `raket pass`
7
+ Then the output should contain "Loading test environment..."
8
+ And the output should contain "Configuring REE"
9
+ And the output should contain "PASS"
10
+ And the output should contain "real 0m0"
11
+
@@ -0,0 +1,15 @@
1
+ Feature: factory_girl patch
2
+
3
+ @gemset
4
+ Scenario: friendly loading (no such gem)
5
+
6
+ Given I'm using a new gemset
7
+ And a file named "gyst_factory_girl.rb" with:
8
+ """
9
+ require '../../lib/gyst/factory_girl'
10
+ """
11
+
12
+ When I run `ruby gyst_factory_girl.rb`
13
+ Then the output should contain "Could not find 'factory_girl'"
14
+
15
+
@@ -0,0 +1,14 @@
1
+ Given /^(?:I'm|I am) using a new gemset$/ do
2
+ use_clean_gemset(CLEAN_GEMSET)
3
+ end
4
+
5
+ Given /^(?:I'm|I am) using a new gemset with these gems:$/ do |table|
6
+ # table is a Cucumber::Ast::Table
7
+ Given "I am using a new gemset"
8
+
9
+ table.rows.each do |row|
10
+ gem = row.first
11
+ run_simple("gem install #{gem}", true)
12
+ end
13
+ end
14
+
@@ -0,0 +1,15 @@
1
+ # require 'ruby-debug'
2
+ require 'aruba/cucumber'
3
+
4
+ Before do
5
+ @aruba_timeout_seconds = 3
6
+ end
7
+
8
+ CLEAN_GEMSET = 'delete_me'
9
+
10
+ Before('@gemset') do
11
+ puts "INFO: feature may be slow, please be patient. Using --no-rdoc in ~/.gemrc helps."
12
+ run_simple("rvm --force gemset delete #{CLEAN_GEMSET}", true)
13
+ @aruba_timeout_seconds = 20
14
+ end
15
+
data/gyst.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gyst/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "gyst"
7
+ s.version = Gyst::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Matt Scilipoti"]
10
+ s.email = ["matt@scilipoti.name"]
11
+ s.homepage = ""
12
+ s.summary = %q{A suite of helpers to aid in speeding up your tests.}
13
+ s.description = %q{A suite of helpers to aid in speeding up your tests; including scripts, existing libraries, and patches.
14
+ }
15
+
16
+ s.rubyforge_project = "gyst"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency('aruba')
24
+ s.add_development_dependency('minitest')
25
+ s.add_development_dependency('rake')
26
+ end
data/lib/gyst.rb ADDED
@@ -0,0 +1 @@
1
+ # require 'gyst/factory_girl'
@@ -0,0 +1,24 @@
1
+ # since use of this "patch" is optional,
2
+ # we should not add "factory_girl" as a dependency
3
+ begin
4
+ require 'factory_girl'
5
+ rescue LoadError
6
+ $stderr.puts <<-EOS
7
+ #{'*'*50}
8
+ "ERROR: Could not find 'factory_girl'.
9
+ You should either install it (https://github.com/thoughtbot/factory_girl)
10
+ or be more specific about which parts of `gyst` you would like to use (see README)."
11
+ #{'*'*50}
12
+ EOS
13
+
14
+ raise
15
+ end
16
+
17
+ Factory.class_eval do
18
+ # change default_strategy to build, instead of :create
19
+ # TODO: patch FactoryGirl to allow setting overall default_strategy
20
+ def default_strategy #:nodoc:
21
+ @options[:default_strategy] || :build
22
+ end
23
+ end
24
+
@@ -0,0 +1,3 @@
1
+ module Gyst
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,12 @@
1
+ require 'minitest/autorun'
2
+ # require 'minitest/pride' # undefined method `output' for MiniTest::Unit:Class (NoMethodError)
3
+
4
+ require File.expand_path('../lib/gyst/factory_girl', File.dirname(__FILE__))
5
+
6
+
7
+ describe Factory do
8
+ it "should use :build by default" do
9
+ subject = Factory.new(:test)
10
+ subject.default_strategy.must_equal :build
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gyst
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - Matt Scilipoti
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-27 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: aruba
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rake
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
49
+ description: "A suite of helpers to aid in speeding up your tests; including scripts, existing libraries, and patches.\n "
50
+ email:
51
+ - matt@scilipoti.name
52
+ executables:
53
+ - grease_your_suite.sh
54
+ - rakee
55
+ - raket
56
+ extensions: []
57
+
58
+ extra_rdoc_files: []
59
+
60
+ files:
61
+ - .gitignore
62
+ - Changelog.md
63
+ - Gemfile
64
+ - MIT-LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - bin/grease_your_suite.sh
68
+ - bin/rakee
69
+ - bin/raket
70
+ - features/command_line/grease_your_suite.feature
71
+ - features/command_line/rakee.feature
72
+ - features/command_line/raket.feature
73
+ - features/patches/factory_girl.feature
74
+ - features/step_definitions/rvm_steps.rb
75
+ - features/support/env.rb
76
+ - gyst.gemspec
77
+ - lib/gyst.rb
78
+ - lib/gyst/factory_girl.rb
79
+ - lib/gyst/version.rb
80
+ - test/factory_girl_spec.rb
81
+ has_rdoc: true
82
+ homepage: ""
83
+ licenses: []
84
+
85
+ post_install_message:
86
+ rdoc_options: []
87
+
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project: gyst
105
+ rubygems_version: 1.6.2
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: A suite of helpers to aid in speeding up your tests.
109
+ test_files:
110
+ - features/command_line/grease_your_suite.feature
111
+ - features/command_line/rakee.feature
112
+ - features/command_line/raket.feature
113
+ - features/patches/factory_girl.feature
114
+ - features/step_definitions/rvm_steps.rb
115
+ - features/support/env.rb
116
+ - test/factory_girl_spec.rb