<commit_before>require 'spec_helper'

describe "V&A SMS App" do

  def twilio_body_from(response)
    parsed_response_body = Nokogiri::XML(response.body)
    returned_text = parsed_response_body.xpath('//Response/Sms').text
  end

  it "responds to a number + letter with confirmation" do
    post 'vacant', :Body => "3456 A"
    twilio_body_from(response).should eq("Thanks! You have selected A - Demolish for property 3456. You can see responses and learn more at www.FeedbackApp.com.")
  end

  it "correctly deals with number-then-letter input" do
    pending "Implementation of number-then-letter logic"
    post '/vacant', Body: "3465"
    twilio_body_from(response).should eq("You have selected property 3456. To submit a response please text A for Demolish, B for Rehab, C for Other.")
    post '/vacant', Body: "A"
    twilio_body_from(response).should eq("Thanks! You have selected A - Demolish for property 3456.  You can see responses and learn more at www.FeedbackApp.com.") 
  end

end<commit_msg>Refactor tests with before block<commit_after>require 'spec_helper'

describe "V&A SMS App" do

  def twilio_body_from(response)
    parsed_response_body = Nokogiri::XML(response.body)
    returned_text = parsed_response_body.xpath('//Response/Sms').text
  end

  before(:all) do
    @property_number = "1234"
    @choice_code = "A"
    @choice_text = "Demolish"
    @success_message = "Thanks! You have selected #{@choice_code} - #{@choice_text} for property #{@property_number}. You can see responses and learn more at www.FeedbackApp.com."
  end

  it "responds to a number + letter with confirmation" do
    post 'vacant', :Body => "#{@property_number} #{@choice_code}"
    twilio_body_from(response).should eq(@success_message)
  end

  it "correctly deals with number-then-letter input" do
    pending "Implementation of number-then-letter logic"

    # Still need to refine language
    post '/vacant', Body: @property_number
    twilio_body_from(response).should eq("for Demolish for the property at 1234 56th Ave.  You can see responses and learn more at FeedbackApp.com/#{@prop_num}.")
    post '/vacant', Body: "A"
    twilio_body_from(response).should eq("Thanks! You have selected A - Demolish for property 3456.  You can see responses and learn more at www.FeedbackApp.com.") 
  end

end
{'fraction_non_alphanumeric': 0.10121107266435986, 'fraction_numerical': 0.014705882352941176, 'mean_word_length': 4.174496644295302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7569820', 'n_tokens_mistral': 757, 'n_tokens_neox': 714, 'n_words': 237}