extend_spec
extend_spec
A small Crystal shard to extend native spec with:
- No global scope pollution
- No Object pollution
- Add
Described
alias for Class or Module - Ability to specify
before
andafter
blocks - Ability to define
let
,let!
,subject
andsubject!
Installation
-
Add the dependency to your
shard.yml
:development_dependencies: extend_spec: github: ramon-sg/extend_spec
-
Run
shards install
Usage
Add this to your spec_helper.cr
:
require "extend_spec"
Example
class Ninja
property name : String
property last_name : String
def initialize(@last_name, @name)
end
def full_name
"#{last_name} #{name}"
end
end
describe Ninja do
let(name) { "Kakashi" }
let(last_name : String) { "Hatake" }
subject { Described.new(last_name, name) }
describe "#full_name" do
it "returns full name" do
subject.full_name.should eq("Hatake Kakashi")
end
context "when name change" do
before { subject.name = "Sakumo" }
it "returns full name" do
subject.full_name.should eq("Hatake Sakumo")
end
end
end
end
Real example in spec/dummy_db_spec.cr
Contributing
- Fork it (https://github.com/ramon-sg/extend_spec/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Repository
extend_spec
Owner
Statistic
- 6
- 0
- 0
- 0
- 0
- about 3 years ago
- November 24, 2019
License
MIT License
Links
Synced at
Sat, 23 Nov 2024 20:05:06 GMT
Languages