aktion_test 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/aktion_test/module/factory_girl.rb +11 -0
- data/lib/aktion_test/module/faker.rb +12 -0
- data/lib/aktion_test/module/timecop.rb +11 -0
- data/lib/aktion_test/spec_helper.rb +32 -9
- data/lib/aktion_test/version.rb +1 -1
- data/lib/aktion_test.rb +3 -0
- data/spec/aktion_test/spec_helper_spec.rb +44 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/support/autoload.rb +3 -0
- data/spec/support/test_module.rb +4 -0
- metadata +11 -2
data/CHANGELOG.md
CHANGED
@@ -4,27 +4,40 @@ module AktionTest
|
|
4
4
|
class SpecHelper
|
5
5
|
include Singleton
|
6
6
|
|
7
|
-
|
7
|
+
attr_reader :modules, :options, :scope
|
8
8
|
|
9
9
|
class << self
|
10
|
-
|
11
|
-
|
10
|
+
def load(*names, &block)
|
11
|
+
options = names.extract_options!
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
if names.any?
|
14
|
+
load_constants(names)
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
unless options.nil? || options.empty?
|
17
|
+
names.each do |name|
|
18
|
+
instance.options.merge! name => options
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
instance.modules.each do |mod|
|
23
|
+
include mod
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
|
-
|
27
|
+
self.instance_eval(&block) if block_given?
|
28
|
+
end
|
29
|
+
|
30
|
+
def within(scope, &block)
|
31
|
+
instance.scope << scope.to_s
|
32
|
+
yield
|
33
|
+
instance.scope.pop
|
21
34
|
end
|
22
35
|
|
23
36
|
private
|
24
37
|
|
25
38
|
def load_constants(modules)
|
26
39
|
modules.each do |mod|
|
27
|
-
module_name = "
|
40
|
+
module_name = "#{instance.scope.join('::')}::#{mod}"
|
28
41
|
begin
|
29
42
|
module_const = module_name.constantize
|
30
43
|
instance.modules << module_const
|
@@ -36,7 +49,17 @@ module AktionTest
|
|
36
49
|
end
|
37
50
|
|
38
51
|
def initialize
|
52
|
+
reset
|
53
|
+
end
|
54
|
+
|
55
|
+
def reset
|
39
56
|
@modules = []
|
57
|
+
@options = {}
|
58
|
+
@scope = %w(AktionTest Module)
|
59
|
+
end
|
60
|
+
|
61
|
+
def loaded?(name)
|
62
|
+
eval "defined? AktionTest::Module::#{name}"
|
40
63
|
end
|
41
64
|
end
|
42
65
|
end
|
data/lib/aktion_test/version.rb
CHANGED
data/lib/aktion_test.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AktionTest::SpecHelper do
|
4
|
+
subject { described_class.instance }
|
5
|
+
before { subject.reset }
|
6
|
+
|
7
|
+
its(:modules) { should be_a Array }
|
8
|
+
its(:options) { should be_a Hash }
|
9
|
+
its(:scope) { should be_a Array }
|
10
|
+
its(:scope) { should == %w(AktionTest Module) }
|
11
|
+
|
12
|
+
describe '#within' do
|
13
|
+
it 'allows a scope to be added' do
|
14
|
+
described_class.within :Test do
|
15
|
+
subject.scope.should == %w(AktionTest Module Test)
|
16
|
+
end
|
17
|
+
subject.scope.should == %w(AktionTest Module)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#load' do
|
22
|
+
before do
|
23
|
+
subject.scope.pop(2)
|
24
|
+
subject.scope << 'Baz'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'initializes the module' do
|
28
|
+
Baz.autoload?(:Bar).should == 'support/test_module'
|
29
|
+
described_class.load :Bar
|
30
|
+
Baz.autoload?(:Bar).should be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'adds the module to a set of loaded modules' do
|
34
|
+
described_class.load :Bar
|
35
|
+
subject.modules.should == [Baz::Bar]
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'saves options for the module loaded' do
|
39
|
+
described_class.load :Bar, :test => :option
|
40
|
+
subject.options.should have_key(:Bar)
|
41
|
+
subject.options[:Bar].should == {:test => :option}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aktion_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -116,18 +116,24 @@ files:
|
|
116
116
|
- lib/aktion_test/matchers/file_system/file_contains.rb
|
117
117
|
- lib/aktion_test/matchers/file_system/file_existance.rb
|
118
118
|
- lib/aktion_test/module/aktion_test.rb
|
119
|
+
- lib/aktion_test/module/factory_girl.rb
|
120
|
+
- lib/aktion_test/module/faker.rb
|
119
121
|
- lib/aktion_test/module/rspec.rb
|
120
122
|
- lib/aktion_test/module/simplecov.rb
|
123
|
+
- lib/aktion_test/module/timecop.rb
|
121
124
|
- lib/aktion_test/spec_helper.rb
|
122
125
|
- lib/aktion_test/support/class_builder.rb
|
123
126
|
- lib/aktion_test/version.rb
|
124
127
|
- spec/aktion_test/class_builder_spec.rb
|
128
|
+
- spec/aktion_test/spec_helper_spec.rb
|
125
129
|
- spec/matchers/base_spec.rb
|
126
130
|
- spec/matchers/directory_contains_spec.rb
|
127
131
|
- spec/matchers/directory_existance_spec.rb
|
128
132
|
- spec/matchers/file_contains_spec.rb
|
129
133
|
- spec/matchers/file_existance_spec.rb
|
130
134
|
- spec/spec_helper.rb
|
135
|
+
- spec/support/autoload.rb
|
136
|
+
- spec/support/test_module.rb
|
131
137
|
homepage: http://aktionlab.com
|
132
138
|
licenses:
|
133
139
|
- MIT
|
@@ -149,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
155
|
version: '0'
|
150
156
|
segments:
|
151
157
|
- 0
|
152
|
-
hash:
|
158
|
+
hash: 847893389
|
153
159
|
requirements: []
|
154
160
|
rubyforge_project:
|
155
161
|
rubygems_version: 1.8.24
|
@@ -158,9 +164,12 @@ specification_version: 3
|
|
158
164
|
summary: Gems, libs, helpers for test suites.
|
159
165
|
test_files:
|
160
166
|
- spec/aktion_test/class_builder_spec.rb
|
167
|
+
- spec/aktion_test/spec_helper_spec.rb
|
161
168
|
- spec/matchers/base_spec.rb
|
162
169
|
- spec/matchers/directory_contains_spec.rb
|
163
170
|
- spec/matchers/directory_existance_spec.rb
|
164
171
|
- spec/matchers/file_contains_spec.rb
|
165
172
|
- spec/matchers/file_existance_spec.rb
|
166
173
|
- spec/spec_helper.rb
|
174
|
+
- spec/support/autoload.rb
|
175
|
+
- spec/support/test_module.rb
|