temporaries 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.0 2012-06-06
2
+
3
+ * Support minitest/unit and minitest/spec.
4
+
1
5
  == 0.0.3 2011-11-17
2
6
 
3
7
  * Attempt to fix Syck error on install in gemspec.
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require 'ritual'
2
+
3
+ task :ci do
4
+ if RUBY_VERSION >= '1.9'
5
+ sh 'bundle exec rspec spec && bundle exec cucumber'
6
+ else
7
+ sh 'bundle exec rspec spec && bundle exec cucumber --tags=~@1.9'
8
+ end
9
+ end
@@ -0,0 +1,50 @@
1
+ @1.9
2
+ Feature: MiniTest Integration
3
+
4
+ As a developer using MiniTest
5
+ I want to define temporary values
6
+ So I can run my tests in isolation
7
+
8
+ Scenario: Using temporary values with MiniTest::Unit
9
+ Given I have a file "mini_test_unit.rb" containing:
10
+ """
11
+ require 'minitest/unit'
12
+ require 'minitest/autorun'
13
+ require 'temporaries'
14
+
15
+ module Mod
16
+ X = 2
17
+ end
18
+
19
+ class MyTest < MiniTest::Unit::TestCase
20
+ use_constant_value Mod, :X, 5
21
+
22
+ def test_should_have_x_set_to_5_in_each_test
23
+ assert_equal 5, Mod::X
24
+ end
25
+ end
26
+ """
27
+ When I run "ruby mini_test_unit.rb"
28
+ Then I should see "1 tests, 1 assertions, 0 failures, 0 errors"
29
+
30
+ Scenario: Using temporary values with MiniTest::Spec
31
+ Given I have a file "mini_test_spec.rb" containing:
32
+ """
33
+ require 'minitest/spec'
34
+ require 'minitest/autorun'
35
+ require 'temporaries'
36
+
37
+ module Mod
38
+ X = 2
39
+ end
40
+
41
+ describe Mod do
42
+ use_constant_value Mod, :X, 5
43
+
44
+ it "should have x set to 5 in each test" do
45
+ Mod::X.must_equal(5)
46
+ end
47
+ end
48
+ """
49
+ When I run "ruby mini_test_spec.rb"
50
+ Then I should see "1 tests, 1 assertions, 0 failures, 0 errors"
data/lib/temporaries.rb CHANGED
@@ -9,6 +9,12 @@ if defined?($TEMPORARIES_TEST)
9
9
  # Testing this library. Don't install anything.
10
10
  elsif defined?(RSpec)
11
11
  Temporaries::Adapters::RSpec.install
12
+ elsif defined?(MiniTest::Unit::TestCase)
13
+ if RUBY_VERSION >= '1.9.3'
14
+ Temporaries::Adapters::MiniTest.install
15
+ else
16
+ Temporaries::Adapters::TestUnit.install(MiniTest::Unit)
17
+ end
12
18
  elsif defined?(Test::Unit)
13
- Temporaries::Adapters::TestUnit.install
19
+ Temporaries::Adapters::TestUnit.install(Test::Unit)
14
20
  end
@@ -1,6 +1,7 @@
1
1
  module Temporaries
2
2
  module Adapters
3
3
  autoload :Base, 'temporaries/adapters/base'
4
+ autoload :MiniTest, 'temporaries/adapters/mini_test'
4
5
  autoload :RSpec, 'temporaries/adapters/rspec'
5
6
  autoload :TestUnit, 'temporaries/adapters/test_unit'
6
7
  end
@@ -0,0 +1,29 @@
1
+ module Temporaries
2
+ module Adapters
3
+ class MiniTest < Base
4
+ # For ruby <= 1.9.2, MiniTest is actually adapted via the
5
+ # Test::Unit adapter.
6
+ def self.install
7
+ ::MiniTest::Unit::TestCase.class_eval do
8
+ extend Extension
9
+ include Values
10
+ include Directory
11
+ end
12
+ end
13
+
14
+ def before(&block)
15
+ context.add_setup_hook {|tc| tc.instance_eval(&block) }
16
+ end
17
+
18
+ def after(&block)
19
+ context.add_teardown_hook {|tc| tc.instance_eval(&block) }
20
+ end
21
+
22
+ module Extension
23
+ def temporaries_adapter
24
+ MiniTest.new(self)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,8 +1,10 @@
1
1
  module Temporaries
2
2
  module Adapters
3
3
  class TestUnit < Base
