Skip to content
Browse files

Add RSpec

  • Loading branch information...
1 parent 6ae8a74 commit 3d220c65314416a30d34e1ba4ab1ad64ce3fc63c @justinko justinko committed Oct 2, 2010
View
3 .gitignore
@@ -1 +1,4 @@
+.bundle
+.DS_Store
+.rvmrc
*.gem
View
2 Gemfile
@@ -0,0 +1,2 @@
+source :rubygems
+gemspec
View
51 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)
View
8 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)
View
2 lib/relish.rb
@@ -0,0 +1,2 @@
+require 'relish/helpers'
+require 'relish/command'
View
5 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
View
2 lib/relish/command.rb
@@ -0,0 +1,2 @@
+require 'relish/commands/base'
+require 'relish/commands/push'
View
12 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
View
20 lib/relish/commands/push_command.rb → lib/relish/commands/push.rb
@@ -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
@@ -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
@@ -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
View
15 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
View
52 relish.gemspec
@@ -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
View
19 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
View
8 spec/relish/commands/push_spec.rb
@@ -0,0 +1,8 @@
+require 'spec_helper'
+
+module Relish
+ module Command
+ describe Push do
+ end
+ end
+end
View
9 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.
Something went wrong with that request. Please try again.