vault-test-tools 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  test.profile*
19
+ vendor
data/LICENSE.txt CHANGED
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
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.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Vault::Test
2
2
 
3
- Test Tools for the Heroku Vault Team
3
+ Test Tools for the Heroku Vault Team.
4
4
 
5
5
  ## Installation
6
6
 
@@ -25,7 +25,7 @@ Sublcass and go:
25
25
  ```ruby
26
26
  class MyTest < Vault::TestCase
27
27
  def test_tautologies
28
- assert_equal 1+1,2
28
+ assert_equal 1+1, 2
29
29
  end
30
30
  end
31
31
  ```
@@ -44,7 +44,8 @@ end
44
44
 
45
45
  ### Uniform Module Sharing
46
46
 
47
- To extend your test classes uniformly, use the method `Vault::Test.include_in_all`
47
+ To extend your test and spec base classes uniformly, use the method
48
+ `Vault::Test.include_in_all`
48
49
 
49
50
  ```ruby
50
51
  module MyTestHelperClass
@@ -56,7 +57,6 @@ Vault::Test.include_in_all Vault::MyTestHelperClass
56
57
 
57
58
  Now you have an `#app` method in your `Vault::TestCase` and your `Vault::Spec`
58
59
 
59
-
60
60
  ## Contributing
61
61
 
62
62
  1. Fork it
@@ -64,3 +64,8 @@ Now you have an `#app` method in your `Vault::TestCase` and your `Vault::Spec`
64
64
  3. Commit your changes (`git commit -am 'Add some feature'`)
65
65
  4. Push to the branch (`git push origin my-new-feature`)
66
66
  5. Create new Pull Request
67
+
68
+ ## Releasing
69
+
70
+ Update the version in `lib/vault-test-tools/version` and run
71
+ `bundle exec rake release`.
@@ -0,0 +1,21 @@
1
+ module Vault::Test::EnvironmentHelpers
2
+ # Override an ENV variable for the current test. The original value will be
3
+ # restored automatically when the test finishes.
4
+ def set_env(key, value)
5
+ # FIXME Blow up if the key already exists in overrides? -jkakar
6
+ overrides[key] = ENV[key]
7
+ ENV[key] = value
8
+ end
9
+
10
+ def teardown
11
+ overrides.each { |key, value| ENV[key] = value }
12
+ super
13
+ end
14
+
15
+ private
16
+
17
+ # The overridden environment variables to restore when the test finishes.
18
+ def overrides
19
+ @overrides ||= {}
20
+ end
21
+ end
@@ -1,4 +1,4 @@
1
- module Vault::TestHelpers
1
+ module Vault::Test::HTMLHelpers
2
2
  def save_and_open_page(html = nil, name = 'page.html', i = 1)
3
3
  html ||= last_response.body
4
4
  name = "page_#{i=i+1}.html" while File.exist? name
@@ -28,13 +28,4 @@ module Vault::TestHelpers
28
28
  assert e, "Element not found: #{css_string}"
29
29
  assert_includes e.content, content
30
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
31
  end
40
-
@@ -1,10 +1,12 @@
1
1
  require 'minitest/spec'
2
+ require 'scrolls'
2
3
 
4
+ # Base class for Vault spec tests.
3
5
  class Vault::Spec < MiniTest::Spec
4
6
  before do
5
7
  Scrolls.stream = StringIO.new
6
8
  end
7
9
  end
8
10
 
9
- # Register our Spec class as the default
11
+ # Register our Spec class as the default.
10
12
  MiniTest::Spec.register_spec_type //, Vault::Spec
@@ -1,4 +1,5 @@
1
1
  require 'minitest/unit'
2
+ require 'scrolls'
2
3
 
3
4
  # Base class for Vault test cases.
4
5
  class Vault::TestCase < MiniTest::Unit::TestCase
@@ -6,8 +7,4 @@ class Vault::TestCase < MiniTest::Unit::TestCase
6
7
  super
7
8
  Scrolls.stream = StringIO.new
8
9
  end
9
-
10
- def teardown
11
- super
12
- end
13
10
  end
@@ -1,5 +1,5 @@
1
1
  module Vault
2
2
  module Test
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -5,7 +5,8 @@ require 'nokogiri'
5
5
 
6
6
  require "vault-test-tools/test_case"
7
7
  require "vault-test-tools/spec"
8
- require "vault-test-tools/helpers"
8
+ require "vault-test-tools/environment_helpers"
9
+ require "vault-test-tools/html_helpers"
9
10
 
10
11
  module Vault
11
12
  module Test
@@ -17,4 +18,5 @@ module Vault
17
18
  end
18
19
 
19
20
  Vault::Test.include_in_all Rack::Test::Methods
20
- Vault::Test.include_in_all Vault::TestHelpers
21
+ Vault::Test.include_in_all Vault::Test::EnvironmentHelpers
22
+ Vault::Test.include_in_all Vault::Test::HTMLHelpers
data/test/helper.rb CHANGED
@@ -1,2 +1 @@
1
-
2
1
  require 'vault-test-tools'
data/test/test_spec.rb CHANGED
@@ -1,7 +1,15 @@
1
- class TestSpec < MiniTest::Unit::TestCase
1
+ class TestSpec < Vault::TestCase
2
2
 
3
3
  def test_default_spec_class_is_vault_spec
4
4
  assert_equal Vault::Spec, MiniTest::Spec.spec_type('')
5
5
  end
6
6
 
7
7
  end
8
+
9
+ class SpecTest < Vault::Spec
10
+ describe "Vault::Spec" do
11
+ it 'should be runnable' do
12
+ assert true
13
+ end
14
+ end
15
+ end
@@ -23,4 +23,5 @@ Gem::Specification.new do |gem|
23
23
  gem.add_dependency 'nokogiri'
24
24
  gem.add_dependency 'rack-test'
25
25
  gem.add_dependency 'rdoc'
26
+ gem.add_dependency 'scrolls'
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vault-test-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-08 00:00:00.000000000 Z
13
+ date: 2012-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: turn
@@ -108,6 +108,22 @@ dependencies:
108
108
  - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: scrolls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
111
127
  description: Basic tools for Heroku Vault's Ruby projects
112
128
  email:
113
129
  - chriscontinanza@gmail.com
@@ -127,7 +143,8 @@ files:
127
143
  - bin/d
128
144
  - bin/t
129
145
  - lib/vault-test-tools.rb
130
- - lib/vault-test-tools/helpers.rb
146
+ - lib/vault-test-tools/environment_helpers.rb
147
+ - lib/vault-test-tools/html_helpers.rb
131
148
  - lib/vault-test-tools/spec.rb
132
149
  - lib/vault-test-tools/test_case.rb
133
150
  - lib/vault-test-tools/version.rb
@@ -148,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
165
  version: '0'
149
166
  segments:
150
167
  - 0
151
- hash: -4263912932500243358
168
+ hash: 4140424068332135162
152
169
  required_rubygems_version: !ruby/object:Gem::Requirement
153
170
  none: false
154
171
  requirements:
@@ -157,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
174
  version: '0'
158
175
  segments:
159
176
  - 0
160
- hash: -4263912932500243358
177
+ hash: 4140424068332135162
161
178
  requirements: []
162
179
  rubyforge_project:
163
180
  rubygems_version: 1.8.23