Permalink
Browse files

Fix dependencies

UUIDTools needs to be a dependency.
  • Loading branch information...
1 parent 5371146 commit c788d2d9928841bfc6d60af1e83f334a89fd58ee @JMongol committed Sep 17, 2012
Showing with 71 additions and 68 deletions.
  1. +0 −11 Gemfile
  2. +2 −2 Gemfile.lock
  3. +27 −1 README.md
  4. +1 −0 lib/twilio-test-toolkit.rb
  5. +36 −35 lib/twilio-test-toolkit/call_in_progress.rb
  6. +0 −15 spec/test_helper.rb
  7. +5 −4 twilio-test-toolkit.gemspec
View
11 Gemfile
@@ -4,14 +4,3 @@ source "http://rubygems.org"
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
-
-# jquery-rails is used by the dummy application
-gem "jquery-rails"
-
-# Declare any dependencies that are still in development here instead of in
-# your gemspec. These might include edge Rails or gems from your path or
-# Git. Remember to move these dependencies to your gemspec before releasing
-# your gem to rubygems.org.
-
-# To use debugger
-# gem 'debugger'
View
@@ -2,7 +2,8 @@ PATH
remote: .
specs:
twilio-test-toolkit (1.0.0)
- capybara (~> 1.0)
+ capybara
+ uuidtools
GEM
remote: http://rubygems.org/
@@ -138,4 +139,3 @@ DEPENDENCIES
sqlite3
sqlite3-ruby
twilio-test-toolkit!
- uuidtools
View
@@ -47,14 +47,40 @@ TTT doesn't yet support (but you should contribute them!)
What's required
================
-TTT depends on [Capybara](https://github.com/jnicklas/capybara). It uses Capybara's session object to POST requests to your controllers, so get Capybara set up before you use TTT. Because of this, your TTT tests should normally go in spec/requests, unless you've relocated these tests elsewhere.
+TTT depends on [Capybara](https://github.com/jnicklas/capybara). It uses Capybara's session object to POST requests to your controllers.
TTT expects your controller actions to behave like well-behaved Twilio callbacks. That is, you need to respond to XML-formatted requests, and need to respond with a 200 OK. TTT also requires that your controller actions be wired for POST, not GET (Twilio does support GET, but TTT lacks this support). Twilio will not follow 301 or 302 redirects properly, and neither will TTT (see below for more details).
TTT has only been tested with RSpec on Rails. It might work on other test frameworks or other Rack-based frameworks. Feel free to submit pull requests to improve compatibility with these.
If it works with Twilio, it should work with TTT. If not, open an issue/pull request.
+Getting started
+================
+
+First, get RSpec and Capybara working for your project. Then, you'll need to add this to your gemfile:
+
+ group :test do
+ ...
+ gem 'twilio-test-toolkit'
+ ...
+ end
+
+Since TTT is test-only code, it should be in the :test group.
+
+You'll have to make one more change in spec/spec_helper.rb:
+
+ RSpec.configure do |config|
+ ...
+ # Configure Twilio Test Toolkit
+ config.include TwilioTestToolkit::DSL, :type => :request
+ ...
+ end
+
+This line is required in order to get TTT's DSL to work with your tests.
+
+Finally, since TTT deals with integration tests, you should write your tests in spec/requests (or whatever directory you've configured for this type of test).
+
How to use
================
@@ -1,3 +1,4 @@
module TwilioTestToolkit
+ require "uuidtools"
require 'twilio-test-toolkit/dsl'
end
@@ -1,47 +1,48 @@
require "twilio-test-toolkit/call_scope"
-require "UUIDTools"
-# Models a call
-class TwilioTestToolkit::CallInProgress < TwilioTestToolkit::CallScope
- # Init the call
- def initialize(initial_path, from_number, to_number, call_sid, is_machine)
- # Save our variables for later
- @initial_path = initial_path
- @from_number = from_number
- @to_number = to_number
- @is_machine = is_machine
+module TwilioTestToolkit
+ # Models a call
+ class CallInProgress < CallScope
+ # Init the call
+ def initialize(initial_path, from_number, to_number, call_sid, is_machine)
+ # Save our variables for later
+ @initial_path = initial_path
+ @from_number = from_number
+ @to_number = to_number
+ @is_machine = is_machine
- # Generate an initial call SID if we don't have one
- if (call_sid.nil?)
- @sid = UUIDTools::UUID.random_create.to_s
- else
- @sid = call_sid
- end
+ # Generate an initial call SID if we don't have one
+ if (call_sid.nil?)
+ @sid = UUIDTools::UUID.random_create.to_s
+ else
+ @sid = call_sid
+ end
- # We are the root call
- self.root_call = self
+ # We are the root call
+ self.root_call = self
- # Create the request
- post_for_twiml!(@initial_path, "", @is_machine)
- end
+ # Create the request
+ post_for_twiml!(@initial_path, "", @is_machine)
+ end
- def sid
- @sid
- end
+ def sid
+ @sid
+ end
- def initial_path
- @initial_path
- end
+ def initial_path
+ @initial_path
+ end
- def from_number
- @from_number
- end
+ def from_number
+ @from_number
+ end
- def to_number
- @to_number
- end
+ def to_number
+ @to_number
+ end
- def is_machine
- @is_machine
+ def is_machine
+ @is_machine
+ end
end
end
View
@@ -1,15 +0,0 @@
-# Configure Rails Environment
-ENV["RAILS_ENV"] = "test"
-
-require File.expand_path("../dummy/config/environment.rb", __FILE__)
-require "rails/test_help"
-
-Rails.backtrace_cleaner.remove_silencers!
-
-# Load support files
-Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
-
-# Load fixtures from the engine
-if ActiveSupport::TestCase.method_defined?(:fixture_path=)
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
-end
@@ -15,18 +15,19 @@ Gem::Specification.new do |s|
s.licenses = ["MIT"]
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
- s.test_files = Dir["test/**/*"]
+ s.test_files = Dir["spec/**/*"]
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency 'capybara', '~> 1.0'
+ s.add_dependency 'capybara'
+ s.add_dependency 'uuidtools'
s.add_development_dependency "rails", "~> 3.2.8"
s.add_development_dependency "sqlite3"
s.add_development_dependency "sqlite3-ruby"
s.add_development_dependency "rspec"
- s.add_development_dependency "rspec-rails"
- s.add_development_dependency "uuidtools"
+ s.add_development_dependency "rspec-rails"
+ s.add_development_dependency "jquery-rails"
end

0 comments on commit c788d2d

Please sign in to comment.