Skip to content

Instantly share code, notes, and snippets.

@braidn
Created October 29, 2014 13:50
Show Gist options
  • Save braidn/9602af3260c474cfa680 to your computer and use it in GitHub Desktop.
Save braidn/9602af3260c474cfa680 to your computer and use it in GitHub Desktop.
require 'ruby-jmeter'
require 'ffaker'
test do
threads 1, {continue_forever: false} do
defaults domain: URI('https://staging2.thereformation.com').host
cookies policy: 'rfc2109'
http_header_manager name: 'Accepts', value: 'application/json, text/javascript, text/html, */*'
visit name: 'Index', url: '/' do
extract name: 'csrf-token', xpath: "//meta[@name='csrf-token']/@content", tolerant: true
extract name: 'csrf-param', xpath: "//meta[@name='csrf-param']/@content", tolerant: true
end
http_header_manager name: 'X-CSRF-Token', value: '${csrf-token}'
post name: 'Create User', url: '/signup',
raw_body: { user: { email: Faker::Internet.email, password: 'godynamo12345',
password_confirmation: 'godynamo12345' } }.to_json do
with_xhr
extract name: 'user_id', regex: '"id":(\d+)'
end
exists 'user_id' do
post name: 'Add To Cart', url: '/cart',
raw_body: {order: { variant_id: 7516, quantity: 1, user_id: '${user_id}' }}.to_json do
with_xhr
extract name: 'order_number', regex: '"number":"(R\d+)"'
extract name: 'order_token', regex: '"token":"([a-zA-Z0-9]+)"'
end
exists 'order_number' do
put name: 'Advance To Address', url: '/api/checkouts/${order_number}?order_token=${order_token}',
raw_body: {order: { ship_address_id: 35273 }}.to_json do
with_xhr
end
put name: 'Advance To Shipping Rate', url: '/api/checkouts/${order_number}?order_token=${order_token}',
raw_body: {order: {shipments_attributes: {selected_shipping_rate_id: 47896, id: 27432}}}.to_json do
with_xhr
end
put name: 'Advance To Payments', url: '/api/checkouts/${order_number}?order_token=${order_token}',
raw_body: {order: {payment_attributes: [{payment_method_id: 35, source_attributes: {month: 04,
year: 2016, name: 'bra bra', number: 5555555555554444, verification_value: 123,
cc_type: 'mastercard', address_id: 35275}}]}}.to_json do
with_xhr
end
put name: 'Advance To Complete', url: '/api/checkouts/${order_number}?order_token=${order_token}' do
with_xhr
end
end
end
end
end.grid('hA7mBow_Xv7_wm5C_qCp') #running on a free flood.io grid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment