spec/resources/phax_code_spec.rb in phaxio-2.1.0.pre vs spec/resources/phax_code_spec.rb in phaxio-2.1.0

- old
+ new

@@ -3,17 +3,11 @@ RSpec.describe PhaxCode do describe 'creating a phax code' do let(:action) { PhaxCode.create params } let(:params) { {metadata: 'This is a test PhaxCode'} } - context 'default type' do - around do |example| - VCR.use_cassette('resources/phax_code/create') do - example.run - end - end - + context 'default type', vcr: 'phax_code/create' do it 'makes the request to phaxio' do expect_api_request :post, 'phax_codes', params action end @@ -21,19 +15,13 @@ result = action expect(result).to be_a(PhaxCode) end end - context 'type is specified to be png' do + context 'type is specified to be png', vcr: 'phax_code/create_png' do let(:params) { {metadata: 'This is a test PhaxCode', type: 'png'} } - around do |example| - VCR.use_cassette('resources/phax_code/create_png') do - example.run - end - end - it 'returns a png if type is specified to be png' do result = action expect(result).to be_a(File) end end @@ -41,17 +29,11 @@ describe 'getting a phax code' do let(:action) { PhaxCode.get params } let(:params) { {} } - context 'default' do - around do |example| - VCR.use_cassette('resources/phax_code/get') do - example.run - end - end - + context 'default', vcr: 'phax_code/get_default' do it 'makes the request to Phaxio' do expect_api_request :get, 'phax_code', params action end @@ -61,47 +43,31 @@ expect(result).to be_a(PhaxCode) end end end - context 'getting the default phax code with png type specified' do + context 'getting the default phax code with png type specified', vcr: 'phax_code/get_default_png' do let(:params) { {type: 'png'} } - around do |example| - VCR.use_cassette('resources/phax_code/get_png') do - example.run - end - end - it 'returns a file' do result = action expect(result).to be_a(File) end end - context 'getting a particular phax code with no type specified' do - let(:params) { {identifier: '-Y3jxX'} } + context 'getting a particular phax code with no type specified', vcr: 'phax_code/get_by_id' do + let(:params) { {identifier: phax_code_identifier} } + let(:phax_code_identifier) { PhaxCode.create(metadata: 'Test Phax Code').identifier } - around do |example| - VCR.use_cassette('resources/phax_code/get_id') do - example.run - end - end - it 'returns a PhaxCode instance' do result = action expect(result).to be_a(PhaxCode) end end - context 'getting a particular phax code with png type specified' do - let(:params) { {identifier: '-Y3jxX', type: 'png'} } - - around do |example| - VCR.use_cassette('resources/phax_code/get_id_png') do - example.run - end - end + context 'getting a particular phax code with png type specified', vcr: 'phax_code/get_png_by_id' do + let(:params) { {identifier: phax_code_identifier, type: 'png'} } + let(:phax_code_identifier) { PhaxCode.create(metadata: 'Test Phax Code').identifier } it 'returns a file' do result = action expect(result).to be_a(File) end