0.0
No commit activity in last 3 years
No release in over 3 years
RubyMotion derivative of Bacon, which is a derivative of RSpec
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0

Runtime

 Project Readme

MotionSpec

App Version Build Status Code Climate Dependency Status MIT Licensed

Specs are important! This project makes them a first-class citizen again.

RubyMotion is great at integrating them from the start, but they aren't core to the RubyMotion workflow, and lag behind their distant rspec cousin (RubyMotion's specs are forked from MacBacon, which is a port of Bacon which is a simplified version of rspec).

Installation

Add this line to your app's Gemfile:

gem 'motion-spec'

If your Rakefile includes this line you're all set:

Bundler.require

Otherwise, you'll need to add this line to the top of your Rakefile:

require 'motion-spec'

Usage

By Example

describe AwesomeClass do
  it 'initializes with defaults' do
    expect(AwesomeClass.new.attribute).to eq 'my default'
  end

  it { expect(true).to be_true }

  context 'with a precondition' do
    before { AwesomeClass.build_context }
    after { AwesomeClass.reset_all }

    let(:example_1) { AwesomeClass.new(foo: 'bar') }
    subject { example_1.instance_function }

    it { is_expected.to have_foo('bar') }
  end

  context 'stubbing a method' do
    before { subject.stub!(:awesome_method, return: 'awesomeness') }

    subject { AwesomeClass.new }

    it { expect(subject.awesome_method).to eq 'awesomeness' }
  end
end

mock! vs stub!

mock! ensures that the method is called (and removes the implementation when it is), while stub! simply replaces the method for the duration of the spec.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jbender/motion-spec.