Skip to content

Commit

Permalink
Adds new libraries and test
Browse files Browse the repository at this point in the history
  - Adds support for endpoints "fascinating", "flying", and "outside"
  • Loading branch information
rthbound committed Aug 19, 2013
1 parent e64749c commit 78cc766
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 7 deletions.
16 changes: 10 additions & 6 deletions README.md
Expand Up @@ -98,18 +98,22 @@ Fuck::Thing.new(thing: "Anything", from: "Me").call
Fuck::Thanks.new(from: "Me").call
```

# TODO
## /flying/:from

## /outside/:name/:from
```ruby
Fuck::Flying.new(from: "Me").call
```

## /fascinating/:from

Intended:
```ruby
Fuck::Outside.new(name: "You", from: "Me").call
Fuck::Fascinating.new(from: "Me").call
```

Current:
## /outside/:name/:from

```ruby
FOaaS::FO.new(resource: "outside", name: "You", from: "Me").call
Fuck::Outside.new(name: "You", from: "Me").call
```

# Contributing
Expand Down
3 changes: 3 additions & 0 deletions lib/foaas.rb
Expand Up @@ -22,3 +22,6 @@
require_relative 'fuck/thing'
require_relative 'fuck/this'
require_relative 'fuck/you'
require_relative 'fuck/flying'
require_relative 'fuck/fascinating'
require_relative 'fuck/outside'
2 changes: 1 addition & 1 deletion lib/foaas/version.rb
@@ -1,3 +1,3 @@
module FOaaS
VERSION = "0.1.1"
VERSION = "0.1.2"
end
22 changes: 22 additions & 0 deletions lib/fuck/fascinating.rb
@@ -0,0 +1,22 @@
module Fuck
class Fascinating
include Salutations

# @param [Hash] options options to send FOaaS
# @option options [String] :name
# @option options [String] :from
# @example
# Fuck::Fascinating.new(from: "Me").call
# => <PayDirt::Result:0x9999eb4 @data= {
# "message"=>"Fascinating story, in what chapter do you shut the fuck up?",
# "subtitle"=>"- Me"
# }, @success=true>
def initialize(options = {})
options = {
resource: "fascinating",
}.merge(options)

load_options(:resource, :from, options)
end
end
end
22 changes: 22 additions & 0 deletions lib/fuck/flying.rb
@@ -0,0 +1,22 @@
module Fuck
class Flying
include Salutations

# @param [Hash] options options to send FOaaS
# @option options [String] :name
# @option options [String] :from
# @example
# Fuck::Flying.new(from: "Me").call
# => #<PayDirt::Result:0x99e132c @data= {
# "message"=>"I don't give a flying fuck.",
# "subtitle"=>"- Me"
# }, @success=true>
def initialize(options = {})
options = {
resource: "flying",
}.merge(options)

load_options(:resource, :from, options)
end
end
end
22 changes: 22 additions & 0 deletions lib/fuck/outside.rb
@@ -0,0 +1,22 @@
module Fuck
class Outside
include Salutations

# @param [Hash] options options to send FOaaS
# @option options [String] :name
# @option options [String] :from
# @example
# Fuck::Off.new(name: "You", from: "Me").call
# => #<PayDirt::Result:0x8a544f4 @data= {
# "message"=>"You, why don't you go outside and play hide-and-go-fuck-yourself?",
# "subtitle"=>"- Me"
# }, @success=true>
def initialize(options = {})
options = {
resource: "outside",
}.merge(options)

load_options(:resource, :name, :from, options)
end
end
end
28 changes: 28 additions & 0 deletions test/unit/fuck/fascinating_test.rb
@@ -0,0 +1,28 @@
require 'minitest_helper'

describe Fuck::Fascinating do
before do
@subject = Fuck::Fascinating
@params = {
from: SecureRandom.hex,
}
end

describe "as a class" do
it "initializes properly" do
@subject.new(@params).must_respond_to :execute!
end

it "errors when initialized without required dependencies" do
-> { @subject.new(@params.reject { |k| k.to_s == 'from' }) }.must_raise RuntimeError
end
end

describe "as an instance" do
it "executes successfully" do
result = @subject.new(@params).execute!
result.successful?.must_equal true
result.must_be_kind_of PayDirt::Result
end
end
end
28 changes: 28 additions & 0 deletions test/unit/fuck/flying_test.rb
@@ -0,0 +1,28 @@
require 'minitest_helper'

describe Fuck::Flying do
before do
@subject = Fuck::Flying
@params = {
from: SecureRandom.hex,
}
end

describe "as a class" do
it "initializes properly" do
@subject.new(@params).must_respond_to :execute!
end

it "errors when initialized without required dependencies" do
-> { @subject.new(@params.reject { |k| k.to_s == 'from' }) }.must_raise RuntimeError
end
end

describe "as an instance" do
it "executes successfully" do
result = @subject.new(@params).execute!
result.successful?.must_equal true
result.must_be_kind_of PayDirt::Result
end
end
end
30 changes: 30 additions & 0 deletions test/unit/fuck/outside_test.rb
@@ -0,0 +1,30 @@
require 'minitest_helper'

describe Fuck::Outside do
before do
@subject = Fuck::Outside
@params = {
name: SecureRandom.hex,
from: SecureRandom.hex,
}
end

describe "as a class" do
it "initializes properly" do
@subject.new(@params).must_respond_to :execute!
end

it "errors when initialized without required dependencies" do
-> { @subject.new(@params.reject { |k| k.to_s == 'name' }) }.must_raise RuntimeError
-> { @subject.new(@params.reject { |k| k.to_s == 'from' }) }.must_raise RuntimeError
end
end

describe "as an instance" do
it "executes successfully" do
result = @subject.new(@params).execute!
result.successful?.must_equal true
result.must_be_kind_of PayDirt::Result
end
end
end

0 comments on commit 78cc766

Please sign in to comment.