extend_spec
Version, currently 0.2.02 versions
- 0.2.0latestAug 2, 2020
- 0.1.0not indexedSep 5, 2021
github.com/ramon-sg/extend_spec
add let, subject, described_class, before and after to native specs
6 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
extend_spec:
github: ramon-sg/extend_spec
version: ~> 0.2.0Then run:
shards installshard.yml
- Crystal
0.30.1- License
- MIT
- Author
- Ramón Soto
Dependencies
This version declares no dependencies.
README
extend_spec
A small Crystal shard to extend native spec with:
- No global scope pollution
- No Object pollution
- Add
Describedalias for Class or Module - Ability to specify
beforeandafterblocks - Ability to define
let,let!,subjectandsubject!
Installation
-
Add the dependency to your
shard.yml:development_dependencies: extend_spec: github: clouw/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/clouw/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
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.0- Tagged
- Aug 2, 2020
- Commit
a9f5dc9f931b- Crystal
0.30.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/ramon-sg/extend_spec
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 2