Git Product home page Git Product logo

Comments (7)

MissingHandle avatar MissingHandle commented on July 19, 2024

Also - any thoughts on shoulda-like helpers -

expect(SomeStruct).to have_attribute(:attr_name).of_type(SomeType)

would this be desirable? or do you have other thoughts?

ftr, willing to contribute if desired.

from dry-struct.

AMHOL avatar AMHOL commented on July 19, 2024

@MissingHandle check out rspec-dry-struct, I think this does exactly what you want.

from dry-struct.

MissingHandle avatar MissingHandle commented on July 19, 2024

Ah - thanks @AMHOL ! That indeed takes care of the testing need.

What about the introspective functions - any thoughts there? I'm coming across a scenario where I have a specification in a JSON file. Within my code, I want to make sure that values in the JSON are valid according to various structs i've defined. For me, the introspective functions seem unavoidably necessary - would you want them within dry-struct?

from dry-struct.

flash-gordon avatar flash-gordon commented on July 19, 2024

@MissingHandle Struct.attribute? and Struct.attribute_names have landed in master :) I'll push a new release next week

from dry-struct.

solnic avatar solnic commented on July 19, 2024

from dry-struct.

flash-gordon avatar flash-gordon commented on July 19, 2024

@solnic tbh I added this specifically for use at the runtime. FWIW using attribute? is more semantic-full than a plain respond_to? call and attribute_names can be useful for metaprogramming. I wouldn't write a test for a struct, for my taste, it's a waste of time :)

from dry-struct.

MissingHandle avatar MissingHandle commented on July 19, 2024

I also wanted the functions for runtime. Though I was asking about it, I might agree with you on the testing.

from dry-struct.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.