• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    Ruby
  • License
    Other
  • Created about 10 years ago
  • Updated about 10 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

Sunscreen

πŸŒ… A macOS app that sets your wallpaper based on sunrise and sunset.
Swift
59
star
5

goodbre.ws

🍻 An example implementation of Recommendable. Unfortunately now defunct.
Ruby
59
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

new_relic-discourse

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

quiet_safari

πŸ™Š If you don’t care about /apple-touch-icon.png being a 404
Ruby
17
star
12

pry-suite

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

emoji

13
star
14

language-fish-shell

🐟 Atom snippets and syntax highlighting for Fish, the friendly interactive shell.
12
star
15

sparkles

✨ Recognize teammates in slack by awarding them sparkles!
Ruby
8
star
16

threads-api

🧡 A Ruby client for Meta's Threads API
Ruby
8
star
17

vim-ariake-dark

The Ariake Dark theme for Vim
Vim Script
5
star
18

snap

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

squint-test

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

davidcelis.github.io

πŸ“° My old homepage and blog, written with Jekyll
HTML
5
star
21

no-tco.safariextension

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

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
23

gifs

🎞 A collection of gifs curated by and for David Celis
HTML
4
star
24

davidcel.is

πŸ“ My personal website and blog
Ruby
3
star
25

runmygi.st

Run arbitrary gists using Docker!
Ruby
3
star
26

rspec-stackprof

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

brewhouse

A Ruby wrapper for the BreweryDB API
Ruby
2
star
28

homebrew-spark

Ruby
1
star
29

gocean

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

dcelis_ebooks

🐦 The home of my Twitter eBooks bot.
Ruby
1
star
31

my-tfe

My personal TFE setup
HCL
1
star
32

empty

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

wing_clip

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

SpriteSheet

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

language-thrift

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

advent-of-code-2020

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

puddle

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