Skip to content
This repository

Response equals #16

Closed
wants to merge 2 commits into from

2 participants

Srushti Ambekallu Andrew Benton
Srushti Ambekallu

Implemented a trivial equals on response to help with testing.
Added test gem dependencies to the Gemfile.
(Also, ignored .rvmrc as you should for any gem you expect to run on more than one ruby.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
1  .gitignore
@@ -2,4 +2,5 @@
2 2 .*
3 3 pkg/*
4 4 doc/*
  5 +.rvmrc
5 6 Gemfile.lock
7 Gemfile
... ... @@ -1,3 +1,8 @@
1 1 source :rubygems
2 2
3   -gemspec
  3 +gemspec
  4 +
  5 +group :test do
  6 + gem 'rspec', '~> 2.6.0'
  7 + gem 'fakeweb', '~> 1.3.0'
  8 +end
8 lib/twilio-ruby/twiml/response.rb
... ... @@ -1,7 +1,6 @@
1 1 module Twilio
2 2 module TwiML
3 3 class Response
4   -
5 4 attr_reader :text
6 5
7 6 def initialize(&block)
@@ -10,6 +9,13 @@ def initialize(&block)
10 9 @text = xml.Response &block
11 10 end
12 11
  12 + def ==(other)
  13 + @text == other.text
  14 + end
  15 +
  16 + def eql(other)
  17 + self == other
  18 + end
13 19 end
14 20 end
15 21 end
15 test/twilio-ruby/twiml/response_test.rb
... ... @@ -0,0 +1,15 @@
  1 +require 'rubygems'
  2 +require 'twilio-ruby'
  3 +require 'fakeweb'
  4 +
  5 +describe Twilio::TwiML::Response do
  6 + it "equates two responses" do
  7 + (Twilio::TwiML::Response.new{|r| r.Say 'hello there'} == Twilio::TwiML::Response.new{|r| r.Say 'hello there'}).should be_true
  8 + (Twilio::TwiML::Response.new{|r| r.Say 'hello there'}.eql(Twilio::TwiML::Response.new{|r| r.Say 'hello there'})).should be_true
  9 + end
  10 +
  11 + it "identifies different responses" do
  12 + (Twilio::TwiML::Response.new{|r| r.Say 'hello there'} == Twilio::TwiML::Response.new{|r| r.Say 'goodbye'}).should be_false
  13 + (Twilio::TwiML::Response.new{|r| r.Say 'hello there'}.eql(Twilio::TwiML::Response.new{|r| r.Say 'goodbye'})).should be_false
  14 + end
  15 +end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.