specify 0.10.2 → 1.0.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 +5 -5
- data/.gitignore +46 -26
- data/.hound.yml +38 -55
- data/.rspec +3 -0
- data/.rubocop.yml +4 -0
- data/.travis.yml +7 -11
- data/CODE_OF_CONDUCT.md +68 -7
- data/Gemfile +5 -1
- data/LICENSE.md +21 -0
- data/README.md +153 -27
- data/Rakefile +11 -7
- data/bin/console +3 -6
- data/bin/setup +4 -1
- data/lib/specify.rb +36 -47
- data/lib/specify/rspec/example_group.rb +47 -40
- data/lib/specify/rspec/formatter.rb +72 -0
- data/lib/specify/rspec/notification.rb +0 -3
- data/lib/specify/rspec/reporter.rb +8 -15
- data/lib/specify/rspec/shared_steps.rb +1 -3
- data/lib/specify/rspec/world.rb +0 -3
- data/lib/specify/spec.rb +23 -17
- data/lib/specify/version.rb +1 -1
- data/specify.gemspec +26 -33
- metadata +46 -22
- data/LICENSE.txt +0 -22
- data/lib/specify/rspec/documentation_formatter.rb +0 -70
data/Rakefile
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require
|
3
|
-
|
4
|
-
require
|
5
|
-
require
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require "rdoc/task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
require "rspec/core/rake_task"
|
6
7
|
|
7
8
|
RuboCop::RakeTask.new
|
8
9
|
|
10
|
+
RSpec::Core::RakeTask.new(:spec)
|
11
|
+
|
9
12
|
namespace :spec do
|
10
13
|
desc 'Clean all generated reports'
|
11
14
|
task :clean do
|
12
15
|
system('rm -rf spec/reports')
|
16
|
+
system('rm -rf spec/coverage')
|
13
17
|
end
|
14
18
|
|
15
19
|
RSpec::Core::RakeTask.new(all: :clean) do |config|
|
16
|
-
options = %w
|
17
|
-
options += %w
|
18
|
-
options += %w
|
20
|
+
options = %w[--color]
|
21
|
+
options += %w[--format documentation]
|
22
|
+
options += %w[--format html --out spec/reports/test-report.html]
|
19
23
|
|
20
24
|
config.rspec_opts = options
|
21
25
|
end
|
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/lib/specify.rb
CHANGED
@@ -1,47 +1,36 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
|
9
|
-
|
10
|
-
require
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
RSpec::Core::ExampleGroup.
|
18
|
-
|
19
|
-
RSpec::Core::
|
20
|
-
|
21
|
-
RSpec::Core::
|
22
|
-
|
23
|
-
|
24
|
-
RSpec.
|
25
|
-
|
26
|
-
:
|
27
|
-
|
28
|
-
:
|
29
|
-
:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
RSpec::Core::ExampleGroup.
|
34
|
-
RSpec::Core::
|
35
|
-
|
36
|
-
|
37
|
-
RSpec::Core::ExampleGroup.define_example_method :Test, with_steps: true
|
38
|
-
RSpec::Core::ExampleGroup.define_example_method :Rule, with_steps: true
|
39
|
-
RSpec::Core::ExampleGroup.define_example_method :Fact, with_steps: true
|
40
|
-
|
41
|
-
RSpec::Core::ExampleGroup.define_example_method :steps, with_steps: true
|
42
|
-
RSpec::Core::ExampleGroup.define_example_method :rules, with_steps: true
|
43
|
-
RSpec::Core::ExampleGroup.define_example_method :tests, with_steps: true
|
44
|
-
RSpec::Core::ExampleGroup.define_example_method :facts, with_steps: true
|
45
|
-
|
46
|
-
require 'specify/rspec/shared_steps'
|
47
|
-
include RSpec::Specify::SharedSteps
|
1
|
+
require "specify/version"
|
2
|
+
|
3
|
+
require "specify/spec"
|
4
|
+
require "specify/rspec/world"
|
5
|
+
require "specify/rspec/reporter"
|
6
|
+
require "specify/rspec/formatter"
|
7
|
+
require "specify/rspec/notification"
|
8
|
+
require "specify/rspec/example_group"
|
9
|
+
|
10
|
+
require "specify/rspec/shared_steps"
|
11
|
+
|
12
|
+
module Specify
|
13
|
+
include RSpec::Specify::SharedSteps
|
14
|
+
|
15
|
+
::RSpec::Core::ExampleGroup.define_example_method :Scenario, has_steps: true
|
16
|
+
::RSpec::Core::ExampleGroup.define_example_method :Condition, has_steps: true
|
17
|
+
::RSpec::Core::ExampleGroup.define_example_method :Behavior, has_steps: true
|
18
|
+
|
19
|
+
::RSpec::Core::ExampleGroup.define_example_method :scenario, has_steps: true
|
20
|
+
::RSpec::Core::ExampleGroup.define_example_method :condition, has_steps: true
|
21
|
+
::RSpec::Core::ExampleGroup.define_example_method :behavior, has_steps: true
|
22
|
+
|
23
|
+
::RSpec::Core::ExampleGroup.define_example_method :Steps, has_steps: true
|
24
|
+
::RSpec::Core::ExampleGroup.define_example_method :Tests, has_steps: true
|
25
|
+
::RSpec::Core::ExampleGroup.define_example_method :Rules, has_steps: true
|
26
|
+
::RSpec::Core::ExampleGroup.define_example_method :Facts, has_steps: true
|
27
|
+
|
28
|
+
::RSpec::Core::ExampleGroup.define_example_method :steps, has_steps: true
|
29
|
+
::RSpec::Core::ExampleGroup.define_example_method :rules, has_steps: true
|
30
|
+
::RSpec::Core::ExampleGroup.define_example_method :tests, has_steps: true
|
31
|
+
::RSpec::Core::ExampleGroup.define_example_method :facts, has_steps: true
|
32
|
+
|
33
|
+
::RSpec::Core::ExampleGroup.send :include, RSpec::Specify::ExampleGroup
|
34
|
+
::RSpec::Core::Reporter.send :include, RSpec::Specify::Reporter
|
35
|
+
::RSpec::Core::World.send :include, RSpec::Specify::World
|
36
|
+
end
|
@@ -1,85 +1,92 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Specify
|
3
3
|
module ExampleGroup
|
4
|
-
# In Rspec, example group bodies are delimited by 'describe' and
|
5
|
-
# 'context' methods. These encapsulate examples, which are
|
6
|
-
# delimited by 'it' methods. Example groups are evaluated in the
|
7
|
-
# context of an ExampleGroup instance. Individual examples are
|
8
|
-
# evaluated in the context of an instance of the ExampleGroup
|
9
|
-
# to which they belong.
|
10
|
-
|
11
4
|
def include_steps(*args)
|
12
5
|
name = args.shift
|
6
|
+
|
13
7
|
shared_block = ::RSpec.world.shared_example_steps[name]
|
14
|
-
shared_block || raise(ArgumentError,
|
8
|
+
shared_block || raise(ArgumentError,
|
9
|
+
"Unable to find shared steps '#{name.inspect}'")
|
10
|
+
|
15
11
|
instance_exec(*args, &shared_block)
|
16
12
|
end
|
17
13
|
|
14
|
+
# rubocop:disable Naming/MethodName
|
18
15
|
def Given(message, options = {}, &block)
|
19
|
-
|
16
|
+
run_example_step(:given, message, options, &block)
|
20
17
|
end
|
21
18
|
|
22
19
|
def When(message, options = {}, &block)
|
23
|
-
|
20
|
+
run_example_step(:when, message, options, &block)
|
24
21
|
end
|
25
22
|
|
26
23
|
def Then(message, options = {}, &block)
|
27
|
-
|
24
|
+
run_example_step(:then, message, options, &block)
|
28
25
|
end
|
29
26
|
|
30
27
|
def And(message, options = {}, &block)
|
31
|
-
|
28
|
+
run_example_step(:and, message, options, &block)
|
32
29
|
end
|
33
30
|
|
34
31
|
def But(message, options = {}, &block)
|
35
|
-
|
32
|
+
run_example_step(:but, message, options, &block)
|
36
33
|
end
|
34
|
+
# rubocop:enable Naming/MethodName
|
37
35
|
|
38
|
-
def
|
39
|
-
|
36
|
+
def rule(message, options = {}, &block)
|
37
|
+
run_example_step(:rule, message, options, &block)
|
40
38
|
end
|
41
39
|
|
42
|
-
def
|
43
|
-
|
40
|
+
def fact(message, options = {}, &block)
|
41
|
+
run_example_step(:fact, message, options, &block)
|
44
42
|
end
|
45
43
|
|
46
|
-
def
|
47
|
-
|
44
|
+
def test(message, options = {}, &block)
|
45
|
+
run_example_step(:test, message, options, &block)
|
48
46
|
end
|
49
47
|
|
50
|
-
def
|
51
|
-
|
48
|
+
def step(message, options = {}, &block)
|
49
|
+
run_example_step(:step, message, options, &block)
|
52
50
|
end
|
53
51
|
|
54
|
-
def
|
55
|
-
|
52
|
+
def it(message, options = {}, &block)
|
53
|
+
run_example_step(:it, message, options, &block)
|
56
54
|
end
|
57
55
|
|
58
|
-
def
|
59
|
-
|
56
|
+
def specify(message, options = {}, &block)
|
57
|
+
run_example_step(:specify, message, options, &block)
|
60
58
|
end
|
61
59
|
|
62
|
-
def
|
63
|
-
|
60
|
+
def example(message, options = {}, &block)
|
61
|
+
run_example_step(:example, message, options, &block)
|
64
62
|
end
|
65
63
|
|
66
64
|
private
|
67
65
|
|
68
|
-
def
|
69
|
-
::RSpec.world.reporter.example_step_started(self, type,
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
rescue Exception => e
|
76
|
-
::RSpec.world.reporter.example_step_failed(self, type, message, options)
|
77
|
-
raise e
|
78
|
-
end
|
79
|
-
::RSpec.world.reporter.example_step_passed(self, type, message, options)
|
66
|
+
def run_example_step(type, msg, opts = {}, &block)
|
67
|
+
::RSpec.world.reporter.example_step_started(self, type, msg, opts)
|
68
|
+
|
69
|
+
opts = { pending: true } if opts == :pending
|
70
|
+
|
71
|
+
if block_given? && !opts[:pending]
|
72
|
+
execute_step(type, msg, opts, &block)
|
80
73
|
else
|
81
|
-
::RSpec.world.reporter.example_step_pending(
|
74
|
+
::RSpec.world.reporter.example_step_pending(
|
75
|
+
self, type, msg, opts
|
76
|
+
)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def execute_step(type, msg, opts, &_block)
|
81
|
+
begin
|
82
|
+
yield
|
83
|
+
# rubocop:disable Lint/RescueException
|
84
|
+
rescue Exception => e
|
85
|
+
::RSpec.world.reporter.example_step_failed(self, type, msg, opts)
|
86
|
+
raise e
|
82
87
|
end
|
88
|
+
# rubocop:enable Lint/RescueException
|
89
|
+
::RSpec.world.reporter.example_step_passed(self, type, msg, opts)
|
83
90
|
end
|
84
91
|
end
|
85
92
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "rspec/core/formatters/console_codes"
|
2
|
+
require "rspec/core/formatters/documentation_formatter"
|
3
|
+
|
4
|
+
module RSpec
|
5
|
+
module Specify
|
6
|
+
class Formatter < ::RSpec::Core::Formatters::DocumentationFormatter
|
7
|
+
::RSpec::Core::Formatters.register(
|
8
|
+
self,
|
9
|
+
:example_started, :example_passed,
|
10
|
+
:example_step_passed, :example_step_failed,
|
11
|
+
:example_step_pending
|
12
|
+
)
|
13
|
+
|
14
|
+
def example_started(notification)
|
15
|
+
return unless notification.example.metadata[:has_steps]
|
16
|
+
|
17
|
+
indentation = current_indentation
|
18
|
+
description = notification.example.description
|
19
|
+
|
20
|
+
full_message = "#{indentation}#{description}"
|
21
|
+
output.puts(
|
22
|
+
::RSpec::Core::Formatters::ConsoleCodes.wrap(full_message, :default)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def example_passed(notification)
|
27
|
+
super unless notification.example.metadata[:has_steps]
|
28
|
+
end
|
29
|
+
|
30
|
+
def example_step_passed(notification)
|
31
|
+
indentation = current_indentation
|
32
|
+
step_type = notification.type.to_s.capitalize
|
33
|
+
step_message = notification.message
|
34
|
+
|
35
|
+
full_message = "#{indentation} #{step_type} #{step_message}"
|
36
|
+
output.puts(
|
37
|
+
::RSpec::Core::Formatters::ConsoleCodes.wrap(full_message, :success)
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def example_step_failed(notification)
|
42
|
+
indentation = current_indentation
|
43
|
+
step_type = notification.type.to_s.capitalize
|
44
|
+
step_message = notification.message
|
45
|
+
|
46
|
+
full_message = "#{indentation} #{step_type} #{step_message} (FAILED)"
|
47
|
+
output.puts(
|
48
|
+
::RSpec::Core::Formatters::ConsoleCodes.wrap(full_message, :failure)
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def example_step_pending(notification)
|
53
|
+
indentation = current_indentation
|
54
|
+
step_type = notification.type.to_s.capitalize
|
55
|
+
step_message = notification.message
|
56
|
+
|
57
|
+
full_message = "#{indentation} #{step_type} #{step_message}"
|
58
|
+
|
59
|
+
full_message << if notification.options[:pending] &&
|
60
|
+
notification.options[:pending] != true
|
61
|
+
" (PENDING: #{notification.options[:pending]})"
|
62
|
+
else
|
63
|
+
" (PENDING)"
|
64
|
+
end
|
65
|
+
|
66
|
+
output.puts(
|
67
|
+
::RSpec::Core::Formatters::ConsoleCodes.wrap(full_message, :pending)
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -1,31 +1,24 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Specify
|
3
3
|
module Reporter
|
4
|
-
# An RSpec reporter sends notifications to listeners. The listeners
|
5
|
-
# are usually formatters for a specific test run.
|
6
|
-
|
7
4
|
def example_step_started(example, type, message, options)
|
8
|
-
notify :example_step_started,
|
5
|
+
notify :example_step_started,
|
6
|
+
Notification.new(example, type, message, options)
|
9
7
|
end
|
10
8
|
|
11
9
|
def example_step_passed(example, type, message, options)
|
12
|
-
notify :example_step_passed,
|
10
|
+
notify :example_step_passed,
|
11
|
+
Notification.new(example, type, message, options)
|
13
12
|
end
|
14
13
|
|
15
14
|
def example_step_failed(example, type, message, options)
|
16
|
-
notify :example_step_failed,
|
15
|
+
notify :example_step_failed,
|
16
|
+
Notification.new(example, type, message, options)
|
17
17
|
end
|
18
18
|
|
19
19
|
def example_step_pending(example, type, message, options)
|
20
|
-
notify :example_step_pending,
|
21
|
-
|
22
|
-
|
23
|
-
def registered_formatters
|
24
|
-
@listeners.values.map(&:to_a).flatten.uniq
|
25
|
-
end
|
26
|
-
|
27
|
-
def find_registered_formatter(cls)
|
28
|
-
registered_formatters.detect { |formatter| formatter.class == cls }
|
20
|
+
notify :example_step_pending,
|
21
|
+
Notification.new(example, type, message, options)
|
29
22
|
end
|
30
23
|
end
|
31
24
|
end
|
@@ -10,10 +10,8 @@ module RSpec
|
|
10
10
|
|
11
11
|
def ensure_shared_example_steps_name_not_taken(name)
|
12
12
|
return unless ::RSpec.world.shared_example_steps.key?(name)
|
13
|
+
|
13
14
|
raise(ArgumentError, "Shared step '#{name}' already exists")
|
14
|
-
# if ::RSpec.world.shared_example_steps.key?(name)
|
15
|
-
# raise ArgumentError.new("Shared step '#{name}' already exists")
|
16
|
-
# end
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
data/lib/specify/rspec/world.rb
CHANGED
data/lib/specify/spec.rb
CHANGED
@@ -1,39 +1,45 @@
|
|
1
1
|
module Specify
|
2
2
|
module Spec
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
alias :Setup :before
|
7
|
-
alias :Teardown :after
|
8
|
-
|
3
|
+
# rubocop:disable Metrics/MethodLength
|
4
|
+
def self.included(caller)
|
5
|
+
caller.instance_eval do
|
9
6
|
alias :Feature :context
|
7
|
+
alias :feature :context
|
10
8
|
alias :Ability :context
|
11
|
-
alias :
|
9
|
+
alias :ability :context
|
12
10
|
alias :Component :context
|
11
|
+
alias :component :context
|
13
12
|
alias :Workflow :context
|
13
|
+
alias :workflow :context
|
14
|
+
alias :Service :context
|
15
|
+
alias :service :context
|
16
|
+
|
17
|
+
alias :Background :before
|
18
|
+
alias :Setup :before
|
19
|
+
alias :Teardown :after
|
20
|
+
alias :Cleanup :after
|
14
21
|
end
|
15
22
|
end
|
23
|
+
# rubocop:enable Metrics/MethodLength
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
27
|
+
# rubocop:disable Naming/MethodName
|
19
28
|
def self.Feature(*args, &block)
|
20
|
-
describe(*args, &block)
|
29
|
+
RSpec.describe(*args, &block)
|
21
30
|
end
|
22
31
|
|
23
|
-
def self.
|
24
|
-
describe(*args, &block)
|
32
|
+
def self.feature(*args, &block)
|
33
|
+
RSpec.describe(*args, &block)
|
25
34
|
end
|
26
35
|
|
27
36
|
def self.Story(*args, &block)
|
28
|
-
describe(*args, &block)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.Component(*args, &block)
|
32
|
-
describe(*args, &block)
|
37
|
+
RSpec.describe(*args, &block)
|
33
38
|
end
|
34
39
|
|
35
|
-
def self.
|
36
|
-
describe(*args, &block)
|
40
|
+
def self.story(*args, &block)
|
41
|
+
RSpec.describe(*args, &block)
|
37
42
|
end
|
43
|
+
# rubocop:enable Naming/MethodName
|
38
44
|
|
39
45
|
RSpec.configuration.include Specify::Spec
|