4
- def self.install
5
- Test::Unit::TestCase.class_eval do
4
+ # This is used for both Test::Unit <= 1.9 and MiniTest::Unit
5
+ # <= 1.9.2.
6
+ def self.install(mod)
7
+ mod::TestCase.class_eval do
6
8
  extend Extension
7
9
  include Values
8
10
  include Directory
@@ -50,7 +50,7 @@ module Temporaries
50
50
  module Values
51
51
  include Core
52
52
 
53
- UNDEFINED = RUBY_VERSION < '1.9' ? Object.new : BasicObject.new
53
+ UNDEFINED = Object.new
54
54
  class << UNDEFINED
55
55
  def inspect
56
56
  '<UNDEFINED>'
@@ -1,5 +1,5 @@
1
1
  module Temporaries
2
- VERSION = [0, 0, 3]
2
+ VERSION = [0, 1, 0]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require File.expand_path('../../spec_helper', File.dirname(__FILE__))
2
2
 
3
3
  describe Temporaries::Directory do
4
4
  before do
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require File.expand_path('../../spec_helper', File.dirname(__FILE__))
2
2
 
3
3
  describe Temporaries::Values do
4
4
  before do
metadata CHANGED
@@ -1,83 +1,76 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: temporaries
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - George Ogata
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-17 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-06-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: ritual
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- hash: 19
29
- segments:
30
- - 0
31
- - 3
32
- - 0
33
- version: 0.3.0
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.1
34
22
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
40
25
  none: false
41
- requirements:
42
- - - "="
43
- - !ruby/object:Gem::Version
44
- hash: 27
45
- segments:
46
- - 2
47
- - 5
48
- - 0
49
- version: 2.5.0
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.10.0
50
38
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: cucumber
54
39
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
56
41
  none: false
57
- requirements:
58
- - - "="
59
- - !ruby/object:Gem::Version
60
- hash: 51
61
- segments:
62
- - 0
63
- - 10
64
- - 2
65
- version: 0.10.2
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.10.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: cucumber
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.0
66
54
  type: :development
67
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.0
68
62
  description:
69
- email:
63
+ email:
70
64
  - george.ogata@gmail.com
71
65
  executables: []
72
-
73
66
  extensions: []
74
-
75
- extra_rdoc_files:
67
+ extra_rdoc_files:
76
68
  - CHANGELOG
77
69
  - LICENSE
78
70
  - README.markdown
79
- files:
71
+ files:
80
72
  - lib/temporaries/adapters/base.rb
73
+ - lib/temporaries/adapters/mini_test.rb
81
74
  - lib/temporaries/adapters/rspec.rb
82
75
  - lib/temporaries/adapters/test_unit.rb
83
76
  - lib/temporaries/adapters.rb
@@ -94,48 +87,48 @@ files:
94
87
  - spec/support/test_context.rb
95
88
  - spec/unit/temporaries/directory_spec.rb
96
89
  - spec/unit/temporaries/values_spec.rb
90
+ - features/mini_test_integration.feature
97
91
  - features/rspec_integration.feature
98
92
  - features/test_unit_integration.feature
99
93
  - features/step_definitions/command_steps.rb
100
94
  - features/support/env.rb
101
95
  homepage: http://github.com/oggy/temporaries
102
- licenses: []
103
-
96
+ licenses:
97
+ - MIT
104
98
  post_install_message:
105
99
  rdoc_options: []
106
-
107
- require_paths:
100
+ require_paths:
108
101
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
102
+ required_ruby_version: !ruby/object:Gem::Requirement
110
103
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ segments:
116
109
  - 0
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
110
+ hash: 2522047447244818612
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
112
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ segments:
125
118
  - 0
126
- version: "0"
119
+ hash: 2522047447244818612
127
120
  requirements: []
128
-
129
121
  rubyforge_project:
130
- rubygems_version: 1.8.10
122
+ rubygems_version: 1.8.24
131
123
  signing_key:
132
124
  specification_version: 3
133
125
  summary: Set temporary values declaratively.
134
- test_files:
126
+ test_files:
135
127
  - spec/spec_helper.rb
136
128
  - spec/support/test_context.rb
137
129
  - spec/unit/temporaries/directory_spec.rb
138
130
  - spec/unit/temporaries/values_spec.rb
131
+ - features/mini_test_integration.feature
139
132
  - features/rspec_integration.feature
140
133
  - features/test_unit_integration.feature
141
134
  - features/step_definitions/command_steps.rb