rspec-command_option 0.1.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +43 -2
- data/lib/rspec/command_option/version.rb +1 -1
- data/spec/rspec/command_option_spec.rb +56 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7da8add829f69ca8e08944cb3db06d4146437ba
|
4
|
+
data.tar.gz: 909337476b8c1ef5d321108e4644dd1e42925fda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 637446deff699a0b99b8b85eacec3915d528c45d4a621c972a35afa6cc71b824decabcab2b497ce7a53979eb242bb655aa198c18c988625edb9090e349012e63
|
7
|
+
data.tar.gz: 3d02cdb8b3011510ff25fa40bd09ab76a162c1b110b0969601f2e9c50af85e6081624be8b9a7ef95b975c534823bf5e905b5a7860cbc0d7c6e999b0d69b6b56a
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Rspec::CommandOption
|
2
2
|
|
3
|
-
|
3
|
+
It is option command builder of 'rspec' for RSpec::Core::RakeTask#rspec_opts
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,48 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
### The simplest examples
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'rspec/command_option'
|
27
|
+
|
28
|
+
option_example1 = RSpec::CommandOption.new do |opt|
|
29
|
+
opt.dry_run = true
|
30
|
+
opt.color = true
|
31
|
+
opt.tag = "~speed:slow"
|
32
|
+
end
|
33
|
+
|
34
|
+
puts option_example1.build #=> '--dry-run --color --tag=\~speed:slow'
|
35
|
+
```
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'rspec/command_option'
|
39
|
+
|
40
|
+
option_example2 = RSpec::CommandOption.new
|
41
|
+
option_example2.dry_run = true
|
42
|
+
option_example2.format = 'documentation'
|
43
|
+
|
44
|
+
puts option_example2.build #=> '--dry-run --format=documentation'
|
45
|
+
```
|
46
|
+
|
47
|
+
### With RSpec::Core::RakeTask
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
require 'rspec/core/rake_task'
|
51
|
+
require 'rspec/command_option'
|
52
|
+
|
53
|
+
rspec_opt = RSpec::CommandOption.new do |opt|
|
54
|
+
opt.dry_run = true
|
55
|
+
opt.color = true
|
56
|
+
opt.tag = "~speed:slow"
|
57
|
+
end
|
58
|
+
|
59
|
+
# If you execute this rake command, will execute 'rspec' command with '--dry-run --color --tag=\~speed:slow'
|
60
|
+
desc "Run examples"
|
61
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
62
|
+
t.rspec_opts = rspec_opts
|
63
|
+
end
|
64
|
+
```
|
24
65
|
|
25
66
|
## Contributing
|
26
67
|
|
@@ -1,7 +1,61 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RSpec::CommandOption do
|
4
4
|
it 'has a version number' do
|
5
|
-
expect(
|
5
|
+
expect(RSpec::CommandOption::VERSION).not_to be nil
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#build' do
|
9
|
+
context 'without all configuration' do
|
10
|
+
subject(:command) { RSpec::CommandOption.new.build }
|
11
|
+
|
12
|
+
it { is_expected.to eq '' }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with no arguments option' do
|
16
|
+
subject(:command) {
|
17
|
+
RSpec::CommandOption.new {|opt|
|
18
|
+
opt.color = true
|
19
|
+
}.build
|
20
|
+
}
|
21
|
+
|
22
|
+
it { is_expected.to eq '--color' }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with argument option' do
|
26
|
+
subject(:command) {
|
27
|
+
RSpec::CommandOption.new {|opt|
|
28
|
+
opt.format = 'documentation'
|
29
|
+
}.build
|
30
|
+
}
|
31
|
+
|
32
|
+
it { is_expected.to eq '--format=documentation' }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with multiple valid options' do
|
36
|
+
subject(:command) {
|
37
|
+
RSpec::CommandOption.new {|opt|
|
38
|
+
opt.color = true
|
39
|
+
opt.dry_run = true
|
40
|
+
opt.tag = "skip"
|
41
|
+
}.build
|
42
|
+
}
|
43
|
+
|
44
|
+
it {
|
45
|
+
is_expected.to include '--color'
|
46
|
+
is_expected.to include '--dry-run'
|
47
|
+
is_expected.to include 'tag=skip'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with invalid options' do
|
52
|
+
subject(:command) {
|
53
|
+
RSpec::CommandOption.new {|opt|
|
54
|
+
opt.invalid_option = 'invalid_argument'
|
55
|
+
}.build
|
56
|
+
}
|
57
|
+
|
58
|
+
it { expect{command}.to raise_error NoMethodError }
|
59
|
+
end
|
6
60
|
end
|
7
61
|
end
|