Skip to content
Browse files

Installer semi-working..

  • Loading branch information...
1 parent 88021b1 commit 3c767aff01c885df2373d04a41e63dd0c5773f7a @aantix committed Dec 17, 2012
View
86 .gitignore
@@ -1,7 +1,79 @@
-.bundle/
-log/*.log
-pkg/
-test/dummy/db/*.sqlite3
-test/dummy/log/*.log
-test/dummy/tmp/
-test/dummy/.sass-cache
+#----------------------------------------------------------------------------
+# Ignore these files when commiting to a git repository.
+#
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# The original version of this file is found here:
+# https://github.com/RailsApps/rails3-application-templates/raw/master/files/gitignore.txt
+#
+# Corrections? Improvements? Create a GitHub issue:
+# http://github.com/RailsApps/rails3-application-templates/issues
+#----------------------------------------------------------------------------
+
+# bundler state
+/.bundle
+/vendor/bundle/
+
+# minimal Rails specific artifacts
+db/*.sqlite3
+/log/*
+/tmp/*
+
+config/initializers/
+db/
+
+# various artifacts
+**.war
+*.rbc
+*.sassc
+.rspec
+.redcar/
+.sass-cache
+/config/config.yml
+/config/database.yml
+/coverage.data
+/coverage/
+/db/*.javadb/
+/db/*.sqlite3
+/doc/api/
+/doc/app/
+/doc/features.html
+/doc/specs.html
+/public/cache
+/public/stylesheets/compiled
+/public/system/*
+/spec/tmp/*
+/cache
+/capybara*
+/capybara-*.html
+/gems
+/spec/requests
+/spec/routing
+/spec/views
+/specifications
+rerun.txt
+pickle-email-*.html
+
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+#
+# Here are some files you may want to ignore globally:
+
+# scm revert files
+**.orig
+
+# Mac finder artifacts
+.DS_Store
+
+# Netbeans project directory
+/nbproject/
+
+# RubyMine project files
+.idea
+
+# Textmate project files
+/*.tmproj
+
+# vim artifacts
+**.swp
View
53 .rvmrc
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+
+# This is an RVM Project .rvmrc file, used to automatically load the ruby
+# development environment upon cd'ing into the directory
+
+# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
+environment_id="ruby-1.9.3-p327@udd"
+
+#
+# Uncomment following line if you want options to be set only for given project.
+#
+# PROJECT_JRUBY_OPTS=( --1.9 )
+
+#
+# First we attempt to load the desired environment directly from the environment
+# file. This is very fast and efficient compared to running through the entire
+# CLI and selector. If you want feedback on which environment was used then
+# insert the word 'use' after --create as this triggers verbose mode.
+#
+if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
+then
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
+
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
+ then
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
+ fi
+else
+ # If the environment file has not yet been created, use the RVM CLI to select.
+ if ! rvm --create "$environment_id"
+ then
+ echo "Failed to create RVM environment '${environment_id}'."
+ return 1
+ fi
+fi
+
+#
+# If you use an RVM gemset file to install a list of gems (*.gems), you can have
+# it be automatically loaded. Uncomment the following and adjust the filename if
+# necessary.
+#
+# filename=".gems"
+# if [[ -s "$filename" ]]
+# then
+# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
+# fi
+
+# If you use bundler, this might be useful to you:
+# if command -v bundle && [[ -s Gemfile ]]
+# then
+# bundle install
+# fi
View
32 Gemfile.lock
@@ -2,8 +2,8 @@ PATH
remote: .
specs:
udd: User Driven Development (0.0.1)
- easyprompt
rails (~> 3.2.9)
+ turkee
GEM
remote: http://rubygems.org/
@@ -46,24 +46,26 @@ GEM
englishext (0.1.2)
erubis (2.7.0)
extensions (0.6.0)
- factory_girl (2.6.4)
- activesupport (>= 2.3.9)
+ factory_girl (4.1.0)
+ activesupport (>= 3.0.0)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.5)
+ lockfile (2.1.0)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.19)
- mocha (0.13.0)
+ mocha (0.13.1)
metaclass (~> 0.0.1)
multi_json (1.5.0)
+ nokogiri (1.5.5)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -90,14 +92,26 @@ GEM
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
- rspec-core (2.12.1)
- rspec-expectations (2.12.0)
+ rspec-core (2.12.2)
+ rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.0)
+ rspec-rails (2.12.0)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec-core (~> 2.12.0)
+ rspec-expectations (~> 2.12.0)
+ rspec-mocks (~> 2.12.0)
+ rturk (2.10.1)
+ nokogiri (>= 1.4.1)
+ rest-client (>= 1.4.0)
spork (0.9.2)
sprockets (2.2.2)
hike (~> 1.2)
@@ -110,16 +124,22 @@ GEM
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
+ turkee (1.2.1)
+ lockfile
+ rails (>= 3.1.1)
+ rturk (>= 2.4.0)
tzinfo (0.3.35)
PLATFORMS
ruby
DEPENDENCIES
+ easyprompt
factory_girl (>= 1.3.2)
jquery-rails
mocha
rspec (>= 2.5.0)
+ rspec-rails
spork
sqlite3
udd: User Driven Development!
View
31 Rakefile
@@ -4,37 +4,14 @@ begin
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
-begin
- require 'rdoc/task'
-rescue LoadError
- require 'rdoc/rdoc'
- require 'rake/rdoctask'
- RDoc::Task = Rake::RDocTask
-end
-
-RDoc::Task.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'Udd'
- rdoc.options << '--line-numbers'
- rdoc.rdoc_files.include('README.rdoc')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
-
-APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
-load 'rails/tasks/engine.rake'
-
-
Bundler::GemHelper.install_tasks
require 'rake/testtask'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = false
+task :install do
+ installer = Udd::InstallGenerator.new
+ installer.install
end
-
-task :default => :test
+task :default => :spec
View
10 lib/generators/install_generator.rb → lib/generators/udd/install_generator.rb
@@ -1,22 +1,14 @@
require 'tasks/turkee'
require 'rails/generators'
-require File.expand_path('../utils', __FILE__)
-
-# http://guides.rubyonrails.org/generators.html
-# http://rdoc.info/github/wycats/thor/master/Thor/Actions.html
-# keep generator idempotent, thanks
-# Thanks to https://github.com/sferik/rails_admin !
module Udd
class InstallGenerator < Rails::Generators::Base
-
source_root File.expand_path("../templates", __FILE__)
include Rails::Generators::Migration
def install
template "udd.yml", "config/udd.yml"
-
- Rake::Task['turkee'].invoke
+ generate "turkee", "skip"
end
end
end
View
14 lib/generators/udd/templates/udd.yml
@@ -0,0 +1,14 @@
+feedback:
+ test1:
+ title: Requesting feedback for my website.
+ description: Look over this page and give me your initial five second impression.
+ reward: 0.05
+ path: welcome_path
+
+
+ab_testing:
+ test1:
+ title: Help me test my site.
+ description: Looking at this page, click on the link that is best action....
+ reward: 0.05
+ path: welcome_path
View
7 lib/udd/engine.rb
@@ -1,5 +1,12 @@
module Udd
class Engine < ::Rails::Engine
isolate_namespace Udd
+
+ config.generators do |g|
+ g.test_framework :rspec, :fixture => false
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
+ g.assets false
+ g.helper false
+ end
end
end
View
32 spec/generators/install_generator_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper'
+require 'fileutils'
+
+describe Udd::InstallGenerator do
+
+ describe "#install" do
+ before do
+ @config = File.expand_path("../../../config", __FILE__)
+ @db = File.expand_path("../../../db/migrate", __FILE__)
+ @installer = Udd::InstallGenerator.new
+
+ # Cleanup the installed migrations from the dummy app
+ FileUtils.rm(Dir.glob("#{@db}/*.rb"), :force => true)
+ FileUtils.rm("#{@config}/initializers/turkee.rb", :force => true)
+ FileUtils.rm("#{@config}/udd.yml", :force => true)
+ end
+
+ after do
+ # Cleanup the installed migrations from the dummy app
+ FileUtils.rm(Dir.glob("#{@db}/*.rb"))
+ FileUtils.rm("#{@config}/initializers/turkee.rb")
+ FileUtils.rm("#{@config}/udd.yml")
+ end
+
+ it "copies over the config file" do
+ puts "config = #{@config}"
+ File.exists?("#{@config}/udd.yml}").should be_false
+ @installer.install
+ File.exists?("#{@config}/udd.yml}").should be_true
+ end
+ end
+end
View
108 spec/spec_helper.rb
@@ -1,38 +1,72 @@
-# This file is copied to spec/ when you run 'rails generate rspec:install'
-ENV["RAILS_ENV"] ||= 'test'
-require File.expand_path("../../config/environment", __FILE__)
-require 'rspec/rails'
-require 'rspec/autorun'
-
-# Requires supporting ruby files with custom matchers and macros, etc,
-# in spec/support/ and its subdirectories.
-Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
-
-RSpec.configure do |config|
- # ## Mock Framework
- #
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
- #
- # config.mock_with :mocha
- # config.mock_with :flexmock
- # config.mock_with :rr
-
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = true
-
- # If true, the base class of anonymous controllers will be inferred
- # automatically. This will be the default behavior in future versions of
- # rspec-rails.
- config.infer_base_class_for_anonymous_controllers = false
-
- # Run specs in random order to surface order dependencies. If you find an
- # order dependency and want to debug it, you can fix the order by providing
- # the seed, which is printed after each run.
- # --seed 1234
- config.order = "random"
+require "bundler/setup"
+
+require 'factory_girl'
+require 'rspec'
+require 'spork'
+require 'rails'
+require 'turkee'
+require 'active_record'
+require 'rake'
+
+
+require File.expand_path("../dummy/config/environment.rb", __FILE__)
+
+ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
+ActiveRecord::Schema.define(:version => 1) do
+ create_table :turkee_tasks do |t|
+ t.string "hit_url"
+ t.boolean "sandbox"
+ t.string "task_type"
+ t.text "hit_title"
+ t.text "hit_description"
+ t.string "hit_id"
+ t.decimal "hit_reward", :precision => 10, :scale => 2
+ t.integer "hit_num_assignments"
+ t.integer "hit_lifetime"
+ t.string "form_url"
+ t.integer "completed_assignments", :default => 0
+ t.boolean "complete"
+ t.boolean "expired"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.integer "turkee_flow_id"
+ t.integer "hit_duration"
+ end
+
+ create_table :surveys do |t|
+ t.string :answer
+ end
+end
+
+
+Spork.prefork do
+ # Loading more in this block will cause your tests to run faster. However,
+ # if you change any configuration or code from libraries loaded here, you'll
+ # need to restart spork for it take effect.
+
+ FactoryGirl.find_definitions
+
+ RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ #config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, comment the following line or assign false
+ # instead of true.
+ #config.use_transactional_fixtures = true
+ end
+
end
+
+Spork.each_run do
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
+ Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| require f}
+end
View
4 udd.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.description = "User Driven Development. Perform usability testing, A/B testing and solicit feedback with ACTUAL HUMANS quickly using Mechanical Turk."
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
- s.test_files = Dir["test/**/*"]
+ s.test_files = Dir["spec/**/*"]
s.add_dependency "rails", "~> 3.2.9"
s.add_dependency "turkee"
@@ -28,5 +28,7 @@ Gem::Specification.new do |s|
# RSpec has to be in both test and development so that rake tasks and generators
# are available without having to explicitly switch the environment to 'test'
s.add_development_dependency 'factory_girl', '>= 1.3.2'
+ s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'rspec', '>= 2.5.0'
+
end

0 comments on commit 3c767af

Please sign in to comment.
Something went wrong with that request. Please try again.