Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Commit

Permalink
Adding message to API and renaming gem
Browse files Browse the repository at this point in the history
  • Loading branch information
golmansax committed Nov 1, 2014
1 parent 03f28e7 commit 1913bf7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in stink-bomb.gemspec
# Specify your gem's dependencies in stink_bomb.gemspec
gemspec

group :development, :test do
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# StinkBomb

[![Gem Version](https://badge.fury.io/rb/stink-bomb.svg)](http://badge.fury.io/rb/stink-bomb)
[![Gem Version](https://badge.fury.io/rb/stink_bomb.svg)](http://badge.fury.io/rb/stink_bomb)
[![Build Status](https://travis-ci.org/ChalkSchools/stink-bomb.svg?branch=master)](https://travis-ci.org/ChalkSchools/stink-bomb)
[![Coverage Status](https://img.shields.io/coveralls/ChalkSchools/stink-bomb.svg)](https://coveralls.io/r/ChalkSchools/stink-bomb?branch=master)

Expand All @@ -13,7 +13,7 @@ and you want this code to fail CI when it gets too stinky.
Add this line to your application's Gemfile:

```ruby
gem 'stink-bomb'
gem 'stink_bomb'
```

And then execute:
Expand All @@ -22,7 +22,7 @@ And then execute:

Or install it yourself as:

$ gem install stink-bomb
$ gem install stink_bomb

## Usage

Expand Down
4 changes: 2 additions & 2 deletions lib/stink_bomb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'stink_bomb/bomb'

class StinkBomb
def self.create(datetime)
StinkBomb::Bomb.new(datetime)
def self.create(datetime, message: nil)
StinkBomb::Bomb.new(datetime, message: message)
end
end
4 changes: 2 additions & 2 deletions lib/stink_bomb/bomb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ class StinkBomb
class Bomb
attr_accessor :datetime

def initialize(datetime)
def initialize(datetime, message: nil)
self.datetime = parse(datetime)
fail fail_message if !production? && past_datetime?
fail (message || fail_message) if !production? && past_datetime?
end

def parse(datetime)
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/stink_bomb/bomb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class StinkBomb
end.not_to raise_error
end

it 'raises a custom message when specified' do
yesterday = Date.today - 1
expect do
Bomb.new(yesterday, message: 'Smells like poo')
end.to raise_error(/Smells like poo/)
end

it 'raises an error if the given date is after today' do
yesterday = Date.today - 1
expect do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/stink_bomb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe StinkBomb do
describe '#create' do
it 'creates an instance of Bomb with the parameters' do
expect(StinkBomb::Bomb).to receive(:new).with('My date')
expect(StinkBomb::Bomb).to receive(:new).with('My date', message: nil)
StinkBomb.create('My date')
end
end
Expand Down
2 changes: 1 addition & 1 deletion stink-bomb.gemspec → stink_bomb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'stink_bomb/version'

Gem::Specification.new do |spec|
spec.name = 'stink-bomb'
spec.name = 'stink_bomb'
spec.version = StinkBomb::VERSION
spec.authors = ['Holman Gao']
spec.email = ['holman@golmansax.com']
Expand Down

0 comments on commit 1913bf7

Please sign in to comment.