Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

upgraded gem internals to use latest newgem (fewer dev files); added …

…Cucumber setup
  • Loading branch information...
commit 1e5852255429442f303047fa67c9a8201aa1bdd1 1 parent d938b09
@drnic authored
View
3  .gitignore
@@ -1,3 +1,4 @@
.DS_Store
pkg
-log
+log
+tmp
View
6 History.txt
@@ -1,3 +1,9 @@
+== 0.4.0 2009-03-17 NOT RELEASED
+
+* No more dependency issues between classes being tested: only one bundle created - all ObjC code being tested is compiled into one bundle
+* Upgrade internals to use latest newgem (removed bunch of dev-only files)
+* Behaviour of rbiphonetest covered by Cucumber scenarios
+
== 0.3.0 2008-07-05
* Support for test/unit AND rspec test frameworks (via install_test_unit and install_rspec generators)
View
20 License.txt
@@ -1,20 +0,0 @@
-Copyright (c) 2008 Dr Nic Williams
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
9 Manifest.txt
@@ -1,5 +1,4 @@
History.txt
-License.txt
Manifest.txt
PostInstall.txt
README.rdoc
@@ -10,8 +9,9 @@ app_generators/rbiphonetest/templates/Rakefile
app_generators/rbiphonetest/templates/dot_autotest
bin/iphoneruby
bin/rbiphonetest
-config/hoe.rb
-config/requirements.rb
+features/development.feature
+features/steps/common.rb
+features/steps/env.rb
lib/rbiphonetest.rb
lib/rbiphonetest/version.rb
rbiphonetest_generators/install_rspec/USAGE
@@ -41,9 +41,6 @@ script/destroy
script/generate
script/txt2html
setup.rb
-tasks/deployment.rake
-tasks/environment.rake
-tasks/website.rake
test/test_generator_helper.rb
test/test_helper.rb
test/test_install_rspec_generator.rb
View
2  README.rdoc
@@ -68,7 +68,7 @@ From source:
(The MIT License)
-Copyright (c) 2008 Dr Nic Williams
+Copyright (c) 2008-9 Dr Nic Williams
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
26 Rakefile
@@ -1,4 +1,24 @@
-require 'config/requirements'
-require 'config/hoe' # setup Hoe + all gem configuration
+%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
+require File.dirname(__FILE__) + '/lib/rbiphonetest'
-Dir['tasks/**/*.rake'].each { |rake| load rake }
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+$hoe = Hoe.new('rbiphonetest', RbIphoneTest::VERSION) do |p|
+ p.developer('Dr Nic Williams', 'drnicwilliams@gmail.com')
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+ p.post_install_message = 'PostInstall.txt'
+ p.extra_dev_deps = [
+ ['newgem', ">= #{::Newgem::VERSION}"]
+ ]
+
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
+ p.rsync_args = '-av --delete --ignore-errors'
+end
+
+require 'newgem/tasks' # load /tasks/*.rake
+Dir['tasks/**/*.rake'].each { |t| load t }
+
+# TODO - want other tests/tasks run by default? Add them to the list
+task :default => [:features]
View
2  app_generators/rbiphonetest/rbiphonetest_generator.rb
@@ -1,4 +1,4 @@
-class RbiphonetestGenerator < RubiGen::Base
+class RbIphoneTestGenerator < RubiGen::Base
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
Config::CONFIG['ruby_install_name'])
View
70 config/hoe.rb
@@ -1,70 +0,0 @@
-require 'rbiphonetest/version'
-
-AUTHOR = 'Dr Nic Williams'
-EMAIL = "drnicwilliams@gmail.com"
-DESCRIPTION = "Want to write iPhone unit tests? Want to write them in Ruby?"
-GEM_NAME = 'rbiphonetest' # what ppl will type to install your gem
-RUBYFORGE_PROJECT = 'rbiphonetest' # The unix name for your project
-HOMEPATH = "http://github.com/drnic/rbiphonetest"
-DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
-EXTRA_DEPENDENCIES = [
- ['rubigen', '>= 1.3.2']
-] # An array of rubygem dependencies [name, version]
-
-@config_file = "~/.rubyforge/user-config.yml"
-@config = nil
-RUBYFORGE_USERNAME = "unknown"
-def rubyforge_username
- unless @config
- begin
- @config = YAML.load(File.read(File.expand_path(@config_file)))
- rescue
- puts <<-EOS
-ERROR: No rubyforge config file found: #{@config_file}
-Run 'rubyforge setup' to prepare your env for access to Rubyforge
- - See http://newgem.rubyforge.org/rubyforge.html for more details
- EOS
- exit
- end
- end
- RUBYFORGE_USERNAME.replace @config["username"]
-end
-
-
-VERS = RbIphoneTest::VERSION::STRING
-RDOC_OPTS = ['--quiet', '--title', 'rbiphonetest documentation',
- "--opname", "index.html",
- "--line-numbers",
- "--main", "README",
- "--inline-source"]
-
-class Hoe
- def extra_deps
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
- @extra_deps
- end
-end
-
-# Generate all the Rake tasks
-# Run 'rake -T' to see list of generated tasks (from gem root directory)
-$hoe = Hoe.new(GEM_NAME, VERS) do |p|
- p.developer(AUTHOR, EMAIL)
- p.description = DESCRIPTION
- p.summary = DESCRIPTION
- p.url = HOMEPATH
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
- p.test_globs = ["test/**/test_*.rb"]
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
-
- # == Optional
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
- #p.extra_deps = EXTRA_DEPENDENCIES
-
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
- end
-
-CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
-PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
-$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
-$hoe.rsync_args = '-av --delete --ignore-errors'
-$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
View
15 config/requirements.rb
@@ -1,15 +0,0 @@
-require 'fileutils'
-include FileUtils
-
-require 'rubygems'
-%w[rake hoe newgem rubigen].each do |req_gem|
- begin
- require req_gem
- rescue LoadError
- puts "This Rakefile requires the '#{req_gem}' RubyGem."
- puts "Installation: gem install #{req_gem} -y"
- exit
- end
-end
-
-$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
View
13 features/development.feature
@@ -0,0 +1,13 @@
+Feature: Development processes of newgem itself (rake tasks)
+
+ As a Newgem maintainer or contributor
+ I want rake tasks to maintain and release the gem
+ So that I can spend time on the tests and code, and not excessive time on maintenance processes
+
+ Scenario: Generate RubyGem
+ Given this project is active project folder
+ And 'pkg' folder is deleted
+ When task 'rake gem' is invoked
+ Then folder 'pkg' is created
+ And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
+ And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
View
194 features/steps/common.rb
@@ -0,0 +1,194 @@
+def in_project_folder(&block)
+ project_folder = @active_project_folder || @tmp_root
+ FileUtils.chdir(project_folder, &block)
+end
+
+def in_home_folder(&block)
+ FileUtils.chdir(@home_path, &block)
+end
+
+Given %r{^a safe folder} do
+ FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
+ FileUtils.mkdir_p @tmp_root
+ FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
+ @lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
+ Given "env variable $HOME set to '#{@home_path}'"
+end
+
+Given %r{^this project is active project folder} do
+ Given "a safe folder"
+ @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
+end
+
+Given %r{^env variable \$([\w_]+) set to '(.*)'} do |env_var, value|
+ ENV[env_var] = value
+end
+
+def force_local_lib_override(project_name = @project_name)
+ rakefile = File.read(File.join(project_name, 'Rakefile'))
+ File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
+ f << "$:.unshift('#{@lib_path}')\n"
+ f << rakefile
+ end
+end
+
+def setup_active_project_folder project_name
+ @active_project_folder = File.join(@tmp_root, project_name)
+ @project_name = project_name
+end
+
+Given %r{'(.*)' folder is deleted} do |folder|
+ in_project_folder do
+ FileUtils.rm_rf folder
+ end
+end
+
+When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
+ @stdout = StringIO.new
+ FileUtils.chdir(@active_project_folder) do
+ if Object.const_defined?("APP_ROOT")
+ APP_ROOT.replace(FileUtils.pwd)
+ else
+ APP_ROOT = FileUtils.pwd
+ end
+ run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
+ end
+ File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
+ @stdout.rewind
+ f << @stdout.read
+ end
+end
+
+When %r{run executable '(.*)' with arguments '(.*)'} do |executable, arguments|
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
+ in_project_folder do
+ system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
+ end
+end
+
+When %r{run project executable '(.*)' with arguments '(.*)'} do |executable, arguments|
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
+ in_project_folder do
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
+ end
+end
+
+When %r{run local executable '(.*)' with arguments '(.*)'} do |executable, arguments|
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
+ in_project_folder do
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
+ end
+end
+
+When %r{^task 'rake (.*)' is invoked$} do |task|
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
+ FileUtils.chdir(@active_project_folder) do
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
+ end
+end
+
+Then %r{^folder '(.*)' (is|is not) created} do |folder, is|
+ in_project_folder do
+ File.exists?(folder).should(is == 'is' ? be_true : be_false)
+ end
+end
+
+Then %r{^file '(.*)' (is|is not) created} do |file, is|
+ in_project_folder do
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
+ end
+end
+
+Then %r{^file with name matching '(.*)' is created} do |pattern|
+ in_project_folder do
+ Dir[pattern].should_not be_empty
+ end
+end
+
+Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file|
+ File.exists?(gem_file).should be_true
+ File.exists?(project_file).should be_true
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
+ project_file_contents.should == gem_file_contents
+end
+
+Then %r{^output same as contents of '(.*)'$} do |file|
+ expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
+ actual_output = File.read(@stdout)
+ actual_output.should == expected_output
+end
+
+Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
+ actual_output = File.read(@stdout)
+ does_invoke == "does" ?
+ actual_output.should(match(/dependency\s+#{generator}/)) :
+ actual_output.should_not(match(/dependency\s+#{generator}/))
+end
+
+Then %r{help options '(.*)' and '(.*)' are displayed} do |opt1, opt2|
+ actual_output = File.read(@stdout)
+ actual_output.should match(/#{opt1}/)
+ actual_output.should match(/#{opt2}/)
+end
+
+Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
+ actual_output = File.read(@stdout)
+ (does == 'does') ?
+ actual_output.should(match(/#{regex}/)) :
+ actual_output.should_not(match(/#{regex}/))
+end
+
+Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
+ in_project_folder do
+ actual_output = File.read(file)
+ (does == 'does') ?
+ actual_output.should(match(/#{regex}/)) :
+ actual_output.should_not(match(/#{regex}/))
+ end
+end
+
+Then %r{^all (\d+) tests pass} do |expected_test_count|
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
+ actual_output = File.read(@stdout)
+ actual_output.should match(expected)
+end
+
+Then %r{^all (\d+) examples pass} do |expected_test_count|
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
+ actual_output = File.read(@stdout)
+ actual_output.should match(expected)
+end
+
+Then %r{^yaml file '(.*)' contains (\{.*\})} do |file, yaml|
+ in_project_folder do
+ yaml = eval yaml
+ YAML.load(File.read(file)).should == yaml
+ end
+end
+
+Then %r{^Rakefile can display tasks successfully} do
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
+ FileUtils.chdir(@active_project_folder) do
+ system "rake -T > #{@stdout} 2> #{@stdout}"
+ end
+ actual_output = File.read(@stdout)
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
+end
+
+Then %r{^task 'rake (.*)' is executed successfully} do |task|
+ @stdout.should_not be_nil
+ actual_output = File.read(@stdout)
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
+ actual_output.should_not match(/Error/i)
+end
+
+Then %r{^gem spec key '(.*)' contains \/(.*)\/} do |key, regex|
+ in_project_folder do
+ gem_file = Dir["pkg/*.gem"].first
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
+ spec_value = gem_spec.send(key.to_sym)
+ spec_value.to_s.should match(/#{regex}/)
+ end
+end
View
6 features/steps/env.rb
@@ -0,0 +1,6 @@
+require File.dirname(__FILE__) + "/../../lib/rbiphonetest"
+
+gem 'cucumber'
+require 'cucumber'
+gem 'rspec'
+require 'spec'
View
2  lib/rbiphonetest.rb
@@ -2,5 +2,5 @@
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
module RbIphoneTest
-
+ VERSION = '0.4.0'
end
View
34 tasks/deployment.rake
@@ -1,34 +0,0 @@
-desc 'Release the website and new gem version'
-task :deploy => [:check_version, :website, :release] do
- puts "Remember to create SVN tag:"
- puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
- "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
- puts "Suggested comment:"
- puts "Tagging release #{CHANGES}"
-end
-
-desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
-task :local_deploy => [:website_generate, :install_gem]
-
-task :check_version do
- unless ENV['VERSION']
- puts 'Must pass a VERSION=x.y.z release version'
- exit
- end
- unless ENV['VERSION'] == VERS
- puts "Please update your version.rb to match the release version, currently #{VERS}"
- exit
- end
-end
-
-desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
-task :install_gem_no_doc => [:clean, :package] do
- sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
-end
-
-namespace :manifest do
- desc 'Recreate Manifest.txt to include ALL files'
- task :refresh do
- `rake check_manifest | patch -p0 > Manifest.txt`
- end
-end
View
7 tasks/environment.rake
@@ -1,7 +0,0 @@
-task :ruby_env do
- RUBY_APP = if RUBY_PLATFORM =~ /java/
- "jruby"
- else
- "ruby"
- end unless defined? RUBY_APP
-end
View
17 tasks/website.rake
@@ -1,17 +0,0 @@
-desc 'Generate website files'
-task :website_generate => :ruby_env do
- (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
- sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
- end
-end
-
-desc 'Upload website files to rubyforge'
-task :website_upload do
- host = "#{rubyforge_username}@rubyforge.org"
- remote_dir = "/var/www/gforge-projects/#{PATH}/"
- local_dir = 'website'
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
-end
-
-desc 'Generate and upload website files'
-task :website => [:website_generate, :website_upload, :publish_docs]
Please sign in to comment.
Something went wrong with that request. Please try again.