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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29f8a3df9f2e11e9c94a50c90347d07c6c46e979
4
- data.tar.gz: faffaf971395e351f8bb548fc314116f81290fb6
3
+ metadata.gz: f7da8add829f69ca8e08944cb3db06d4146437ba
4
+ data.tar.gz: 909337476b8c1ef5d321108e4644dd1e42925fda
5
5
  SHA512:
6
- metadata.gz: 9adeff6bf6dabc8807bb2e8a9c9c6e6b35988a8e8c011f152b03f11d8ef291537212071d08e259d73bfb737f6afd875d3ebcd6c7dbb1ef766ec97a98f188d3e8
7
- data.tar.gz: 70a8c2222591feab4f39205a01b115a39a8fb301cb5e03fe625872d299e26ece6da4ac84c6829f7a0d522460fdc8e897b9841cbb4194da5b8f7adcffde11e6cc
6
+ metadata.gz: 637446deff699a0b99b8b85eacec3915d528c45d4a621c972a35afa6cc71b824decabcab2b497ce7a53979eb242bb655aa198c18c988625edb9090e349012e63
7
+ data.tar.gz: 3d02cdb8b3011510ff25fa40bd09ab76a162c1b110b0969601f2e9c50af85e6081624be8b9a7ef95b975c534823bf5e905b5a7860cbc0d7c6e999b0d69b6b56a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rspec::CommandOption
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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,5 +1,5 @@
1
1
  module RSpec
2
2
  class CommandOption
3
- VERSION = "0.1.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -1,7 +1,61 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Rspec::CommandOption do
3
+ describe RSpec::CommandOption do
4
4
  it 'has a version number' do
5
- expect(Rspec::CommandOption::VERSION).not_to be nil
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-command_option
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyohei Shimada