rspec-rake 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +4 -0
- data/lib/rspec/rake.rb +2 -4
- data/lib/rspec/rake/example_group.rb +3 -2
- data/lib/rspec/rake/version.rb +1 -1
- data/spec/lib/example_group_spec.rb +55 -0
- data/spec/tasks/rake_task_spec.rb +2 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efc103eb231e30250258d2c08c46e78f4f3e8702
|
4
|
+
data.tar.gz: faf47c00e50764358ee8b9fa5ef3b72d413a33ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c893c28ee53f85a702119e9c34a289494ec58b68a2976039358b3d4203a730df78dc02d99dc5aade6d92204725050209650a1e8ace0a4e0ef802e29aa0ca5988
|
7
|
+
data.tar.gz: def6b7bd9ac79ed2ed26cd7c020b221946034203aca9a995106e882d3ca51d431912cb001ee5bf8386731b40f5e0cac852c4cdd045d0734e621163e47b513d1c
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# RSpec Rake Support
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/stas/rspec-rake.png?branch=master)](https://travis-ci.org/stas/rspec-rake)
|
4
|
+
|
3
5
|
You can test you Rake files like you test your Rails app.
|
4
6
|
|
5
7
|
This gem adds an example group and configures RSpec so we can write tests for our Rake tasks easily.
|
@@ -53,6 +55,8 @@ describe 'task:subtask', :rakefile => 'my_task', :tasks_path => 'lib/capistrano/
|
|
53
55
|
end
|
54
56
|
```
|
55
57
|
|
58
|
+
Check [rails-dummy](https://github.com/Courseware/rails-dummy) tests for more examples.
|
59
|
+
|
56
60
|
### Limitations
|
57
61
|
|
58
62
|
Due to how `Rake::Application#rake_require` works, only files with `.rake` extension can be tests.
|
data/lib/rspec/rake.rb
CHANGED
@@ -3,8 +3,6 @@ require 'rspec/rake/example_group'
|
|
3
3
|
|
4
4
|
RSpec.configure do |config|
|
5
5
|
config.include RSpec::Rake::ExampleGroup,
|
6
|
-
:
|
7
|
-
:
|
8
|
-
metadata[:type].nil? && %r{spec/tasks}.match(example_group[:file_path])
|
9
|
-
}
|
6
|
+
type: :task,
|
7
|
+
file_path: /\bspec\/tasks\//
|
10
8
|
end
|
@@ -8,7 +8,7 @@ module RSpec::Rake
|
|
8
8
|
base.instance_eval do
|
9
9
|
|
10
10
|
metadata[:type] = :task
|
11
|
-
metadata[:tasks_path] ||= File.join('
|
11
|
+
metadata[:tasks_path] ||= File.join('lib', 'tasks')
|
12
12
|
metadata[:rakefile] ||= nil
|
13
13
|
|
14
14
|
subject(:task) { Rake.application[self.class.top_level_description] }
|
@@ -18,12 +18,13 @@ module RSpec::Rake
|
|
18
18
|
task_name = self.class.top_level_description
|
19
19
|
|
20
20
|
rakefile = metadata[:rakefile] || task_name.split(':').first
|
21
|
-
task_path = File.join(metadata[:tasks_path], rakefile)
|
21
|
+
task_path = File.join('..', metadata[:tasks_path], rakefile)
|
22
22
|
|
23
23
|
Rake.application = Rake::Application.new
|
24
24
|
# We are sending an empty list of loaded files
|
25
25
|
# in order to force loading of existing files
|
26
26
|
Rake.application.rake_require(task_path, $LOAD_PATH, [])
|
27
|
+
Rake::Task.define_task(:environment)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
data/lib/rspec/rake/version.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RSpec::Rake::ExampleGroup do
|
4
|
+
|
5
|
+
subject(:example_group) do
|
6
|
+
RSpec::Core::ExampleGroup.describe do
|
7
|
+
include RSpec::Rake::ExampleGroup
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'loads metadata' do
|
12
|
+
expect(example_group.metadata[:type]).to eq(:task)
|
13
|
+
expect(example_group.metadata[:tasks_path]).to eq('lib/tasks')
|
14
|
+
expect(example_group.metadata[:rakefile]).to be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
context '#before(:each) with no rakefile metadata' do
|
18
|
+
let(:task_name) { 'some:task' }
|
19
|
+
|
20
|
+
before do
|
21
|
+
example_group.class.stub(:top_level_description => task_name)
|
22
|
+
example_group.class.stub(:metadata => example_group.metadata)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'creates a new rake application and loads the task rake file' do
|
26
|
+
fake_rake_app = Rake::Application.new
|
27
|
+
expect(fake_rake_app).to receive(:rake_require).with(
|
28
|
+
'../lib/tasks/some', $LOAD_PATH, [])
|
29
|
+
expect(Rake::Application).to receive(:new).and_return(fake_rake_app)
|
30
|
+
|
31
|
+
example_group.hooks.send(
|
32
|
+
:run_example_hooks_for, example_group, :before, :each)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context '#before(:each) with rakefile metadata' do
|
37
|
+
let(:metadata) { example_group.metadata.merge(:rakefile => 'another') }
|
38
|
+
|
39
|
+
before do
|
40
|
+
example_group.class.stub(:top_level_description)
|
41
|
+
example_group.class.stub(:metadata => metadata)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'creates a new rake application and loads the task rake file' do
|
45
|
+
fake_rake_app = Rake::Application.new
|
46
|
+
expect(fake_rake_app).to receive(:rake_require).with(
|
47
|
+
'../lib/tasks/another', $LOAD_PATH, [])
|
48
|
+
expect(Rake::Application).to receive(:new).and_return(fake_rake_app)
|
49
|
+
|
50
|
+
example_group.hooks.send(
|
51
|
+
:run_example_hooks_for, example_group, :before, :each)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'default', :rakefile => 'example', :tasks_path => '
|
3
|
+
describe 'default', :rakefile => 'example', :tasks_path => 'spec/fixtures' do
|
4
4
|
it 'task lists another task as the prerequisite' do
|
5
5
|
expect(task.prerequisites).to include('example:subexample:task')
|
6
6
|
end
|
@@ -11,7 +11,7 @@ describe 'default', :rakefile => 'example', :tasks_path => './fixtures' do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
describe 'example:subexample:task', :tasks_path => 'fixtures' do
|
14
|
+
describe 'example:subexample:task', :tasks_path => 'spec/fixtures' do
|
15
15
|
it 'has no prerequisites' do
|
16
16
|
expect(task.prerequisites).to be_empty
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas SUȘCOV
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/rspec/rake/version.rb
|
85
85
|
- rspec-rake.gemspec
|
86
86
|
- spec/fixtures/example.rake
|
87
|
+
- spec/lib/example_group_spec.rb
|
87
88
|
- spec/spec_helper.rb
|
88
89
|
- spec/tasks/rake_task_spec.rb
|
89
90
|
homepage: https://github.com/stas/rspec-rake
|
@@ -106,11 +107,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
109
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.6.8
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
113
|
summary: Test Rake tasks with RSpec.
|
113
114
|
test_files:
|
114
115
|
- spec/fixtures/example.rake
|
116
|
+
- spec/lib/example_group_spec.rb
|
115
117
|
- spec/spec_helper.rb
|
116
118
|
- spec/tasks/rake_task_spec.rb
|