a shiny test framework for rust

Related tags

Text editors shiny
Overview

Ooh, shiny!

Build Status

Shiny makes you less distracted with copying over initialization code in test cases. It also has a fancy syntax similar to Ruby's RSpec or Objective-C's Kiwi.

Installation

Install in the usual way with cargo.

Usage

Add the shiny crate:

#![feature(plugin)]
#![plugin(shiny)]

Write your shiny test case:

#[cfg(test)]
mod test {
  describe!(
    before_each {
      let awesome = true;
    }

    it "is awesome" {
      assert!(awesome);
    }

    it "injects before_each into all test cases" {
      let still_awesome = awesome;
      assert!(still_awesome);
    }
  )
}

All the items from before_each are inserted as-is into each generated test case function. Mind the final semicolon in before_each block!

TODO

  • add support for context to do recursive prologue injections
  • better filtering for test case name

License

Shiny is distributed under Apache-2.0, see LICENSE for more details.

Comments
  • Compilation problem because of box syntax

    Compilation problem because of box syntax

    Hi there,

    I'm new to rust and I'd like to use shiny as a tool to learn the language. However, I'm not able to compile even a simple test.

    When I try to compile my dummy project (cargo build) I get this error:

       Compiling shiny v0.1.3
    error: box expression syntax is experimental; you can call `Box::new` instead. (see issue #27779)
       --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/shiny-0.1.3/src/lib.rs:120:9
        |
    120 |         box MacItems { items: items } as Box<MacResult>
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = help: add #![feature(box_syntax)] to the crate attributes to enable
    

    My test code is basically one of your examples:

    #![feature(box_syntax)]
    #![feature(plugin)]
    #![plugin(shiny)]
    
    #[cfg(test)]
    mod test {
      describe!(
        before_each {
          let awesome = true;
        }
    
        it "is awesome" {
          assert!(awesome);
        }
    
        it "injects before_each into all test cases" {
          let still_awesome = awesome;
          assert!(still_awesome);
        }
      )
    }
    

    and my cargo file is just this:

    [package]
    name = "shiny test"
    version = "0.0.1"
    authors = ["me"]
    license = "MIT / Apache-2.0"
    
    [dependencies]
    shiny = "0.1.3"
    

    PS:

    • cargo 0.13.0-nightly (b931a0f 2016-09-11)
    • gcc version 4.9.2 (Debian 4.9.2-10)

    Thanks a lot

    opened by fagossa 2
  • Compile under 1.4.0 nightly

    Compile under 1.4.0 nightly

    As @milgner noticed this is broken with the latest Rust nightly build. This makes everything compile again. And even though the tests pass I don't really know if the functionality has changed or not.

    It is now broken under the current stable version, but due to the usage of #![feature(...)] it couldn't be compiled with the stable compiler anyway.

    opened by ujh 2
  • Synergy with Stainless

    Synergy with Stainless

    Hey @farcaller. Thanks for writing this awesome package. Are you aware that @reem also built a similar project? You can find it here: https://github.com/reem/stainless

    I think it would make sense to somehow merge the projects to end up with a better package in terms of maintaining and quality.

    opened by schickling 2
  • merge with stainless ?

    merge with stainless ?

    ... and make cute little test babies ? :)

    seems to have more activity / was first in my google searches ... might make sense to join up and create a great framework together!

    https://github.com/reem/stainless

    @farcaller

    opened by grosser 1
  • Build fails with rustc 1.4.0 nightly

    Build fails with rustc 1.4.0 nightly

    After the stable branch complained about the use of #![feature(plugin)], I built myself Rust 1.4.0 nightly. But I can't get shiny to work. Unfortunately I'm a total Rust noob, too (just want to write nice tests from the start), so it may be that I'm doing something elementary wrong. Nonetheless, here's the output:

    lib.rs:68:21: 68:29 error: no method named `as_str` found for type `core::result::Result<syntax::ast::Ident, syntax::diagnostic::FatalError>` in the current scope
    lib.rs:76:21: 76:30 error: mismatched types:
     expected `core::result::Result<(syntax::parse::token::InternedString, syntax::ast::StrStyle), syntax::diagnostic::FatalError>`,
        found `(_, _)`
    (expected enum `core::result::Result`,
        found tuple) [E0308]
    lib.rs:76:21: 76:30 help: run `rustc --explain E0308` to see a detailed explanation
    lib.rs:78:35: 78:51 error: the type of this value must be known in this context
    lib.rs:84:28: 84:38 error: no method named `as_slice` found for type `collections::string::String` in the current scope
    lib.rs:93:21: 93:34 error: the type of this value must be known in this context
    note: in expansion of for loop expansion
    lib.rs:91:5: 121:6 note: expansion site
    lib.rs:95:48: 95:60 error: attempted access of field `stmts` on type `&core::result::Result<syntax::ptr::P<syntax::ast::Block>, syntax::diagnostic::FatalError>`, but no field with that name was found
    note: in expansion of for loop expansion
    lib.rs:91:5: 121:6 note: expansion site
    lib.rs:97:28: 97:33 error: binary operation `+` cannot be applied to type `collections::vec::Vec<syntax::ptr::P<syntax::codemap::Spanned<syntax::ast::Stmt_>>>` [E0369]
    note: in expansion of for loop expansion
    lib.rs:91:5: 121:6 note: expansion site
    lib.rs:97:28: 97:33 help: run `rustc --explain E0369` to see a detailed explanation
    lib.rs:97:36: 97:48 error: attempted access of field `stmts` on type `&core::result::Result<syntax::ptr::P<syntax::ast::Block>, syntax::diagnostic::FatalError>`, but no field with that name was found
    note: in expansion of for loop expansion
    lib.rs:91:5: 121:6 note: expansion site
    lib.rs:108:32: 108:54 error: the type of this value must be known in this context
    note: in expansion of for loop expansion
    lib.rs:91:5: 121:6 note: expansion site
    lib.rs:111:19: 116:22 error: this function takes 6 parameters but 5 parameters were supplied [E0061]
    lib.rs:111             node: ast::ItemFn(
    lib.rs:112                 cx.fn_decl(Vec::new(), cx.ty(DUMMY_SP, ast::Ty_::TyTup(Vec::new()))),
    lib.rs:113                 ast::Unsafety::Normal,
    lib.rs:114                 abi::Rust,
    lib.rs:115                 empty_generics(),
    lib.rs:116                 body),
    note: in expansion of for loop expansion
    
    opened by milgner 1
Owner
Vladimir Pouzanov
Vladimir Pouzanov
A terminal-based text editor written in Rust

Iota Iota is a terminal-based text-editor written in Rust. Here's what it looks like right now, editing itself. Motivation Iota was born out of my fru

Greg Chapple 1.6k Jan 8, 2023
A text editor in ≤1024 lines of code, written in Rust

Kibi: A text editor in ≤1024 lines of code, written in Rust A configurable text editor with UTF-8 support, incremental search, syntax highlighting, li

Ilaï Deutel 881 Dec 29, 2022
An independent Rust text editor that runs in your terminal!

Ox editor Ox is a code editor that runs in your terminal. About The Project Ox is a code editor. It was written in Rust using ANSI escape sequences. I

null 2.9k Jan 2, 2023
Rust :heart: Emacs

Rust ❤️ Emacs A community-driven port of Emacs to Rust. Table of Contents Why Emacs? Why Rust? Why A Fork? Getting Started Requirements Dockerized dev

Remacs 4.5k Jan 2, 2023
A modern editor with a backend written in Rust.

Xi Editor (pronounced "Zigh") A modern editor with a backend written in Rust. Maintenance status: The xi-editor project is not currently under active

null 19.7k Jan 5, 2023
Web base text editor written in rust

Ultron Ultron is a web based monospace text-editor with syntax highlighting, completely written in rust. I wrote this code editor for my very specific

Jovansonlee Cesar 59 Aug 8, 2022
syntect is a syntax highlighting library for Rust that uses Sublime Text syntax definitions.

syntect is a syntax highlighting library for Rust that uses Sublime Text syntax definitions. It aims to be a good solution for any Rust project that needs syntax highlighting, including deep integration with text editors written in Rust.

Tristan Hume 1.5k Jan 8, 2023
A fast and small Rust library to make Electron apps more secure.

electron-hardener A Rust library and command line tool to harden Electron binaries against runtime behavior modifications. This provides a way to hard

1Password 364 Dec 23, 2022
Rust-based traffic editor for RMF

Traffic Editor III Welcome to Traffic Editor III. install stuff Unfortunately we need a newer Rust than what comes with Ubuntu 20.04. First make sure

null 2 Oct 20, 2022
My own personal code editor built with Rust + OpenGL

Glyph This is my personal code editor that I am building for fun and to get more familiar with OpenGL. Glyph currently supports Vim keybinds, syntax h

Zack Radisic 83 Dec 23, 2022
Lightning-fast and Powerful Code Editor written in Rust

Lapce Lightning-fast and Powerful Code Editor written in Rust About Lapce is written in pure Rust, with UI in Druid. It's using Xi-Editor's Rope Scien

Lapce 22.1k Jan 8, 2023
A simple terminal-based editor made in rust!

ELuna Editor The terminal-based editor for europa lang. Goals Be as minimal as possible, but retain conveniences found in other editors. Do not add fe

Junhao 3 May 25, 2022
Ginkgo is a text editor built entirely in Rust

Ginkgo is a text editor built entirely in Rust. It supports cursor movements, CTRL commands, select vim commands, insert vs. normal modes, and more. Ginkgo is based on my text editor JED, which itself was based on the popular online editor Kilo.

James Asbury 12 Oct 15, 2022
Linting your Rust-files in Atom, using rustc and cargo.

linter-rust Linting your Rust-files in Atom, using rustc and cargo. Files will be checked when you open or save them. Installation Install Rust and/or

Atom Linter 42 Sep 28, 2022
Dip editor: Multi-platform Text editor purely written in Rust

dip editor Multi-platform Text editor purely written in Rust, supercharged by Bevy game engine and Dioxus UI framework. heavily in development Why Gam

Junichi Sugiura 270 Jan 4, 2023
A collision editor for Guilty Gear -Strive-, written in Rust

ggst_collision_editor_rs A collision editor for Guilty Gear -Strive- and other Team Red Arc System Works games, written in Rust. Uses a customized ver

null 4 May 3, 2022
Wealthy Rich ported to Rust! This aims to be a crate for rich text and beautiful formatting in the terminal

Wealthy Rich ported to Rust! This aims to be a crate for rich text and beautiful formatting in the terminal

Sourajyoti Basak 20 Dec 29, 2022
Helix - A kakoune / neovim inspired editor, written in Rust

A kakoune / neovim inspired editor, written in Rust. The editing model is very heavily based on kakoune; during development I found myself agree

null 17.9k Jan 10, 2023
A pathtracer written in rust - runs in the web and includes an editor

Webtracer A pathtracer written in rust - runs in the web and includes an editor Rendering is parallelized and utilizes all cpu cores You can easily ed

Shapur 5 Oct 7, 2022