aktion_test 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/aktion_test.gemspec +1 -1
- data/lib/aktion_test/module/factory_girl.rb +4 -0
- data/lib/aktion_test/spec_helper.rb +36 -30
- data/lib/aktion_test/version.rb +1 -1
- data/spec/aktion_test/spec_helper_spec.rb +6 -14
- metadata +4 -7
data/CHANGELOG.md
CHANGED
data/aktion_test.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
# even the simplest gem.
|
24
24
|
gem.add_dependency 'rspec', '~> 2.12.0'
|
25
25
|
gem.add_dependency 'faker', '~> 1.1.2'
|
26
|
-
gem.add_dependency 'factory_girl', '~> 4.
|
26
|
+
gem.add_dependency 'factory_girl', '~> 4.2.0'
|
27
27
|
gem.add_dependency 'simplecov', '~> 0.7.1'
|
28
28
|
gem.add_dependency 'timecop', '~> 0.5.3'
|
29
29
|
end
|
@@ -8,43 +8,20 @@ module AktionTest
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def load(*names, &block)
|
11
|
-
options = names.extract_options!
|
12
|
-
|
13
11
|
if names.any?
|
14
|
-
|
15
|
-
|
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
|
12
|
+
instance.load(*names)
|
25
13
|
end
|
26
14
|
|
27
|
-
|
28
|
-
end
|
15
|
+
instance.instance_eval(&block) if block_given?
|
29
16
|
|
30
|
-
|
31
|
-
instance.scope << scope.to_s
|
32
|
-
yield
|
33
|
-
instance.scope.pop
|
17
|
+
instance.modules.each{|mod| include mod}
|
34
18
|
end
|
35
19
|
|
36
|
-
|
20
|
+
def add_module(name, options={})
|
21
|
+
end
|
37
22
|
|
38
|
-
def
|
39
|
-
|
40
|
-
module_name = "#{instance.scope.join('::')}::#{mod}"
|
41
|
-
begin
|
42
|
-
module_const = module_name.constantize
|
43
|
-
instance.modules << module_const
|
44
|
-
rescue NameError
|
45
|
-
puts "Unknown module #{mod}."
|
46
|
-
end
|
47
|
-
end
|
23
|
+
def add_modules(*names)
|
24
|
+
names.each{|name| add_module(name)}
|
48
25
|
end
|
49
26
|
end
|
50
27
|
|
@@ -61,5 +38,34 @@ module AktionTest
|
|
61
38
|
def loaded?(name)
|
62
39
|
eval "defined? AktionTest::Module::#{name}"
|
63
40
|
end
|
41
|
+
|
42
|
+
def load(*names)
|
43
|
+
options = names.extract_options!
|
44
|
+
|
45
|
+
names.each do |name|
|
46
|
+
unless options.nil? or options.empty?
|
47
|
+
self.options.merge! name => options
|
48
|
+
end
|
49
|
+
load_constant(name)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def within(scope, &block)
|
54
|
+
self.scope << scope.to_s
|
55
|
+
yield
|
56
|
+
self.scope.pop
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def load_constant(name)
|
62
|
+
name = "#{self.scope.join('::')}::#{name}"
|
63
|
+
begin
|
64
|
+
const = name.constantize
|
65
|
+
self.modules << const
|
66
|
+
rescue NameError
|
67
|
+
puts "Unknown module #{name}."
|
68
|
+
end
|
69
|
+
end
|
64
70
|
end
|
65
71
|
end
|
data/lib/aktion_test/version.rb
CHANGED
@@ -11,7 +11,7 @@ describe AktionTest::SpecHelper do
|
|
11
11
|
|
12
12
|
describe '#within' do
|
13
13
|
it 'allows a scope to be added' do
|
14
|
-
|
14
|
+
subject.within :Test do
|
15
15
|
subject.scope.should == %w(AktionTest Module Test)
|
16
16
|
end
|
17
17
|
subject.scope.should == %w(AktionTest Module)
|
@@ -19,24 +19,16 @@ describe AktionTest::SpecHelper do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#load' do
|
22
|
-
|
22
|
+
it 'initializes the module, adds it to a set of loaded modules, and saves any options' do
|
23
23
|
subject.scope.pop(2)
|
24
24
|
subject.scope << 'Baz'
|
25
|
-
end
|
26
25
|
|
27
|
-
|
28
|
-
Baz.autoload?(:Bar).should == 'support/test_module'
|
29
|
-
described_class.load :Bar
|
30
|
-
Baz.autoload?(:Bar).should be_nil
|
31
|
-
end
|
26
|
+
Baz.autoload?(:Bar).should_not be_nil
|
32
27
|
|
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
28
|
described_class.load :Bar, :test => :option
|
29
|
+
|
30
|
+
subject.modules.should == [Baz::Bar]
|
31
|
+
Baz.autoload?(:Bar).should be_nil
|
40
32
|
subject.options.should have_key(:Bar)
|
41
33
|
subject.options[:Bar].should == {:test => :option}
|
42
34
|
end
|
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 4.
|
53
|
+
version: 4.2.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 4.
|
61
|
+
version: 4.2.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: simplecov
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,9 +153,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- - ! '>='
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '0'
|
156
|
-
segments:
|
157
|
-
- 0
|
158
|
-
hash: 847893389
|
159
156
|
requirements: []
|
160
157
|
rubyforge_project:
|
161
158
|
rubygems_version: 1.8.24
|