active_operation icon indicating copy to clipboard operation
active_operation copied to clipboard

Shoulda-like smart property matchers

Open SebastianSzturo opened this issue 9 years ago • 0 comments

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") }

SebastianSzturo avatar Oct 29 '16 20:10 SebastianSzturo