Last active
July 1, 2016 18:17
-
-
Save astery/7961e88a108e7513a430094b25e0c628 to your computer and use it in GitHub Desktop.
Rails test example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake test:integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pasha: | |
mobile_number: 404040 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bus: | |
id: 1 | |
name: bus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment