extend_spec

Version, currently 0.1.02 versions

github.com/ramon-sg/extend_spec

add let, subject, described_class, before and after to native specs

6 stars
0 dependents
License: MIT

Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  extend_spec:
    github: ramon-sg/extend_spec
    version: ~> 0.1.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

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 and after blocks
  • Ability to define let, let!, subject and subject!

Installation

  1. Add the dependency to your shard.yml:

    development_dependencies:
      extend_spec:
        github: clouw/extend_spec
  2. 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

  1. Fork it (https://github.com/clouw/extend_spec/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request