<commit_before>ENV["RACK_ENV"] = "test"
require File.dirname(__FILE__) + "/../app"
require "rack/test"
require "nokogiri"

describe "Twilio" do
  include Rack::Test::Methods

  def app
    CopperNet.new!
  end

  it "should load menu" do
    get "/"
    #last_response.should be_ok
    doc = Nokogiri::XML(last_response.body)
    doc.xpath("//Response/Dial").should_not be_nil
  end

  it "should load private menu" do
    get "/", {:From => ENV["CELL_NUMBER"]}
    doc = Nokogiri::XML(last_response.body)
    doc.xpath("//Response/Gather").first["action"].should == "/process-private-menu"
  end

  it "should recognize cell number" do
    app.recognized_number?(ENV["CELL_NUMBER"]).should be_true
  end

  it "should recognize VOIP number" do
    app.recognized_number?(ENV["VOIP_NUMBER"]).should be_true
  end

  it "should forward emails" do
    sms_body = "testing sms"
    post "/sms", {:Body => sms_body}
    doc = Nokogiri::XML(last_response.body)
    doc.xpath("//Response/Sms").first.content.should == sms_body
  end
end<commit_msg>Add test for dialing out<commit_after>ENV["RACK_ENV"] = "test"
require File.dirname(__FILE__) + "/../app"
require "rack/test"
require "nokogiri"

describe "Twilio" do
  include Rack::Test::Methods

  def app
    CopperNet.new!
  end

  it "should load menu" do
    get "/"
    #last_response.should be_ok
    doc = Nokogiri::XML(last_response.body)
    doc.xpath("//Response/Dial").should_not be_nil
  end

  it "should load private menu" do
    get "/", {:From => ENV["CELL_NUMBER"]}
    doc = Nokogiri::XML(last_response.body)
    doc.xpath("//Response/Gather").first["action"].should == "/process-private-menu"
  end

  it "should recognize cell number" do
    app.recognized_number?(ENV["CELL_NUMBER"]).should be_true
  end

  it "should recognize VOIP number" do
    app.recognized_number?(ENV["VOIP_NUMBER"]).should be_true
  end

  it "should forward emails" do
    sms_body = "testing sms"
    post "/sms", {:Body => sms_body}
    doc = Nokogiri::XML(last_response.body)
    doc.xpath("//Response/Sms").first.content.should == sms_body
  end

  it "should ask for dial out" do
    post "/process-private-menu", {:Digits => 2}
    doc = Nokogiri::XML(last_response.body)
    doc.xpath("//Response/Gather").first["action"].should == "/dial-out"
  end
end
{'fraction_non_alphanumeric': 0.14900086880973068, 'fraction_numerical': 0.0004344048653344917, 'mean_word_length': 3.6713995943204867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3663401', 'n_tokens_mistral': 835, 'n_tokens_neox': 808, 'n_words': 181}