• Stars
    star
    167
  • Rank 219,493 (Top 5 %)
  • Language
    Ruby
  • License
    Other
  • Created over 9 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

โ“ Introduces the `maybe` syntax to RSpec.

spec-me-maybe Build Status

Are your tests order-dependent? Tired of all those randomly failing specs? Can't be bothered to use Timecop? Just give up and surrender. But at least use a proper syntax.

Introducing the maybe syntax for RSpec.

Installation

Add this line to your application's Gemfile:

gem 'spec-me-maybe'

And then execute:

$ bundle

Or install it yourself as:

$ gem install spec-me-maybe

Then, in your spec_helper.rb file:

require 'rspec/maybes'

RSpec.configure do |config|
  config.expect_with :rspec do |expectations|
    # Enable the `maybe` syntax from spec-me-maybe, e.g.:
    #   maybe(actual).will eq(expected)
    expectations.syntax = :maybe
  end
end

Usage

The "maybe" syntax looks and feels almost exactly like the "expect" syntax:

describe User do
  describe '#initialize' do
    let(:user) { User.new(name: 'David Celis') }

    it 'should set up a name' do
      maybe(user.name).will eq 'David Celis'
    end

    it 'probably should not raise any sort of error' do
      maybe { user }.will_not raise_error
    end
  end
end

Whereas expect would set up an RSpec::Expectations::ExpectationTarget, maybe will instead set up an RSpec::Maybe::MaybeTarget. Like expectations, maybes may or may not fail. In the case of maybes, however, they will fail randomly regardless of your code. But hey, maybe your Expectations were like that too.

If your colleagues' complaints of broken specs are totally bullshit because you're super sure they work on your machine, we've got you covered. Here's the above example again, but this time it'll totally always pass:

describe User do
  describe '#initialize' do
    let(:user) { User.new(name: 'David Celis') }

    it 'should set up a name' do
      maybe(user.name).will eq('David Celis').on_my_machine
    end

    it 'probably should not raise any sort of error' do
      maybe { user }.will_not raise_error.on_my_machine
    end
  end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

More Repositories

1

recommendable

๐Ÿ‘๐Ÿ‘Ž A recommendation engine using Likes and Dislikes for your Ruby app
Ruby
1,351
star
2

api-pagination

๐Ÿ“„ Link header pagination for Rails and Grape APIs.
Ruby
689
star
3

inflections

๐Ÿ‡ช๐Ÿ‡ธ Sane and multilingual singularization/pluralization rules for ActiveSupport and Rails.
Ruby
88
star
4

goodbre.ws

๐Ÿป An example implementation of Recommendable. Unfortunately now defunct.
Ruby
59
star
5

Sunscreen

๐ŸŒ… A macOS app that sets your wallpaper based on sunrise and sunset.
Swift
58
star
6

rack-console

๐Ÿ’ป `rails console` for your Rack applications
Ruby
27
star
7

geocodio

A ruby client for the http://geocod.io/ API. Geocode with ease.
Ruby
20
star
8

dotfiles

๐ŸŸ #!/usr/bin/env fish
Shell
19
star
9

api-benchmarks

Benchmarks for various Ruby API frameworks.
Ruby
18
star
10

quiet_safari

๐Ÿ™Š If you donโ€™t care about /apple-touch-icon.png being a 404
Ruby
17
star
11

new_relic-discourse

A New Relic plugin for Discourse forums.
Ruby
17
star
12

pry-suite

A metagem to install Pry with many useful plugins.
Ruby
15
star
13

language-fish-shell

๐ŸŸ Atom snippets and syntax highlighting for Fish, the friendly interactive shell.
12
star
14

emoji

10
star
15

sparkles

โœจ Recognize teammates in slack by awarding them sparkles!
Ruby
6
star
16

vim-ariake-dark

The Ariake Dark theme for Vim
Vim Script
5
star
17

snap

A bootstrapped IRC bot using Cinch. I write plugins so you don't have to.
Ruby
5
star
18

squint-test

Do squint tests on your code in Atom!
CoffeeScript
5
star
19

davidcelis.github.io

๐Ÿ“ฐ My old homepage and blog, written with Jekyll
HTML
5
star
20

no-tco.safariextension

A Safari extension to replace t.co links with their original URL.
JavaScript
4
star
21

nook_stop_api

๐Ÿƒ Welcome to Nook Stop, a multimedia terminal from Nook Inc. This toy app is an example of how to build a GraphQL API in Ruby, powered by data from Animal Crossing: New Horizons.
HTML
4
star
22

davidcel.is

๐Ÿ“ My personal website and blog
Ruby
3
star
23

runmygi.st

Run arbitrary gists using Docker!
Ruby
3
star
24

gifs

๐ŸŽž A collection of gifs curated by and for David Celis
HTML
3
star
25

rspec-stackprof

Easily integrate stackprof with RSpec on Ruby 2.1.
Ruby
2
star
26

brewhouse

A Ruby wrapper for the BreweryDB API
Ruby
2
star
27

homebrew-spark

Ruby
1
star
28

gocean

A Go library to communicate with Digital Ocean's APIv2
1
star
29

dcelis_ebooks

๐Ÿฆ The home of my Twitter eBooks bot.
Ruby
1
star
30

my-tfe

My personal TFE setup
HCL
1
star
31

empty

This repository is empty, but it still has a commit
1
star
32

wing_clip

Sync your Foursquare check-in historyโ€”past, present, and futureโ€”to Google Calendar.
Ruby
1
star
33

SpriteSheet

A small helper class to convert .gifs to sprites.
Ruby
1
star
34

language-thrift

Atom syntax highlighting and snippets for Thrift files.
CoffeeScript
1
star
35

advent-of-code-2020

๐ŸŽ„ My solutions to 2020's Advent of Code, in Ruby
Ruby
1
star
36

puddle

WIP: A MUD server written in Node.js
JavaScript
1
star