spinach 0.1.0 → 0.1.1
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.
- data/features/error_reporting.feature +3 -3
- data/features/rspec_compatibility.feature +9 -0
- data/features/steps/error_reporting.rb +11 -20
- data/features/steps/feature_name_guessing.rb +1 -1
- data/features/steps/rspec_compatibility.rb +33 -0
- data/features/support/env.rb +1 -0
- data/features/support/error_reporting.rb +16 -0
- data/features/support/spinach_runner.rb +25 -3
- data/lib/spinach.rb +2 -2
- data/lib/spinach/capybara.rb +4 -4
- data/lib/spinach/config.rb +14 -3
- data/lib/spinach/dsl.rb +2 -2
- data/lib/spinach/exceptions.rb +10 -3
- data/lib/spinach/{feature.rb → feature_steps.rb} +2 -6
- data/lib/spinach/runner.rb +9 -0
- data/lib/spinach/runner/scenario.rb +1 -1
- data/lib/spinach/suites.rb +2 -0
- data/lib/spinach/suites/minitest.rb +3 -0
- data/lib/spinach/suites/rspec.rb +1 -0
- data/lib/spinach/support.rb +22 -0
- data/lib/spinach/version.rb +1 -1
- data/spinach.gemspec +1 -0
- data/test/exceptions_test.rb +26 -0
- data/test/spinach/capybara_test.rb +3 -3
- data/test/spinach/config_test.rb +26 -6
- data/test/spinach/{feature_test.rb → feature_steps_test.rb} +5 -9
- data/test/spinach/suites/minitest_test.rb +15 -0
- data/test/spinach/support_test.rb +33 -0
- data/test/spinach_test.rb +1 -13
- metadata +55 -29
@@ -4,11 +4,11 @@ Feature: Error reporting
|
|
4
4
|
I want spinach to give me a comprehensive error reporting
|
5
5
|
|
6
6
|
Scenario: Error reporting without backtrace
|
7
|
-
Given I have a feature with some
|
7
|
+
Given I have a feature with some failures
|
8
8
|
When I run "spinach"
|
9
|
-
Then I should see the
|
9
|
+
Then I should see the failure count along with their messages
|
10
10
|
|
11
11
|
Scenario: Error reporting with backtrace
|
12
|
-
Given I have a feature with some
|
12
|
+
Given I have a feature with some failures
|
13
13
|
When I run "spinach --backtrace"
|
14
14
|
Then I should see the error count along with their messages and backtrace
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: RSpec compatibility
|
2
|
+
In order to use rspec in my step definitions
|
3
|
+
As a RSpec developer
|
4
|
+
I want spinach to detect my rspec failures as failures instead of errors
|
5
|
+
|
6
|
+
Scenario: An expectation fails
|
7
|
+
Given I have a feature with some failed expectations
|
8
|
+
When I run "spinach" with rspec
|
9
|
+
Then I should see the failure count along with their messages
|
@@ -1,17 +1,18 @@
|
|
1
1
|
Feature "Error reporting" do
|
2
2
|
include Integration::SpinachRunner
|
3
|
+
include Integration::ErrorReporting
|
3
4
|
|
4
|
-
Given "I have a feature with some
|
5
|
-
write_file('features/
|
6
|
-
'Feature: Feature with
|
5
|
+
Given "I have a feature with some failures" do
|
6
|
+
write_file('features/feature_with_failures.feature',
|
7
|
+
'Feature: Feature with failures
|
7
8
|
|
8
9
|
Scenario: This scenario will fail
|
9
10
|
Given true is false
|
10
11
|
Then remove all the files in my hard drive
|
11
12
|
')
|
12
13
|
|
13
|
-
write_file('features/steps/
|
14
|
-
'Feature "Feature with
|
14
|
+
write_file('features/steps/failure_feature.rb',
|
15
|
+
'Feature "Feature with failures" do
|
15
16
|
Given "true is false" do
|
16
17
|
true.must_equal false
|
17
18
|
end
|
@@ -23,30 +24,20 @@ Feature "Error reporting" do
|
|
23
24
|
end
|
24
25
|
|
25
26
|
When 'I run "spinach"' do
|
26
|
-
run_feature 'features/
|
27
|
+
run_feature 'features/feature_with_failures.feature'
|
27
28
|
end
|
28
29
|
|
29
30
|
When 'I run "spinach --backtrace"' do
|
30
|
-
run_feature 'features/
|
31
|
+
run_feature 'features/feature_with_failures.feature', append: '--backtrace'
|
31
32
|
end
|
32
33
|
|
33
|
-
Then 'I should see the
|
34
|
-
check_error_messages
|
34
|
+
Then 'I should see the failure count along with their messages' do
|
35
|
+
check_error_messages(1)
|
35
36
|
all_stderr.wont_match /gems.*minitest.*assert_equal/
|
36
37
|
end
|
37
38
|
|
38
39
|
Then 'I should see the error count along with their messages and backtrace' do
|
39
|
-
check_error_messages
|
40
|
+
check_error_messages(1)
|
40
41
|
check_backtrace
|
41
42
|
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def check_error_messages
|
45
|
-
all_stderr.must_match /Failures \(1\)/
|
46
|
-
end
|
47
|
-
|
48
|
-
def check_backtrace
|
49
|
-
all_stderr.must_match /Failures \(1\)/
|
50
|
-
all_stderr.must_match /gems.*minitest.*assert_equal/
|
51
|
-
end
|
52
43
|
end
|
@@ -13,7 +13,7 @@ Feature "Feature name guessing" do
|
|
13
13
|
|
14
14
|
And 'I write a class named "MyCoolFeature"' do
|
15
15
|
write_file('features/steps/my_cool_feature.rb',
|
16
|
-
'class MyCoolFeature < Spinach::
|
16
|
+
'class MyCoolFeature < Spinach::FeatureSteps
|
17
17
|
When "this is so meta" do
|
18
18
|
end
|
19
19
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature "RSpec compatibility" do
|
2
|
+
include Integration::SpinachRunner
|
3
|
+
include Integration::ErrorReporting
|
4
|
+
|
5
|
+
Given "I have a feature with some failed expectations" do
|
6
|
+
write_file('features/feature_with_failures.feature',
|
7
|
+
'Feature: Feature with failures
|
8
|
+
|
9
|
+
Scenario: This scenario will fail
|
10
|
+
Given true is false
|
11
|
+
Then remove all the files in my hard drive
|
12
|
+
')
|
13
|
+
|
14
|
+
write_file('features/steps/failure_feature.rb',
|
15
|
+
'Feature "Feature with failures" do
|
16
|
+
Given "true is false" do
|
17
|
+
true.should == false
|
18
|
+
end
|
19
|
+
|
20
|
+
Then "remove all the files in my hard drive" do
|
21
|
+
# joking!
|
22
|
+
end
|
23
|
+
end')
|
24
|
+
end
|
25
|
+
|
26
|
+
When "I run \"spinach\" with rspec" do
|
27
|
+
run_feature 'features/feature_with_failures.feature', suite: :rspec
|
28
|
+
end
|
29
|
+
|
30
|
+
Then "I should see the failure count along with their messages" do
|
31
|
+
check_error_messages(1)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'minitest/spec'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'aruba/api'
|
2
|
+
|
3
|
+
module Integration
|
4
|
+
module ErrorReporting
|
5
|
+
include Aruba::Api
|
6
|
+
|
7
|
+
def check_error_messages(n = 1)
|
8
|
+
all_stderr.must_match /Failures \(1\)/
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_backtrace(n = 1)
|
12
|
+
all_stderr.must_match /Failures \(1\)/
|
13
|
+
all_stderr.must_match /gems.*(minitest|rspec).*assert_equal/
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -4,9 +4,31 @@ module Integration
|
|
4
4
|
module SpinachRunner
|
5
5
|
include Aruba::Api
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def self.included(base)
|
8
|
+
base.class_eval do
|
9
|
+
before do
|
10
|
+
in_current_dir do
|
11
|
+
FileUtils.rmdir('features')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_feature(command, options={})
|
18
|
+
options[:suite] ||= :minitest
|
19
|
+
use_minitest if options[:suite] == :minitest
|
20
|
+
use_rspec if options[:suite] == :rspec
|
21
|
+
run "../../bin/spinach #{command} #{options[:append]}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def use_minitest
|
25
|
+
write_file('features/support/minitest.rb',
|
26
|
+
"require 'minitest/spec'")
|
27
|
+
end
|
28
|
+
|
29
|
+
def use_rspec
|
30
|
+
write_file('features/support/minitest.rb',
|
31
|
+
"require 'rspec'")
|
10
32
|
end
|
11
33
|
end
|
12
34
|
end
|
data/lib/spinach.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'spinach/exceptions'
|
|
5
5
|
require_relative 'spinach/runner'
|
6
6
|
require_relative 'spinach/parser'
|
7
7
|
require_relative 'spinach/dsl'
|
8
|
-
require_relative 'spinach/
|
8
|
+
require_relative 'spinach/feature_steps'
|
9
9
|
require_relative 'spinach/reporter'
|
10
10
|
require_relative 'spinach/cli'
|
11
11
|
|
@@ -51,6 +51,6 @@ module Spinach
|
|
51
51
|
@@features.detect do |feature|
|
52
52
|
feature.feature_name.to_s == name.to_s ||
|
53
53
|
feature.name == klass
|
54
|
-
end || raise(Spinach::
|
54
|
+
end || raise(Spinach::FeatureStepsNotFoundException, [klass, name])
|
55
55
|
end
|
56
56
|
end
|
data/lib/spinach/capybara.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'capybara'
|
2
2
|
require 'capybara/dsl'
|
3
|
-
require_relative '
|
3
|
+
require_relative 'feature_steps'
|
4
4
|
|
5
5
|
module Spinach
|
6
|
-
class
|
6
|
+
class FeatureSteps
|
7
7
|
# Spinach's capybara module makes Capybara DSL available in all features.
|
8
8
|
#
|
9
9
|
# @example
|
10
10
|
# require 'spinach/capybara'
|
11
|
-
# class CapybaraFeature < Spinach::
|
11
|
+
# class CapybaraFeature < Spinach::FeatureSteps
|
12
12
|
# Given "I go to the home page" do
|
13
13
|
# visit '/'
|
14
14
|
# end
|
15
15
|
# end
|
16
16
|
#
|
17
17
|
module Capybara
|
18
|
-
# Enhances a
|
18
|
+
# Enhances a FeatureSteps with Capybara goodness.
|
19
19
|
#
|
20
20
|
# @param [Class] base
|
21
21
|
# The host class.
|
data/lib/spinach/config.rb
CHANGED
@@ -20,10 +20,11 @@ module Spinach
|
|
20
20
|
# to run.
|
21
21
|
#
|
22
22
|
class Config
|
23
|
-
attr_writer :step_definitions_path, :default_reporter, :support_path
|
23
|
+
attr_writer :step_definitions_path, :default_reporter, :support_path,
|
24
|
+
:failure_exceptions
|
24
25
|
|
25
|
-
# The "step definitions path" holds the place where your feature
|
26
|
-
# will be searched for. Defaults to 'features/steps'
|
26
|
+
# The "step definitions path" holds the place where your feature step
|
27
|
+
# classes will be searched for. Defaults to 'features/steps'
|
27
28
|
#
|
28
29
|
# @return [String]
|
29
30
|
# The step definitions path.
|
@@ -82,5 +83,15 @@ module Spinach
|
|
82
83
|
def []=(attribute, value)
|
83
84
|
self.send("#{attribute}=", value)
|
84
85
|
end
|
86
|
+
|
87
|
+
# The failure exceptions return an array of exceptions to be captured and
|
88
|
+
# considered as failures (as opposite of errors)
|
89
|
+
#
|
90
|
+
# @return [Array<Exception>]
|
91
|
+
#
|
92
|
+
# @api public
|
93
|
+
def failure_exceptions
|
94
|
+
@failure_exceptions ||= []
|
95
|
+
end
|
85
96
|
end
|
86
97
|
end
|
data/lib/spinach/dsl.rb
CHANGED
@@ -39,7 +39,7 @@ module Spinach
|
|
39
39
|
# Action to perform in that step.
|
40
40
|
#
|
41
41
|
# @example
|
42
|
-
# class MyFeature < Spinach::
|
42
|
+
# class MyFeature < Spinach::FeatureSteps
|
43
43
|
# When "I go to the toilet" do
|
44
44
|
# @sittin_on_the_toilet.must_equal true
|
45
45
|
# end
|
@@ -61,7 +61,7 @@ module Spinach
|
|
61
61
|
# The name.
|
62
62
|
#
|
63
63
|
# @example
|
64
|
-
# class MyFeature < Spinach::
|
64
|
+
# class MyFeature < Spinach::FeatureSteps
|
65
65
|
# feature "Satisfy needs"
|
66
66
|
# end
|
67
67
|
#
|
data/lib/spinach/exceptions.rb
CHANGED
@@ -2,7 +2,7 @@ module Spinach
|
|
2
2
|
# This class represents the exception raised when Spinach can't find a class
|
3
3
|
# for a feature.
|
4
4
|
#
|
5
|
-
class
|
5
|
+
class FeatureStepsNotFoundException < StandardError
|
6
6
|
# @param [Array] options
|
7
7
|
# An array consisting of the missing class and the feature.
|
8
8
|
#
|
@@ -12,11 +12,18 @@ module Spinach
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# @return [String]
|
15
|
-
# A custom message when
|
15
|
+
# A custom message when feature steps aren't found.
|
16
16
|
#
|
17
17
|
# @api public
|
18
18
|
def message
|
19
|
-
|
19
|
+
[%Q{Could not find steps for `#{@feature}` feature.
|
20
|
+
Please create the file #{Spinach::Support.underscore(@missing_class)}.rb
|
21
|
+
at #{Spinach.config[:step_definitions_path]}, with:}.gsub(/^\s{6,7}/, ''),
|
22
|
+
%Q{class #{@missing_class} << Spinach::FeatureSteps
|
23
|
+
#
|
24
|
+
# define your steps here
|
25
|
+
#
|
26
|
+
end}.gsub(/^\s{6,7}/, '')].join("\n\n").red
|
20
27
|
end
|
21
28
|
end
|
22
29
|
|
@@ -1,12 +1,8 @@
|
|
1
|
-
require 'minitest/spec'
|
2
|
-
MiniTest::Spec.new nil
|
3
|
-
|
4
1
|
module Spinach
|
5
2
|
# The feature class is the class which all the features must inherit from.
|
6
3
|
#
|
7
|
-
class
|
4
|
+
class FeatureSteps
|
8
5
|
include DSL
|
9
|
-
include MiniTest::Assertions
|
10
6
|
|
11
7
|
# Registers the feature class for later use.
|
12
8
|
#
|
@@ -22,7 +18,7 @@ end
|
|
22
18
|
|
23
19
|
# Syntactic sugar. Define the "Feature do" syntax.
|
24
20
|
Object.send(:define_method, :Feature) do |name, &block|
|
25
|
-
Class.new(Spinach::
|
21
|
+
Class.new(Spinach::FeatureSteps) do
|
26
22
|
feature name
|
27
23
|
class_eval &block
|
28
24
|
end
|
data/lib/spinach/runner.rb
CHANGED
@@ -60,6 +60,9 @@ module Spinach
|
|
60
60
|
# @api public
|
61
61
|
def run
|
62
62
|
require_dependencies
|
63
|
+
require_suites
|
64
|
+
|
65
|
+
run_hook :before_run
|
63
66
|
|
64
67
|
successful = true
|
65
68
|
|
@@ -82,6 +85,12 @@ module Spinach
|
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
88
|
+
# Requires the test suite support
|
89
|
+
#
|
90
|
+
def require_suites
|
91
|
+
require_relative 'suites'
|
92
|
+
end
|
93
|
+
|
85
94
|
# @return [Array<String>] files
|
86
95
|
# The step definition files.
|
87
96
|
#
|
@@ -46,7 +46,7 @@ module Spinach
|
|
46
46
|
begin
|
47
47
|
feature.execute_step(step['name'])
|
48
48
|
run_hook :on_successful_step, step
|
49
|
-
rescue
|
49
|
+
rescue *Spinach.config[:failure_exceptions] => e
|
50
50
|
@exception = e
|
51
51
|
run_hook :on_failed_step, step, @exception
|
52
52
|
rescue Spinach::StepNotDefinedException => e
|
@@ -0,0 +1 @@
|
|
1
|
+
Spinach.config[:failure_exceptions] << RSpec::Expectations::ExpectationNotMetError
|
data/lib/spinach/support.rb
CHANGED
@@ -16,5 +16,27 @@ module Spinach
|
|
16
16
|
def self.camelize(name)
|
17
17
|
name.to_s.strip.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join
|
18
18
|
end
|
19
|
+
|
20
|
+
# Makes an underscored, lowercase form from the expression in the string.
|
21
|
+
#
|
22
|
+
# Changes '::' to '/' to convert namespaces to paths.
|
23
|
+
#
|
24
|
+
# Examples:
|
25
|
+
# "ActiveRecord".underscore # => "active_record"
|
26
|
+
# "ActiveRecord::Errors".underscore # => active_record/errors
|
27
|
+
#
|
28
|
+
# As a rule of thumb you can think of +underscore+ as the inverse of +camelize+,
|
29
|
+
# though there are cases where that does not hold:
|
30
|
+
#
|
31
|
+
# "SSLError".underscore.camelize # => "SslError"
|
32
|
+
def self.underscore(camel_cased_word)
|
33
|
+
word = camel_cased_word.to_s.dup
|
34
|
+
word.gsub!(/::/, '/')
|
35
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
36
|
+
word.gsub!(/([a-z\\d])([A-Z])/,'\1_\2')
|
37
|
+
word.tr!("-", "_")
|
38
|
+
word.downcase!
|
39
|
+
word
|
40
|
+
end
|
19
41
|
end
|
20
42
|
end
|
data/lib/spinach/version.rb
CHANGED
data/spinach.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_development_dependency 'aruba'
|
22
22
|
gem.add_development_dependency 'pry'
|
23
23
|
gem.add_development_dependency 'simplecov'
|
24
|
+
gem.add_development_dependency 'rspec'
|
24
25
|
|
25
26
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
27
|
gem.files = `git ls-files`.split("\n")
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe Spinach::FeatureStepsNotFoundException do
|
4
|
+
subject do
|
5
|
+
Spinach::FeatureStepsNotFoundException.new(['ThisFeatureDoesNotExist', 'This feature does not exist'])
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'message' do
|
9
|
+
it 'tells the user that the steps could not be found' do
|
10
|
+
subject.message.must_include 'Could not find steps for `This feature does not exist` feature.'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'tells the user to create the file' do
|
14
|
+
subject.message.must_include 'Please create the file this_feature_does_not_exist.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'tells the user where to create the file respecting the step definitions path' do
|
18
|
+
Spinach.config.stubs(:step_definitions_path).returns('my/path')
|
19
|
+
subject.message.must_include 'at my/path, with:'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'tells the user what to write in the file' do
|
23
|
+
subject.message.must_include 'class ThisFeatureDoesNotExist << Spinach::FeatureSteps'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
require 'spinach/capybara'
|
3
3
|
require 'sinatra'
|
4
4
|
|
5
|
-
describe Spinach::
|
5
|
+
describe Spinach::FeatureSteps::Capybara do
|
6
6
|
before do
|
7
7
|
@sinatra_app = Sinatra::Application.new do
|
8
8
|
get '/' do
|
@@ -12,8 +12,8 @@ describe Spinach::Feature::Capybara do
|
|
12
12
|
|
13
13
|
Capybara.app = @sinatra_app
|
14
14
|
|
15
|
-
@feature = Class.new(Spinach::
|
16
|
-
include Spinach::
|
15
|
+
@feature = Class.new(Spinach::FeatureSteps) do
|
16
|
+
include Spinach::FeatureSteps::Capybara
|
17
17
|
Given 'Hello' do
|
18
18
|
end
|
19
19
|
Then 'Goodbye' do
|
data/test/spinach/config_test.rb
CHANGED
@@ -1,25 +1,45 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
3
|
describe Spinach::Config do
|
4
|
+
before do
|
5
|
+
@config = Spinach::Config.new
|
6
|
+
end
|
7
|
+
|
4
8
|
describe '#step_definitions_path' do
|
5
9
|
it 'returns a default' do
|
6
|
-
|
10
|
+
@config[:step_definitions_path].must_be_kind_of String
|
7
11
|
end
|
8
12
|
|
9
13
|
it 'can be overwritten' do
|
10
|
-
|
11
|
-
|
14
|
+
@config[:step_definitions_path] = 'steps'
|
15
|
+
@config[:step_definitions_path].must_equal 'steps'
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
15
19
|
describe '#support_path' do
|
16
20
|
it 'returns a default' do
|
17
|
-
|
21
|
+
@config[:support_path].must_be_kind_of String
|
18
22
|
end
|
19
23
|
|
20
24
|
it 'can be overwritten' do
|
21
|
-
|
22
|
-
|
25
|
+
@config[:support_path] = 'support'
|
26
|
+
@config[:support_path].must_equal 'support'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#failure_exceptions' do
|
31
|
+
it 'returns a default' do
|
32
|
+
@config[:failure_exceptions].must_be_kind_of Array
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can be overwritten' do
|
36
|
+
@config[:failure_exceptions] = [1, 2, 3]
|
37
|
+
@config[:failure_exceptions].must_equal [1,2,3]
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'allows adding elements' do
|
41
|
+
@config[:failure_exceptions] << RuntimeError
|
42
|
+
@config[:failure_exceptions].must_include RuntimeError
|
23
43
|
end
|
24
44
|
end
|
25
45
|
end
|
@@ -1,21 +1,17 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
|
-
describe Spinach::
|
3
|
+
describe Spinach::FeatureSteps do
|
4
4
|
describe 'ancestors' do
|
5
|
-
it 'includes minitest helpers' do
|
6
|
-
Spinach::Feature.ancestors.must_include MiniTest::Assertions
|
7
|
-
end
|
8
|
-
|
9
5
|
it 'is extended by the DSL' do
|
10
|
-
Spinach::
|
6
|
+
Spinach::FeatureSteps.ancestors.must_include Spinach::DSL
|
11
7
|
end
|
12
8
|
end
|
13
9
|
|
14
10
|
describe 'class methods' do
|
15
11
|
describe '#inherited' do
|
16
12
|
it 'registers any feature subclass' do
|
17
|
-
@feature1 = Class.new(Spinach::
|
18
|
-
@feature2 = Class.new(Spinach::
|
13
|
+
@feature1 = Class.new(Spinach::FeatureSteps)
|
14
|
+
@feature2 = Class.new(Spinach::FeatureSteps)
|
19
15
|
@feature3 = Class.new
|
20
16
|
|
21
17
|
Spinach.features.must_include @feature1
|
@@ -27,7 +23,7 @@ describe Spinach::Feature do
|
|
27
23
|
|
28
24
|
describe 'instance methods' do
|
29
25
|
let(:feature) do
|
30
|
-
Class.new(Spinach::
|
26
|
+
Class.new(Spinach::FeatureSteps) do
|
31
27
|
When 'I go to the toilet' do
|
32
28
|
@pee = true
|
33
29
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
describe "minitest suite" do
|
4
|
+
before do
|
5
|
+
require_relative '../../../lib/spinach/suites/minitest'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "adds MiniTest::Assertion into the failure exceptions" do
|
9
|
+
Spinach.config[:failure_exceptions].must_include MiniTest::Assertion
|
10
|
+
end
|
11
|
+
|
12
|
+
it "extends the FeatureSteps class with MiniTest DSL" do
|
13
|
+
Spinach::FeatureSteps.ancestors.must_include MiniTest::Assertions
|
14
|
+
end
|
15
|
+
end
|
@@ -22,4 +22,37 @@ describe Spinach::Support do
|
|
22
22
|
Spinach::Support.camelize('feature name').must_equal 'FeatureName'
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe '#underscore' do
|
27
|
+
it 'changes dashes to underscores' do
|
28
|
+
Spinach::Support.underscore('feature-name').must_equal 'feature_name'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'downcases the text' do
|
32
|
+
Spinach::Support.underscore('FEATURE').must_equal 'feature'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'converts namespaces to paths' do
|
36
|
+
Spinach::Support.underscore('Spinach::Support').must_equal 'spinach/support'
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'prepends underscores to uppercase letters' do
|
40
|
+
Spinach::Support.underscore('FeatureName').must_equal 'feature_name'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'only prepends underscores to the last uppercase letter' do
|
44
|
+
Spinach::Support.underscore('SSLError').must_equal 'ssl_error'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not modify the original string' do
|
48
|
+
text = 'FeatureName'
|
49
|
+
underscored_text = Spinach::Support.underscore(text)
|
50
|
+
|
51
|
+
text.wont_equal underscored_text
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'accepts non string values' do
|
55
|
+
Spinach::Support.underscore(:FeatureName).must_equal 'feature_name'
|
56
|
+
end
|
57
|
+
end
|
25
58
|
end
|
data/test/spinach_test.rb
CHANGED
@@ -43,19 +43,7 @@ describe Spinach do
|
|
43
43
|
it 'raises when it cannot find the class' do
|
44
44
|
exception = proc {
|
45
45
|
Spinach.find_feature('This feature does not exist')
|
46
|
-
}.must_raise Spinach::
|
47
|
-
|
48
|
-
exception.message.must_equal 'Could not find class for `This feature does not exist` feature. Please create a ThisFeatureDoesNotExist.rb file at features/steps'
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'uses Spinach.config[:step_definitions_path] to tell the user where to wirte the steps' do
|
52
|
-
Spinach.config.stubs(:step_definitions_path).returns('my/path/')
|
53
|
-
|
54
|
-
exception = proc {
|
55
|
-
Spinach.find_feature('This feature does not exist')
|
56
|
-
}.must_raise Spinach::FeatureNotFoundException
|
57
|
-
|
58
|
-
exception.message.must_match %r{my/path}
|
46
|
+
}.must_raise Spinach::FeatureStepsNotFoundException
|
59
47
|
end
|
60
48
|
end
|
61
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spinach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,11 +12,11 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2011-10-
|
15
|
+
date: 2011-10-09 00:00:00.000000000Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: gherkin
|
19
|
-
requirement: &
|
19
|
+
requirement: &70133830838360 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: '0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70133830838360
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: minitest
|
30
|
-
requirement: &
|
30
|
+
requirement: &70133830837940 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: '0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70133830837940
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: colorize
|
41
|
-
requirement: &
|
41
|
+
requirement: &70133830837520 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: '0'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70133830837520
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: hooks
|
52
|
-
requirement: &
|
52
|
+
requirement: &70133830837100 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ! '>='
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: '0'
|
58
58
|
type: :runtime
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *70133830837100
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: purdytest
|
63
|
-
requirement: &
|
63
|
+
requirement: &70133830836680 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ! '>='
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *70133830836680
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: rake
|
74
|
-
requirement: &
|
74
|
+
requirement: &70133830836260 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ! '>='
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: '0'
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *70133830836260
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mocha
|
85
|
-
requirement: &
|
85
|
+
requirement: &70133830835840 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ! '>='
|
@@ -90,10 +90,10 @@ dependencies:
|
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *70133830835840
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: sinatra
|
96
|
-
requirement: &
|
96
|
+
requirement: &70133830835420 !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
@@ -101,10 +101,10 @@ dependencies:
|
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
|
-
version_requirements: *
|
104
|
+
version_requirements: *70133830835420
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: capybara
|
107
|
-
requirement: &
|
107
|
+
requirement: &70133830835000 !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
110
110
|
- - ! '>='
|
@@ -112,10 +112,10 @@ dependencies:
|
|
112
112
|
version: '0'
|
113
113
|
type: :development
|
114
114
|
prerelease: false
|
115
|
-
version_requirements: *
|
115
|
+
version_requirements: *70133830835000
|
116
116
|
- !ruby/object:Gem::Dependency
|
117
117
|
name: aruba
|
118
|
-
requirement: &
|
118
|
+
requirement: &70133830834580 !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
121
121
|
- - ! '>='
|
@@ -123,10 +123,10 @@ dependencies:
|
|
123
123
|
version: '0'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
|
-
version_requirements: *
|
126
|
+
version_requirements: *70133830834580
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: pry
|
129
|
-
requirement: &
|
129
|
+
requirement: &70133830834160 !ruby/object:Gem::Requirement
|
130
130
|
none: false
|
131
131
|
requirements:
|
132
132
|
- - ! '>='
|
@@ -134,10 +134,10 @@ dependencies:
|
|
134
134
|
version: '0'
|
135
135
|
type: :development
|
136
136
|
prerelease: false
|
137
|
-
version_requirements: *
|
137
|
+
version_requirements: *70133830834160
|
138
138
|
- !ruby/object:Gem::Dependency
|
139
139
|
name: simplecov
|
140
|
-
requirement: &
|
140
|
+
requirement: &70133830833740 !ruby/object:Gem::Requirement
|
141
141
|
none: false
|
142
142
|
requirements:
|
143
143
|
- - ! '>='
|
@@ -145,7 +145,18 @@ dependencies:
|
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
|
-
version_requirements: *
|
148
|
+
version_requirements: *70133830833740
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: rspec
|
151
|
+
requirement: &70133830833320 !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
type: :development
|
158
|
+
prerelease: false
|
159
|
+
version_requirements: *70133830833320
|
149
160
|
description: Spinach is a BDD framework on top of gherkin
|
150
161
|
email:
|
151
162
|
- info@codegram.com
|
@@ -169,9 +180,13 @@ files:
|
|
169
180
|
- features/error_reporting.feature
|
170
181
|
- features/exit_status.feature
|
171
182
|
- features/feature_name_guessing.feature
|
183
|
+
- features/rspec_compatibility.feature
|
172
184
|
- features/steps/error_reporting.rb
|
173
185
|
- features/steps/exit_status.rb
|
174
186
|
- features/steps/feature_name_guessing.rb
|
187
|
+
- features/steps/rspec_compatibility.rb
|
188
|
+
- features/support/env.rb
|
189
|
+
- features/support/error_reporting.rb
|
175
190
|
- features/support/spinach_runner.rb
|
176
191
|
- lib/spinach.rb
|
177
192
|
- lib/spinach/capybara.rb
|
@@ -179,27 +194,32 @@ files:
|
|
179
194
|
- lib/spinach/config.rb
|
180
195
|
- lib/spinach/dsl.rb
|
181
196
|
- lib/spinach/exceptions.rb
|
182
|
-
- lib/spinach/
|
197
|
+
- lib/spinach/feature_steps.rb
|
183
198
|
- lib/spinach/parser.rb
|
184
199
|
- lib/spinach/reporter.rb
|
185
200
|
- lib/spinach/reporter/stdout.rb
|
186
201
|
- lib/spinach/runner.rb
|
187
202
|
- lib/spinach/runner/feature.rb
|
188
203
|
- lib/spinach/runner/scenario.rb
|
204
|
+
- lib/spinach/suites.rb
|
205
|
+
- lib/spinach/suites/minitest.rb
|
206
|
+
- lib/spinach/suites/rspec.rb
|
189
207
|
- lib/spinach/support.rb
|
190
208
|
- lib/spinach/version.rb
|
191
209
|
- spinach.gemspec
|
210
|
+
- test/exceptions_test.rb
|
192
211
|
- test/spinach/capybara_test.rb
|
193
212
|
- test/spinach/cli_test.rb
|
194
213
|
- test/spinach/config_test.rb
|
195
214
|
- test/spinach/dsl_test.rb
|
196
|
-
- test/spinach/
|
215
|
+
- test/spinach/feature_steps_test.rb
|
197
216
|
- test/spinach/parser_test.rb
|
198
217
|
- test/spinach/reporter/stdout_test.rb
|
199
218
|
- test/spinach/reporter_test.rb
|
200
219
|
- test/spinach/runner/feature_test.rb
|
201
220
|
- test/spinach/runner/scenario_test.rb
|
202
221
|
- test/spinach/runner_test.rb
|
222
|
+
- test/spinach/suites/minitest_test.rb
|
203
223
|
- test/spinach/support_test.rb
|
204
224
|
- test/spinach_test.rb
|
205
225
|
- test/test_helper.rb
|
@@ -231,21 +251,27 @@ test_files:
|
|
231
251
|
- features/error_reporting.feature
|
232
252
|
- features/exit_status.feature
|
233
253
|
- features/feature_name_guessing.feature
|
254
|
+
- features/rspec_compatibility.feature
|
234
255
|
- features/steps/error_reporting.rb
|
235
256
|
- features/steps/exit_status.rb
|
236
257
|
- features/steps/feature_name_guessing.rb
|
258
|
+
- features/steps/rspec_compatibility.rb
|
259
|
+
- features/support/env.rb
|
260
|
+
- features/support/error_reporting.rb
|
237
261
|
- features/support/spinach_runner.rb
|
262
|
+
- test/exceptions_test.rb
|
238
263
|
- test/spinach/capybara_test.rb
|
239
264
|
- test/spinach/cli_test.rb
|
240
265
|
- test/spinach/config_test.rb
|
241
266
|
- test/spinach/dsl_test.rb
|
242
|
-
- test/spinach/
|
267
|
+
- test/spinach/feature_steps_test.rb
|
243
268
|
- test/spinach/parser_test.rb
|
244
269
|
- test/spinach/reporter/stdout_test.rb
|
245
270
|
- test/spinach/reporter_test.rb
|
246
271
|
- test/spinach/runner/feature_test.rb
|
247
272
|
- test/spinach/runner/scenario_test.rb
|
248
273
|
- test/spinach/runner_test.rb
|
274
|
+
- test/spinach/suites/minitest_test.rb
|
249
275
|
- test/spinach/support_test.rb
|
250
276
|
- test/spinach_test.rb
|
251
277
|
- test/test_helper.rb
|