8 releases

0.2.2 Jan 11, 2025
0.2.1 Nov 20, 2024
0.2.0 Aug 3, 2023
0.1.4 May 24, 2023
0.1.1 Apr 25, 2023

#332 in Build Utils

Download history 185/week @ 2024-10-26 231/week @ 2024-11-02 150/week @ 2024-11-09 417/week @ 2024-11-16 134/week @ 2024-11-23 299/week @ 2024-11-30 196/week @ 2024-12-07 24/week @ 2024-12-14 6/week @ 2024-12-21 1/week @ 2024-12-28 282/week @ 2025-01-04 414/week @ 2025-01-11 110/week @ 2025-01-18 80/week @ 2025-01-25 167/week @ 2025-02-01 87/week @ 2025-02-08

459 downloads per month

MIT/Apache

155KB
3.5K SLoC

rb-sys-test-helpers

Helpers for testing Ruby extensions from Rust

Usage

Add this to your Cargo.toml:

[dev-dependencies]
rb-sys-env = { version = "0.1" }
rb-sys-test-helpers = { version = "0.2" }

Then, in your crate's build.rs:

pub fn main() -> Result<(), Box<dyn std::error::Error>> {
    let _ = rb_sys_env::activate()?;

    Ok(())
}

Then, you can use the with_ruby_vm function in your tests:

#[cfg(test)]
mod tests {
    use rb_sys_test_helpers::ruby_test;
    use rb_sys::{rb_num2fix, rb_int2big, FIXNUM_P};

    #[ruby_test]
    fn test_something() {
        // Your test code here will have a valid Ruby VM (hint: this works with
        // the `magnus` crate, too!)
        //
        // ...

        let int = unsafe { rb_num2fix(1) };
        let big = unsafe { rb_int2big(9999999) };

        assert!(FIXNUM_P(int));
        assert!(!FIXNUM_P(big));
    }
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.2–3MB
~52K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy