Skip to content

Shoulda-like smart property matchers #21

@SebastianSzturo

Description

@SebastianSzturo

It would be great if we could add one-line input matchers either to this project or smart_properties similar to shoulda matchers.

Brainstorming with @t6d:

# input :id, accepts: Integer, converts: :to_i
it { is_expected.to accept_input(:id).of_type(Integer) }
it { is_expected.to accept_input(:id).of_type(Integer) }
it { is_expected.to accept_input(:foo, :bar).for(:id)}
it { is_expected.to convert_input(:id).using(:to_i) }
it { is_expected.to convert_input(:id).dynamically }

# property :name, accepts: String, required: true, default: "No Name", accepts: ["Tom", "Peter"]
it { is_expected.to accept_property(:name).of_type(:String) }
it { is_expected.to accept_property(:name).of_types(:String) }
it { is_expected.to accept_property(:name).of_values(:String) }

it { is_expected.to accept_property(:id) }
it { is_expected.to require_property(:name)
it { is_expected.to default_property(:name),to("No Name") }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions