From 78cc766669be26f2ead5c0b81a342d6b203352ee Mon Sep 17 00:00:00 2001 From: "Ryan T. Hosford" Date: Mon, 19 Aug 2013 16:51:03 -0500 Subject: [PATCH] Adds new libraries and test - Adds support for endpoints "fascinating", "flying", and "outside" --- README.md | 16 ++++++++++------ lib/foaas.rb | 3 +++ lib/foaas/version.rb | 2 +- lib/fuck/fascinating.rb | 22 ++++++++++++++++++++++ lib/fuck/flying.rb | 22 ++++++++++++++++++++++ lib/fuck/outside.rb | 22 ++++++++++++++++++++++ test/unit/fuck/fascinating_test.rb | 28 ++++++++++++++++++++++++++++ test/unit/fuck/flying_test.rb | 28 ++++++++++++++++++++++++++++ test/unit/fuck/outside_test.rb | 30 ++++++++++++++++++++++++++++++ 9 files changed, 166 insertions(+), 7 deletions(-) create mode 100644 lib/fuck/fascinating.rb create mode 100644 lib/fuck/flying.rb create mode 100644 lib/fuck/outside.rb create mode 100644 test/unit/fuck/fascinating_test.rb create mode 100644 test/unit/fuck/flying_test.rb create mode 100644 test/unit/fuck/outside_test.rb diff --git a/README.md b/README.md index 4e7ef21..7ea8d2e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/foaas.rb b/lib/foaas.rb index 7f24d11..e259ae7 100644 --- a/lib/foaas.rb +++ b/lib/foaas.rb @@ -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' diff --git a/lib/foaas/version.rb b/lib/foaas/version.rb index a9e60c0..096b2d1 100644 --- a/lib/foaas/version.rb +++ b/lib/foaas/version.rb @@ -1,3 +1,3 @@ module FOaaS - VERSION = "0.1.1" + VERSION = "0.1.2" end diff --git a/lib/fuck/fascinating.rb b/lib/fuck/fascinating.rb new file mode 100644 index 0000000..e1131ed --- /dev/null +++ b/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 + # => "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 diff --git a/lib/fuck/flying.rb b/lib/fuck/flying.rb new file mode 100644 index 0000000..d0a18cf --- /dev/null +++ b/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 + # => #"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 diff --git a/lib/fuck/outside.rb b/lib/fuck/outside.rb new file mode 100644 index 0000000..16d7701 --- /dev/null +++ b/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 + # => #"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 diff --git a/test/unit/fuck/fascinating_test.rb b/test/unit/fuck/fascinating_test.rb new file mode 100644 index 0000000..0395bcb --- /dev/null +++ b/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 diff --git a/test/unit/fuck/flying_test.rb b/test/unit/fuck/flying_test.rb new file mode 100644 index 0000000..a335ab4 --- /dev/null +++ b/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 diff --git a/test/unit/fuck/outside_test.rb b/test/unit/fuck/outside_test.rb new file mode 100644 index 0000000..ea31b63 --- /dev/null +++ b/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