Skip to content

Instantly share code, notes, and snippets.

@astery
Last active July 1, 2016 18:17
Show Gist options
  • Save astery/7961e88a108e7513a430094b25e0c628 to your computer and use it in GitHub Desktop.
Save astery/7961e88a108e7513a430094b25e0c628 to your computer and use it in GitHub Desktop.
Rails test example
rake test:integration
pasha:
mobile_number: 404040
class PbxTest < ActionDispatch::IntegrationTest
include JsonHelper
def setup
@pasha = passengers(:pasha)
@bus = teams(:bus)
end
test "generate ticket code for pasha and use it" do
post '/pbx/ticket_codes/generate', pasha_call_params
assert json_response['code']
assert json_response['registred'] == true
get "/tickets", pasha_call_params
assert_equal 1, json_response.count
assert json_response[0]['usable']
post "/tickets/use_available_or_buy_and_use", conductor_check_pasha_params
assert json_response['ok']
get "/tickets", pasha_call_params
assert_equal 1, json_response.count
get "/tickets/has_right_to_ride_in_team", conductor_check_pasha_params
assert_equal 1, json_response.count
end
def pasha_call_params
{
mobile_number: @pasha.mobile_number,
source: '101010'
}
end
end
bus:
id: 1
name: bus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment