Struct mrusty::Spec [] [src]

pub struct Spec { /* fields omitted */ }

A struct useful for mruby spec definition and running.

Available matchers:

  • be_a, be_an - type testing
  • be_<somehow> - test boolean-returning <name>? methods
  • be <, be <=, be >, be >= - test relation
  • be_eq, be_eql, be_equal - test equality
  • be_falsey - test falsey things
  • be_truthy - test truthy things
  • have_<something> - test boolean-returning has_<name>? methods
  • raise_error - test errors
  • respond_to - test method responding
  • be_within(value).of - test value

Examples

struct Cont;

impl MrubyFile for Cont {
    fn require(mruby: MrubyType) {
        mruby.def_class_for::<Cont>("Container");
    }
}

let mruby = Mruby::new();
Cont::require(mruby.clone());

let spec = Spec::new(mruby, "Container", "
    context 'when 1' do
      subject { 1 }

      it { is_expected.to eql 1 }
    end

    context 'when 1' do
      subject { 1 }
      let(:one) { 1 }

      it 'won\\'t' do
        expect(1).to eql one
      end
    end
");

assert_eq!(spec.run(), true);

Methods

impl Spec
[src]

Creates an mruby spec runner.

Examples

struct Cont;

impl MrubyFile for Cont {
    fn require(mruby: MrubyType) {
        mruby.def_class_for::<Cont>("Container");
    }
}

let mruby = Mruby::new();
Cont::require(mruby.clone());

let spec = Spec::new(mruby, "Container", "
    context 'when 1' do
      subject { 1 }

      it { is_expected.to eql 1 }
    end

    context 'when 1' do
      subject { 1 }
      let(:one) { 1 }

      it 'won\\'t' do
        expect(1).to eql one
      end
    end
");

Runs mruby specs.

Examples

struct Cont;

impl MrubyFile for Cont {
    fn require(mruby: MrubyType) {
        mruby.def_class_for::<Cont>("Container");
    }
}

let mruby = Mruby::new();
Cont::require(mruby.clone());

let spec = Spec::new(mruby, "Container", "
    context 'when 1' do
      subject { 1 }

      it { is_expected.to eql 1 }
    end

    context 'when 1' do
      subject { 1 }
      let(:one) { 1 }

      it 'won\\'t' do
        expect(1).to eql one
      end
    end
");

assert_eq!(spec.run(), true);