Skip to content

Commit

Permalink
Add RSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
justinko committed Oct 3, 2010
1 parent 6ae8a74 commit 3d220c6
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 54 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1 +1,4 @@
.bundle
.DS_Store
.rvmrc
*.gem
2 changes: 2 additions & 0 deletions Gemfile
@@ -0,0 +1,2 @@
source :rubygems
gemspec
51 changes: 51 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,51 @@
PATH
remote: .
specs:
relish (0.0.1)

GEM
remote: http://rubygems.org/
specs:
archive-tar-minitar (0.5.2)
aruba (0.2.2)
builder (2.1.2)
cucumber (0.8.5)
builder (~> 2.1.2)
diff-lcs (~> 1.1.2)
gherkin (~> 2.1.4)
json_pure (~> 1.4.3)
term-ansicolor (~> 1.0.4)
diff-lcs (1.1.2)
gherkin (2.1.5)
trollop (~> 1.16.2)
json_pure (1.4.6)
mime-types (1.16)
rake (0.8.7)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
rspec-mocks (= 2.0.0.beta.22)
rspec-core (2.0.0.beta.22)
rspec-expectations (2.0.0.beta.22)
diff-lcs (>= 1.1.2)
rspec-mocks (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
term-ansicolor (1.0.5)
trollop (1.16.2)

PLATFORMS
ruby

DEPENDENCIES
archive-tar-minitar (~> 0.5.2)
aruba (~> 0.2.1)
bundler (~> 1.0.0)
cucumber (~> 0.8.5)
rake (~> 0.8.7)
relish!
rest-client (~> 1.6.1)
rspec (~> 2.0.0.beta.22)
trollop (~> 1.16.2)
8 changes: 8 additions & 0 deletions Rakefile
@@ -0,0 +1,8 @@
require 'bundler'
require 'bundler/setup'
Bundler::GemHelper.install_tasks

require 'rake'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)
2 changes: 2 additions & 0 deletions lib/relish.rb
@@ -0,0 +1,2 @@
require 'relish/helpers'
require 'relish/command'
5 changes: 2 additions & 3 deletions lib/relish/cli/options.rb
@@ -1,11 +1,10 @@
require 'rubygems'
require 'trollop'
require 'relish/commands/push_command'
require 'relish/commands/push'

module Relish
module Cli
class OptionsParser < Trollop::Parser
COMMANDS = { 'push' => Commands::PushCommand }
COMMANDS = { 'push' => Commands::Push }

def initialize(error_stream, out_stream)
super
Expand Down
2 changes: 2 additions & 0 deletions lib/relish/command.rb
@@ -0,0 +1,2 @@
require 'relish/commands/base'
require 'relish/commands/push'
12 changes: 12 additions & 0 deletions lib/relish/commands/base.rb
@@ -0,0 +1,12 @@
module Relish
module Command
class Base
include Relish::Helpers

def api_token
File.read("#{home_directory}/.relish/api_token")
end

end
end
end
Expand Up @@ -4,8 +4,9 @@
require 'rest_client'

module Relish
module Commands
class PushCommand
module Command
class Push < Base

def initialize(global_options)
@options = global_options
end
Expand Down Expand Up @@ -39,10 +40,6 @@ def url
end
end

def api_token
File.read("#{home_directory}/.relish/api_token")
end

def features_as_tar_gz
stream = StringIO.new

Expand All @@ -64,17 +61,6 @@ def files
Dir['features/**/*.{feature,md}']
end

def home_directory
running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME']
end

def running_on_windows?
RUBY_PLATFORM =~ /mswin32|mingw32/
end

def running_on_a_mac?
RUBY_PLATFORM =~ /-darwin\d/
end
end
end
end
15 changes: 15 additions & 0 deletions lib/relish/helpers.rb
@@ -0,0 +1,15 @@
module Relish
module Helpers
def home_directory
running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME']
end

def running_on_windows?
RUBY_PLATFORM =~ /mswin32|mingw32/
end

def running_on_a_mac?
RUBY_PLATFORM =~ /-darwin\d/
end
end
end
52 changes: 18 additions & 34 deletions relish.gemspec
Expand Up @@ -2,47 +2,31 @@ Gem::Specification.new do |s|
s.name = "relish"
s.version = "0.0.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.required_rubygems_version = '>= 1.3.5'
s.authors = ["Matt Patterson", "Matt Wynne", "Justin Ko"]
s.date = "2010-09-23"
s.description = %q{Client gem for http://relishapp.com}
s.email = "matt@reprocessed.org"
s.extra_rdoc_files = [
"LICENSE",
"README.md"
]
s.files = Dir.glob([
"VERSION",
"README.md",
"LICENSE",
"Rakefile",
"lib/**/*.rb",
])
s.email = "jko170@gmail.com"

s.homepage = "http://relishapp.com"
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = "1.3.6"
s.summary = %q{Client gem for http://relishapp.com}
s.test_files = Dir.glob([
"spec/spec.opts",
"spec/**/*.rb",
"features/**/*.rb",
"features/**/*.feature"
])

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
s.add_development_dependency(%q<cucumber>, [">= 0.5"])
else
s.add_dependency(%q<rspec>, [">= 1.2.9"])
s.add_dependency(%q<cucumber>, [">= 0.5"])
end
else
s.add_dependency(%q<rspec>, [">= 1.2.9"])
s.add_dependency(%q<cucumber>, [">= 0.5"])
s.require_path = "lib"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")

{
'bundler' => '~> 1.0.0',
'rake' => '~> 0.8.7',
'archive-tar-minitar' => '~> 0.5.2',
'rest-client' => '~> 1.6.1',
'trollop' => '~> 1.16.2',
'rspec' => '~> 2.0.0.beta.22',
'cucumber' => '~> 0.8.5',
'aruba' => '~> 0.2.1'
}.each do |lib, version|
s.add_development_dependency lib, version
end
end
19 changes: 19 additions & 0 deletions spec/relish/commands/base_spec.rb
@@ -0,0 +1,19 @@
require 'spec_helper'

module Relish
module Command
describe Base do

describe '#api_token' do
let(:base) { described_class.new }

it 'calls File.read with the correct path' do
base.should_receive(:home_directory).and_return('~')
File.should_receive(:read).with('~/.relish/api_token')
base.api_token
end
end

end
end
end
8 changes: 8 additions & 0 deletions spec/relish/commands/push_spec.rb
@@ -0,0 +1,8 @@
require 'spec_helper'

module Relish
module Command
describe Push do
end
end
end
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,9 @@
require 'rubygems'
require 'bundler'
Bundler.setup

require 'relish'

RSpec.configure do |config|
config.color_enabled = true
end

0 comments on commit 3d220c6

Please sign in to comment.