Permalink
Browse files

Idea of how to test the interactivity

  • Loading branch information...
1 parent 7c95973 commit 9d1695d3bd6687623cfe4813c724081498cfa0fc @bjeanes committed Sep 6, 2009
Showing with 21 additions and 7 deletions.
  1. +1 −1 lib/matrimony.rb
  2. +14 −2 spec/matrimony_spec.rb
  3. +6 −4 spec/spec_helper.rb
View
@@ -1,7 +1,7 @@
module Matrimony
class << self
def run(*args)
- "This is your first run!"
+ puts "This is your first run!"
end
end
end
View
@@ -1,9 +1,21 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-describe "Matrimony" do
+describe Matrimony do
describe "on first run" do
it "should ask for development email address" do
- matrimony.should =~ /This is your first run/
+ open('|-') do |command|
+ if sub.nil?
+ Matrimony.run # What the gem executable calls
+ else
+ command.gets.should =~ /This is your first run/
+ end
+ end
end
end
+
+ describe "after configuration" do
+ matrimony_configured_with 'dev@mocra.com'
+
+ # ...
+ end
end
View
@@ -4,11 +4,13 @@
require 'spec'
require 'spec/autorun'
-%w(matrimony_command git_helper).each do |helper|
- require "spec_helpers/#{helper}"
-end
+# Interesting reads
+# http://devver.net/blog/2009/08/unit-testing-filesystem-interaction/
+# http://devver.net/blog/2009/07/a-dozen-or-so-ways-to-start-sub-processes-in-ruby-part-2/
+# http://devver.net/blog/2009/07/a-command-line-prompt-with-timeout-and-countdown/
SPEC_ROOT = File.dirname(__FILE__)
+Dir["#{SPEC_ROOT}/spec_helpers/*"].each { |helper| require helper }
Spec::Runner.configure do |config|
config.include MatrimonyCommand
@@ -25,4 +27,4 @@
Dir.chdir(SPEC_ROOT)
`rm -rf fixture_repo`
end
-end
+end

0 comments on commit 9d1695d

Please sign in to comment.