rutabaga 0.0.4 → 0.1.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 +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +31 -4
- data/Gemfile +1 -1
- data/Gemfile_rspec_2_7 +5 -0
- data/Gemfile_turnip_1_1_0 +4 -0
- data/Gemfile_turnip_1_1_0_rspec_2 +6 -0
- data/README.md +35 -1
- data/examples/spec_helper.rb +5 -0
- data/examples/test3.feature +5 -0
- data/examples/test_spec.rb +49 -33
- data/lib/rutabaga/feature.rb +20 -8
- data/lib/rutabaga/version.rb +1 -1
- data/rutabaga.gemspec +1 -1
- data/spec/feature_spec.rb +11 -6
- data/spec/spec_helper.rb +5 -0
- metadata +19 -14
- data/lib/.DS_Store +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 130b492203c71821bb61671e00cbf3741c96c493
|
4
|
+
data.tar.gz: 41750f343f697fde7381a693778e9bce2ae6c75c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e209c2d40214542ce623ab37a50e4ce8ee36f52a393936259e9ffdc2597961ca2fc5311d5a20f11fd2493e8ea28f28e0498ebe23c9c42393a7d83d4ffc2fe379
|
7
|
+
data.tar.gz: c7c9da041dd28316b89d362f6e190839029eb70388d19c0847c05ee4ab7f90a9134fd54ea390bafd2b1f2d5809432d15eb8772cc33bdca3cae37d9c1793960d0
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,36 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.9.2
|
4
3
|
- 1.9.3
|
5
|
-
|
6
|
-
|
7
|
-
-
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.0
|
6
|
+
- jruby-19mode
|
7
|
+
|
8
|
+
gemfile:
|
9
|
+
- Gemfile
|
10
|
+
- Gemfile_turnip_1_1_0_rspec_2
|
11
|
+
- Gemfile_turnip_1_1_0
|
12
|
+
- Gemfile_rspec_2_7
|
13
|
+
|
14
|
+
# Run the full suite against ruby 2.0.0 only
|
15
|
+
matrix:
|
16
|
+
exclude:
|
17
|
+
- rvm: 1.9.3
|
18
|
+
gemfile: Gemfile_turnip_1_1_0_rspec_2
|
19
|
+
- rvm: 2.1.0
|
20
|
+
gemfile: Gemfile_turnip_1_1_0_rspec_2
|
21
|
+
- rvm: jruby-19mode
|
22
|
+
gemfile: Gemfile_turnip_1_1_0_rspec_2
|
23
|
+
- rvm: 1.9.3
|
24
|
+
gemfile: Gemfile_turnip_1_1_0
|
25
|
+
- rvm: 2.1.0
|
26
|
+
gemfile: Gemfile_turnip_1_1_0
|
27
|
+
- rvm: jruby-19mode
|
28
|
+
gemfile: Gemfile_turnip_1_1_0
|
29
|
+
- rvm: 1.9.3
|
30
|
+
gemfile: Gemfile_rspec_2_7
|
31
|
+
- rvm: 2.1.0
|
32
|
+
gemfile: Gemfile_rspec_2_7
|
33
|
+
- rvm: jruby-19mode
|
34
|
+
gemfile: Gemfile_rspec_2_7
|
8
35
|
|
9
36
|
script: bundle exec rspec spec
|
data/Gemfile
CHANGED
data/Gemfile_rspec_2_7
ADDED
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# Rutabaga
|
2
2
|
|
3
|
-
Turnip hacks to enable running turnips from inside spec files, rather than outside.
|
3
|
+
[Turnip](https://github.com/jnicklas/turnip) hacks to enable running turnips from inside spec files, rather than outside.
|
4
4
|
|
5
5
|
Rutabaga allows you to invert the control of feature files, so that features are called from your `_spec.rb` files rather than the other way around. Step definitions are then put into the `_spec.rb` files as well. The steps are then scoped to that particular test.
|
6
6
|
|
7
7
|
This means that it is simple to create tests that are described by a class (such as controller tests in rspec-rails).
|
8
8
|
|
9
|
+
[](https://travis-ci.org/simplybusiness/rutabaga)
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Install the gem
|
@@ -81,6 +83,38 @@ end
|
|
81
83
|
|
82
84
|
Will run `spec/features/test.feature`.
|
83
85
|
|
86
|
+
Second alternative, is specifying the feature file in the `feature` command:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
it "should run the feature" do
|
90
|
+
feature "spec/features/test.feature"
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
94
|
+
Will run `spec/features/test.feature`.
|
95
|
+
|
96
|
+
### Definining steps
|
97
|
+
|
98
|
+
Steps are defined in the same way as in Turnip, however, steps can be defined within the rspec context and are scoped to only be available there.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
describe "step will only be in this context" do
|
102
|
+
it "should run feature" do
|
103
|
+
feature
|
104
|
+
end
|
105
|
+
|
106
|
+
step "action :named" do |named| do
|
107
|
+
expect(named).to eq("a name")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "step 'action :named' is not available here" do
|
112
|
+
it "cannot run feature due to missing step" do
|
113
|
+
expect(feature).to raise_error
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
84
118
|
### Differences from Turnip
|
85
119
|
|
86
120
|
Other than these differences, Rutabaga is a tiny shim over Turnip and all features will work as expected.
|
data/examples/spec_helper.rb
CHANGED
data/examples/test_spec.rb
CHANGED
@@ -1,48 +1,64 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "test" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
it "should run feature" do
|
5
|
+
feature
|
6
|
+
end
|
7
|
+
|
8
|
+
step "that :first + :second is calculated" do |first, second|
|
9
|
+
@first = first
|
10
|
+
@second = second
|
11
|
+
end
|
12
|
+
|
13
|
+
step "my result is :result" do |result|
|
14
|
+
result.to_i.should == @first.to_i + @second.to_i
|
15
|
+
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "should find the feature file using the root (and monkey patching the result)" do
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
it "examples/test2.feature" do
|
20
|
+
feature
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
step "that :first + :second is calculated" do |first, second|
|
24
|
+
@first = first
|
25
|
+
@second = second
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
step "my result is :result" do |result|
|
29
|
+
result.to_i.should == @first.to_i + @second.to_i - 1
|
30
|
+
end
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "causes a failing test" do
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
it "examples/test2.feature" do
|
36
|
+
feature
|
37
|
+
end
|
38
|
+
|
39
|
+
step "that :first + :second is calculated" do |first, second|
|
40
|
+
@first = first
|
41
|
+
@second = second
|
42
|
+
end
|
43
|
+
|
44
|
+
step "my result is :result" do |result|
|
45
|
+
result.to_i.should == @first.to_i + @second.to_i
|
46
|
+
end
|
38
47
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "finds a feature file given as parameter to the 'feature' method" do
|
51
|
+
it "implements the named feature" do
|
52
|
+
feature "examples/test3.feature"
|
53
|
+
end
|
43
54
|
|
44
|
-
|
45
|
-
|
46
|
-
|
55
|
+
step "that :first * :second is calculated" do |first, second|
|
56
|
+
@first = first
|
57
|
+
@second = second
|
58
|
+
end
|
47
59
|
|
48
|
-
|
60
|
+
step "my result is :result" do |result|
|
61
|
+
result.to_i.should == @first.to_i * @second.to_i
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/lib/rutabaga/feature.rb
CHANGED
@@ -2,8 +2,7 @@ require 'turnip'
|
|
2
2
|
|
3
3
|
module Rutabaga
|
4
4
|
module Feature
|
5
|
-
def feature
|
6
|
-
feature_file = find_feature
|
5
|
+
def feature(feature_file = find_feature)
|
7
6
|
|
8
7
|
rspec_class = self.class
|
9
8
|
|
@@ -16,7 +15,7 @@ module Rutabaga
|
|
16
15
|
rspec_class.describe(feature.name, feature.metadata_hash) do
|
17
16
|
rspec_class.before do
|
18
17
|
# This is kind of a hack, but it will make RSpec throw way nicer exceptions
|
19
|
-
|
18
|
+
get_example.metadata[:file_path] = feature_file
|
20
19
|
|
21
20
|
feature.backgrounds.map(&:steps).flatten.each do |step|
|
22
21
|
run_step(feature_file, step)
|
@@ -36,13 +35,26 @@ module Rutabaga
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def find_feature
|
39
|
-
return
|
38
|
+
return get_example.description if File.exists?(get_example.description)
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
feature_file = caller(0).find do |call|
|
41
|
+
call =~ /_spec.rb:/
|
42
|
+
end.gsub(/_spec.rb:.*\Z/, '.feature')
|
43
43
|
return feature_file if File.exists?(feature_file)
|
44
44
|
|
45
|
-
raise "Feature file not found. Tried: #{
|
45
|
+
raise "Feature file not found. Tried: #{get_example.description} and #{feature_file}"
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# For compatibility with rspec 2 and rspec 3. RSpec.current_example was added late in
|
51
|
+
# the rspec 2 cycle.
|
52
|
+
def get_example
|
53
|
+
begin
|
54
|
+
@example ||= RSpec.current_example
|
55
|
+
rescue NameError => e
|
56
|
+
@example ||= example
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
48
60
|
end
|
@@ -51,4 +63,4 @@ end
|
|
51
63
|
c.include Rutabaga::Feature
|
52
64
|
# Blow away turnip's pattern, and focus just on features directory
|
53
65
|
c.pattern.gsub!(",**/*.feature", ",features/**/*.feature")
|
54
|
-
end
|
66
|
+
end
|
data/lib/rutabaga/version.rb
CHANGED
data/rutabaga.gemspec
CHANGED
data/spec/feature_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'integration', :type => :integration do
|
4
4
|
before do
|
5
|
-
@result = %x(rspec -r rutabaga -
|
5
|
+
@result = %x(rspec -r rutabaga -fd examples/*_spec.rb)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "shows the correct description" do
|
@@ -12,20 +12,25 @@ describe 'integration', :type => :integration do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should not show any pending steps" do
|
15
|
-
|
16
|
-
|
15
|
+
@result.should_not include('PENDING')
|
16
|
+
@result.should_not include('No such step')
|
17
17
|
end
|
18
18
|
|
19
19
|
it "prints out failures and successes" do
|
20
|
-
@result.should include('
|
20
|
+
@result.should include('8 examples, 1 failure')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should find features relative to the root" do
|
24
|
-
|
24
|
+
@result.should_not include('Feature file not found')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "finds the .feature file given as parameter to the 'feature' method" do
|
28
|
+
@result.should include('that 2 * 4 is calculated')
|
29
|
+
@result.should include('my result is 8')
|
25
30
|
end
|
26
31
|
|
27
32
|
it "should scope steps to describe blocks" do
|
28
|
-
|
33
|
+
@result.should_not include('Turnip::Ambiguous')
|
29
34
|
end
|
30
35
|
|
31
36
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,32 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutabaga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Lukas Oberhuber
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: turnip
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.1.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.1.0
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
30
33
|
description: Allows using feature from within RSpec and is built on top of Turnip
|
31
34
|
email:
|
32
35
|
- lukas.oberhuber@simplybusiness.co.uk
|
@@ -37,14 +40,17 @@ files:
|
|
37
40
|
- .gitignore
|
38
41
|
- .travis.yml
|
39
42
|
- Gemfile
|
43
|
+
- Gemfile_rspec_2_7
|
44
|
+
- Gemfile_turnip_1_1_0
|
45
|
+
- Gemfile_turnip_1_1_0_rspec_2
|
40
46
|
- LICENSE
|
41
47
|
- README.md
|
42
48
|
- Rakefile
|
43
49
|
- examples/spec_helper.rb
|
44
50
|
- examples/test.feature
|
45
51
|
- examples/test2.feature
|
52
|
+
- examples/test3.feature
|
46
53
|
- examples/test_spec.rb
|
47
|
-
- lib/.DS_Store
|
48
54
|
- lib/rutabaga.rb
|
49
55
|
- lib/rutabaga/feature.rb
|
50
56
|
- lib/rutabaga/version.rb
|
@@ -54,27 +60,26 @@ files:
|
|
54
60
|
homepage: https://github.com/simplybusiness/rutabaga
|
55
61
|
licenses:
|
56
62
|
- MIT
|
63
|
+
metadata: {}
|
57
64
|
post_install_message:
|
58
65
|
rdoc_options: []
|
59
66
|
require_paths:
|
60
67
|
- lib
|
61
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
69
|
requirements:
|
64
|
-
- -
|
70
|
+
- - '>='
|
65
71
|
- !ruby/object:Gem::Version
|
66
72
|
version: '0'
|
67
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
74
|
requirements:
|
70
|
-
- -
|
75
|
+
- - '>='
|
71
76
|
- !ruby/object:Gem::Version
|
72
77
|
version: '0'
|
73
78
|
requirements: []
|
74
79
|
rubyforge_project:
|
75
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.0.14
|
76
81
|
signing_key:
|
77
|
-
specification_version:
|
82
|
+
specification_version: 4
|
78
83
|
summary: Calling Turnip feature files from RSpec, which allows encapsulating a feature
|
79
84
|
inside a describe block
|
80
85
|
test_files:
|
data/lib/.DS_Store
DELETED
Binary file
|