vault-test-tools 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ test.profile*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vault-dev-tools.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Chris Continanza
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.md ADDED
@@ -0,0 +1,66 @@
1
+ # Vault::Test
2
+
3
+ Test Tools for the Heroku Vault Team
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ group :test do
10
+ gem 'vault-test-tools'
11
+ end
12
+
13
+ ## Usage
14
+
15
+ ### test/helper.rb
16
+
17
+ ```ruby
18
+ require 'vault-test-tools'
19
+ ```
20
+
21
+ ### Test Base Classes
22
+
23
+ Sublcass and go:
24
+
25
+ ```ruby
26
+ class MyTest < Vault::TestCase
27
+ def test_tautologies
28
+ assert_equal 1+1,2
29
+ end
30
+ end
31
+ ```
32
+
33
+ ### Spec Base Class
34
+
35
+ Automatically installed as default. Just:
36
+
37
+ ```ruby
38
+ describe 'Anything' do
39
+ it 'should be a Vault::Spec' do
40
+ MiniTest::Spec.spec_type('').must_equal Vault::Spec
41
+ end
42
+ end
43
+ ```
44
+
45
+ ### Uniform Module Sharing
46
+
47
+ To extend your test classes uniformly, use the method `Vault::Test.include_in_all`
48
+
49
+ ```ruby
50
+ module MyTestHelperClass
51
+ def app; Vault::InvoiceBuilder::Web; end
52
+ end
53
+
54
+ Vault::Test.include_in_all Vault::MyTestHelperClass
55
+ ```
56
+
57
+ Now you have an `#app` method in your `Vault::TestCase` and your `Vault::Spec`
58
+
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/d ADDED
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ system(%|bundle exec rdoc --ri lib test|)
4
+ system(%|bundle exec rdoc --force-output lib test|)
data/bin/t ADDED
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ ENV['CPUPROFILE'] = './test.profile'
4
+ exec('bundle exec turn -r perftools -I test test')
@@ -0,0 +1,20 @@
1
+ require "vault-test-tools/version"
2
+
3
+ require 'rack/test'
4
+ require 'nokogiri'
5
+
6
+ require "vault-test-tools/test_case"
7
+ require "vault-test-tools/spec"
8
+ require "vault-test-tools/helpers"
9
+
10
+ module Vault
11
+ module Test
12
+ def self.include_in_all(_module)
13
+ Vault::TestCase.send(:include, _module)
14
+ Vault::Spec.send(:include, _module)
15
+ end
16
+ end
17
+ end
18
+
19
+ Vault::Test.include_in_all Rack::Test::Methods
20
+ Vault::Test.include_in_all Vault::TestHelpers
@@ -0,0 +1,40 @@
1
+ module Vault::TestHelpers
2
+ def save_and_open_page(html = nil, name = 'page.html', i = 1)
3
+ html ||= last_response.body
4
+ name = "page_#{i=i+1}.html" while File.exist? name
5
+ File.open(name, 'w') { |f| f << html }
6
+ system "open #{name}"
7
+ end
8
+
9
+ def set_doc(body)
10
+ @doc = Nokogiri::HTML(body)
11
+ end
12
+
13
+ def doc
14
+ @doc || Nokogiri::HTML(last_response.body)
15
+ end
16
+
17
+ def css(string)
18
+ doc.css(string)
19
+ end
20
+
21
+ def assert_includes_css(css_string)
22
+ exists = doc.css(css_string).first
23
+ assert exists, "Last response must include #{css_string}"
24
+ end
25
+
26
+ def assert_css(css_string, content)
27
+ e = css(css_string).first
28
+ assert e, "Element not found: #{css_string}"
29
+ assert_includes e.content, content
30
+ end
31
+
32
+ def with_env(key, value)
33
+ old_env = ENV[key]
34
+ ENV[key] = value
35
+ yield
36
+ ensure
37
+ ENV[key] = old_env
38
+ end
39
+ end
40
+
@@ -0,0 +1,10 @@
1
+ require 'minitest/spec'
2
+
3
+ class Vault::Spec < MiniTest::Spec
4
+ before do
5
+ Scrolls.stream = StringIO.new
6
+ end
7
+ end
8
+
9
+ # Register our Spec class as the default
10
+ MiniTest::Spec.register_spec_type //, Vault::Spec
@@ -0,0 +1,13 @@
1
+ require 'minitest/unit'
2
+
3
+ # Base class for Vault test cases.
4
+ class Vault::TestCase < MiniTest::Unit::TestCase
5
+ def setup
6
+ super
7
+ Scrolls.stream = StringIO.new
8
+ end
9
+
10
+ def teardown
11
+ super
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Vault
2
+ module Test
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,2 @@
1
+
2
+ require 'vault-test-tools'
data/test/test_spec.rb ADDED
@@ -0,0 +1,7 @@
1
+ class TestSpec < MiniTest::Unit::TestCase
2
+
3
+ def test_default_spec_class_is_vault_spec
4
+ assert_equal Vault::Spec, MiniTest::Spec.spec_type('')
5
+ end
6
+
7
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vault-test-tools/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "vault-test-tools"
8
+ gem.version = Vault::Test::VERSION
9
+ gem.authors = ["Chris Continanza", "Jamu Kakar"]
10
+ gem.email = ["chriscontinanza@gmail.com", "csquared@heroku.com", "jkakar@heroku.com"]
11
+ gem.description = %q{Basic tools for Heroku Vault's Ruby projects}
12
+ gem.summary = %q{Test classes and stuff you want in your dev, but not prod, environment.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = ['t','d']
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'turn'
21
+ gem.add_dependency 'minitest'
22
+ gem.add_dependency 'rack-perftools_profiler'
23
+ gem.add_dependency 'nokogiri'
24
+ gem.add_dependency 'rack-test'
25
+ gem.add_dependency 'rdoc'
26
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vault-test-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Continanza
9
+ - Jamu Kakar
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-12-08 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: turn
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: minitest
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rack-perftools_profiler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: nokogiri
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: rack-test
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: rdoc
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Basic tools for Heroku Vault's Ruby projects
112
+ email:
113
+ - chriscontinanza@gmail.com
114
+ - csquared@heroku.com
115
+ - jkakar@heroku.com
116
+ executables:
117
+ - t
118
+ - d
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - .gitignore
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/d
128
+ - bin/t
129
+ - lib/vault-test-tools.rb
130
+ - lib/vault-test-tools/helpers.rb
131
+ - lib/vault-test-tools/spec.rb
132
+ - lib/vault-test-tools/test_case.rb
133
+ - lib/vault-test-tools/version.rb
134
+ - test/helper.rb
135
+ - test/test_spec.rb
136
+ - vault-test-tools.gemspec
137
+ homepage: ''
138
+ licenses: []
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ segments:
150
+ - 0
151
+ hash: -4263912932500243358
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ segments:
159
+ - 0
160
+ hash: -4263912932500243358
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 1.8.23
164
+ signing_key:
165
+ specification_version: 3
166
+ summary: Test classes and stuff you want in your dev, but not prod, environment.
167
+ test_files:
168
+ - test/helper.rb
169
+ - test/test_spec.rb