neospec 0.0.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.
- checksums.yaml +7 -0
- data/.buildkite/bin/check-formatting +7 -0
- data/.buildkite/bin/install-asdf +16 -0
- data/.buildkite/bin/install-ruby +11 -0
- data/.buildkite/bin/install-taylor +15 -0
- data/.buildkite/bin/setup-ruby +5 -0
- data/.buildkite/bin/test-ruby +8 -0
- data/.buildkite/bin/test-taylor +8 -0
- data/.buildkite/pipeline.yml +52 -0
- data/.tool-versions +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +66 -0
- data/README.md +43 -0
- data/Rakefile +16 -0
- data/docs/example_spec.rb +28 -0
- data/lib/neospec/color.rb +8 -0
- data/lib/neospec/expector.rb +55 -0
- data/lib/neospec/logger/basic.rb +32 -0
- data/lib/neospec/logger/symbols.rb +18 -0
- data/lib/neospec/report/basic.rb +57 -0
- data/lib/neospec/results.rb +29 -0
- data/lib/neospec/runner/basic.rb +11 -0
- data/lib/neospec/spec/result/failure.rb +14 -0
- data/lib/neospec/spec/result.rb +31 -0
- data/lib/neospec/spec.rb +66 -0
- data/lib/neospec/suite.rb +28 -0
- data/lib/neospec/version.rb +3 -0
- data/lib/neospec.rb +38 -0
- data/neospec.gemspec +30 -0
- data/spec/neospec/expector_spec.rb +201 -0
- data/spec/neospec/logger/basic_spec.rb +101 -0
- data/spec/neospec/logger/symbols_spec.rb +54 -0
- data/spec/neospec/report/basic_spec.rb +115 -0
- data/spec/neospec/results_spec.rb +151 -0
- data/spec/neospec/runner/basic_spec.rb +27 -0
- data/spec/neospec/spec/result_spec.rb +64 -0
- data/spec/neospec/spec_spec.rb +103 -0
- data/spec/neospec/suite_spec.rb +56 -0
- data/spec/neospec/version_spec.rb +3 -0
- data/spec/neospec_spec.rb +11 -0
- data/spec/run.rb +30 -0
- data/spec/support/test_logger.rb +15 -0
- data/spec/support/test_outputter.rb +15 -0
- metadata +97 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@unit.describe "Neospec::Runner::Basic#run" do
|
|
2
|
+
specs_run = []
|
|
3
|
+
|
|
4
|
+
Given "We create a new Neospec::Runner::Basic instance" do
|
|
5
|
+
@runner = Neospec::Runner::Basic.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
When "there are specs defined" do
|
|
9
|
+
@suite = Neospec::Suite.new
|
|
10
|
+
@suite.specs << Neospec::Spec.new(
|
|
11
|
+
description: "",
|
|
12
|
+
block: -> { specs_run << "spec 1" }
|
|
13
|
+
)
|
|
14
|
+
@suite.specs << Neospec::Spec.new(
|
|
15
|
+
description: "",
|
|
16
|
+
block: -> { specs_run << "spec 2" }
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
And "we call #run" do
|
|
21
|
+
@runner.run(logger: TestLogger.new, suite: @suite)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Then "the specs are run" do
|
|
25
|
+
expect(specs_run).to_equal(["spec 1", "spec 2"])
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@unit.describe "Neospec::Spec::Result#initialize" do
|
|
2
|
+
Given "we create a new Neospec::Spec::Result instance" do
|
|
3
|
+
@result = Neospec::Spec::Result.new
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Then "instance variables are set" do
|
|
7
|
+
expect(@result.expectations).to_equal(0)
|
|
8
|
+
expect(@result.failures).to_equal([])
|
|
9
|
+
expect(@result.start).to_equal(nil)
|
|
10
|
+
expect(@result.finish).to_equal(nil)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
@unit.describe "Neospec::Spec::Result#successful?" do
|
|
15
|
+
Given "we create a new Neospec::Spec::Result instance with no failures" do
|
|
16
|
+
@result = Neospec::Spec::Result.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then "it is successful" do
|
|
20
|
+
expect(@result.successful?).to_equal(true)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
But "if we record a failure" do
|
|
24
|
+
@result.expectations = 1
|
|
25
|
+
@result.failures << "a failure"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Then "it is not successful" do
|
|
29
|
+
expect(@result.successful?).to_equal(false)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@unit.describe "Neospec::Spec::Result#finish!" do
|
|
34
|
+
Given "we create a new Neospec::Spec::Result instance" do
|
|
35
|
+
@result = Neospec::Spec::Result.new
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
When "we call #finish!" do
|
|
39
|
+
@result.finish!
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
Then "a finish time is logged" do
|
|
43
|
+
expect(@result.finish).to_be_a(Time)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
@unit.describe "Neospec::Spec::Result#duration" do
|
|
48
|
+
Given "we create a new Neospec::Spec::Result instance" do
|
|
49
|
+
@result = Neospec::Spec::Result.new
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Then "there is no duration" do
|
|
53
|
+
expect(@result.duration).to_equal(nil)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
When "there is a start and finish" do
|
|
57
|
+
@result.start = 10
|
|
58
|
+
@result.finish = 13.5
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Then "there is a duration" do
|
|
62
|
+
expect(@result.duration).to_equal(3.5)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
@unit.describe "Neospec::Spec#initialize" do
|
|
2
|
+
Given "We create a new Neospec::Spec instance" do
|
|
3
|
+
@spec = Neospec::Spec.new(
|
|
4
|
+
description: "the description",
|
|
5
|
+
block: "the block"
|
|
6
|
+
)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Then "instance variables are set" do
|
|
10
|
+
expect(@spec.instance_variable_get(:@__result)).to_be_a(Neospec::Spec::Result)
|
|
11
|
+
|
|
12
|
+
expect(@spec.instance_variable_get(:@__description)).to_equal("the description")
|
|
13
|
+
expect(@spec.instance_variable_get(:@__block)).to_equal("the block")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
@unit.describe "Neospec::Spec#log" do
|
|
18
|
+
Given "We create a new Neospec::Spec instance" do
|
|
19
|
+
@logger = TestLogger.new
|
|
20
|
+
@spec = Neospec::Spec.new(
|
|
21
|
+
description: "the description",
|
|
22
|
+
block: "the block"
|
|
23
|
+
)
|
|
24
|
+
@spec.instance_variable_set(:@__logger, @logger)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
When "log is called" do
|
|
28
|
+
@spec.log("the message", context: "the context", result: "the result")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Then "the logger receives the call" do
|
|
32
|
+
expect(@logger.calls.size).to_equal(1)
|
|
33
|
+
expect(@logger.calls.first).to_equal(
|
|
34
|
+
{
|
|
35
|
+
message: "the message",
|
|
36
|
+
context: "the context",
|
|
37
|
+
result: "the result"
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
@unit.describe "Neospec::Spec#run" do
|
|
44
|
+
was_run = false
|
|
45
|
+
|
|
46
|
+
Given "We create a new Neospec::Spec instance" do
|
|
47
|
+
@spec = Neospec::Spec.new(
|
|
48
|
+
description: "the description",
|
|
49
|
+
block: -> { was_run = true }
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
When "the spec is run" do
|
|
54
|
+
@spec.run(logger: TestLogger.new)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Then "the block was run" do
|
|
58
|
+
expect(was_run).to_equal(true)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
And "the result timing was updated" do
|
|
62
|
+
expect(@spec.result.finish).to_be_a(Time)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
@unit.describe "Neospec::Spec Commands" do
|
|
67
|
+
commands_run = []
|
|
68
|
+
|
|
69
|
+
Given "We create a new Neospec::Spec instance" do
|
|
70
|
+
@spec = Neospec::Spec.new(
|
|
71
|
+
description: "the description",
|
|
72
|
+
block: -> {
|
|
73
|
+
Given("Given") { commands_run << "Given" }
|
|
74
|
+
And("And") { commands_run << "And" }
|
|
75
|
+
But("But") { commands_run << "But" }
|
|
76
|
+
When("When") { commands_run << "When" }
|
|
77
|
+
Then("Then") { commands_run << "Then" }
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
When "the spec is run" do
|
|
83
|
+
@spec.run(logger: TestLogger.new)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Then "all commands were run" do
|
|
87
|
+
expect(commands_run).to_equal(Neospec::Spec::COMMANDS)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
@unit.describe "Neospec::Spec#expect" do
|
|
92
|
+
Given "We create a new Neospec::Spec instance" do
|
|
93
|
+
@spec = Neospec::Spec.new(
|
|
94
|
+
description: "the description",
|
|
95
|
+
block: -> {}
|
|
96
|
+
)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
Then "we can call #expect and get an Expector" do
|
|
100
|
+
expectation = @spec.expect("something")
|
|
101
|
+
expect(expectation).to_be_a(Neospec::Expector)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
@unit.describe "Neospec::Suite#initialize" do
|
|
2
|
+
Given "we create a new Neospec::Suite instance" do
|
|
3
|
+
@suite = Neospec::Suite.new
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Then "instance variables are set" do
|
|
7
|
+
expect(@suite.runner).to_be_a(Neospec::Runner::Basic)
|
|
8
|
+
expect(@suite.specs).to_equal([])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
When "we create a new Neospec::Suite instance with a runner" do
|
|
12
|
+
@runner = Neospec::Runner::Basic.new
|
|
13
|
+
@suite = Neospec::Suite.new(runner: @runner)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Then "instance variables are set" do
|
|
17
|
+
expect(@suite.runner).to_equal(@runner)
|
|
18
|
+
expect(@suite.specs).to_equal([])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@unit.describe "Neospec::Suite#describe" do
|
|
23
|
+
Given "we create a new Neospec::Suite instance" do
|
|
24
|
+
@suite = Neospec::Suite.new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
When "we call #describe" do
|
|
28
|
+
@suite.describe "a spec" do
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
Then "it's recorded in #specs" do
|
|
33
|
+
expect(@suite.specs.size).to_equal(1)
|
|
34
|
+
expect(@suite.specs.first.description).to_equal("a spec")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
@unit.describe "Neospec::Suite#run" do
|
|
39
|
+
was_run = false
|
|
40
|
+
|
|
41
|
+
Given "we create a new Neospec::Suite instance with specs" do
|
|
42
|
+
@suite = Neospec::Suite.new
|
|
43
|
+
|
|
44
|
+
@suite.describe "a spec" do
|
|
45
|
+
was_run = true
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
When "we call #run" do
|
|
50
|
+
@suite.run(logger: TestLogger.new)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
Then "it ran the spec" do
|
|
54
|
+
expect(was_run).to_equal(true)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@unit.describe "Neospec#initialize" do
|
|
2
|
+
Given "We create a new Neospec instance" do
|
|
3
|
+
@unit = Neospec.new
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
Then "instance variables are set" do
|
|
7
|
+
expect(@unit.suites).to_equal([])
|
|
8
|
+
expect(@unit.logger).to_be_a(Neospec::Logger::Basic)
|
|
9
|
+
expect(@unit.reporters).to_equal([Neospec::Report::Basic])
|
|
10
|
+
end
|
|
11
|
+
end
|
data/spec/run.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
$: << "./lib"
|
|
2
|
+
$: << "./spec"
|
|
3
|
+
|
|
4
|
+
require "neospec"
|
|
5
|
+
require "support/test_logger"
|
|
6
|
+
require "support/test_outputter"
|
|
7
|
+
|
|
8
|
+
@unit = Neospec::Suite.new(
|
|
9
|
+
runner: Neospec::Runner::Basic.new
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
neospec = Neospec.new(
|
|
13
|
+
logger: Neospec::Logger::Basic.new,
|
|
14
|
+
reporters: [Neospec::Report::Basic],
|
|
15
|
+
suites: [@unit]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
require "neospec_spec"
|
|
19
|
+
require "neospec/expector_spec"
|
|
20
|
+
require "neospec/logger/basic_spec"
|
|
21
|
+
require "neospec/logger/symbols_spec"
|
|
22
|
+
require "neospec/report/basic_spec"
|
|
23
|
+
require "neospec/results_spec"
|
|
24
|
+
require "neospec/runner/basic_spec"
|
|
25
|
+
require "neospec/spec_spec"
|
|
26
|
+
require "neospec/spec/result_spec"
|
|
27
|
+
require "neospec/suite_spec"
|
|
28
|
+
require "neospec/version_spec"
|
|
29
|
+
|
|
30
|
+
neospec.run!
|
metadata
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: neospec
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sean Earle
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: |2
|
|
13
|
+
A simple testing library that works on ruby and mruby.
|
|
14
|
+
|
|
15
|
+
This has been designed to be very modular, you can run different types of
|
|
16
|
+
suites with different setup/teardown and before/after blocks. You can have
|
|
17
|
+
as many reporters as you want, these can range from "output to the terminal
|
|
18
|
+
in a nice way" all the way to "shape the results into an XML or JSON for my
|
|
19
|
+
CI".
|
|
20
|
+
|
|
21
|
+
The secondary purpose of this testing library is to work with mruby for my
|
|
22
|
+
game engine Taylor and any project built upon that.
|
|
23
|
+
|
|
24
|
+
I also plan to support quite a few ruby versions as I want the code for
|
|
25
|
+
this to be very portable. The main feature I don't want to drop is
|
|
26
|
+
positional AND keyword arguments in definitions, this means anything that
|
|
27
|
+
matches the Ruby 2.6+ spec should be compatible.
|
|
28
|
+
email:
|
|
29
|
+
- sean.r.earle@gmail.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- ".buildkite/bin/check-formatting"
|
|
35
|
+
- ".buildkite/bin/install-asdf"
|
|
36
|
+
- ".buildkite/bin/install-ruby"
|
|
37
|
+
- ".buildkite/bin/install-taylor"
|
|
38
|
+
- ".buildkite/bin/setup-ruby"
|
|
39
|
+
- ".buildkite/bin/test-ruby"
|
|
40
|
+
- ".buildkite/bin/test-taylor"
|
|
41
|
+
- ".buildkite/pipeline.yml"
|
|
42
|
+
- ".tool-versions"
|
|
43
|
+
- Gemfile
|
|
44
|
+
- Gemfile.lock
|
|
45
|
+
- README.md
|
|
46
|
+
- Rakefile
|
|
47
|
+
- docs/example_spec.rb
|
|
48
|
+
- lib/neospec.rb
|
|
49
|
+
- lib/neospec/color.rb
|
|
50
|
+
- lib/neospec/expector.rb
|
|
51
|
+
- lib/neospec/logger/basic.rb
|
|
52
|
+
- lib/neospec/logger/symbols.rb
|
|
53
|
+
- lib/neospec/report/basic.rb
|
|
54
|
+
- lib/neospec/results.rb
|
|
55
|
+
- lib/neospec/runner/basic.rb
|
|
56
|
+
- lib/neospec/spec.rb
|
|
57
|
+
- lib/neospec/spec/result.rb
|
|
58
|
+
- lib/neospec/spec/result/failure.rb
|
|
59
|
+
- lib/neospec/suite.rb
|
|
60
|
+
- lib/neospec/version.rb
|
|
61
|
+
- neospec.gemspec
|
|
62
|
+
- spec/neospec/expector_spec.rb
|
|
63
|
+
- spec/neospec/logger/basic_spec.rb
|
|
64
|
+
- spec/neospec/logger/symbols_spec.rb
|
|
65
|
+
- spec/neospec/report/basic_spec.rb
|
|
66
|
+
- spec/neospec/results_spec.rb
|
|
67
|
+
- spec/neospec/runner/basic_spec.rb
|
|
68
|
+
- spec/neospec/spec/result_spec.rb
|
|
69
|
+
- spec/neospec/spec_spec.rb
|
|
70
|
+
- spec/neospec/suite_spec.rb
|
|
71
|
+
- spec/neospec/version_spec.rb
|
|
72
|
+
- spec/neospec_spec.rb
|
|
73
|
+
- spec/run.rb
|
|
74
|
+
- spec/support/test_logger.rb
|
|
75
|
+
- spec/support/test_outputter.rb
|
|
76
|
+
homepage: https://github.com/HellRok/neospec
|
|
77
|
+
licenses:
|
|
78
|
+
- MIT
|
|
79
|
+
metadata: {}
|
|
80
|
+
rdoc_options: []
|
|
81
|
+
require_paths:
|
|
82
|
+
- lib
|
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: 2.6.0
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
requirements: []
|
|
94
|
+
rubygems_version: 3.6.9
|
|
95
|
+
specification_version: 4
|
|
96
|
+
summary: A simple testing library that works on ruby and mruby
|
|
97
|
+
test_files: []
|