Cucumber tests that uses VCR requests

Cucumber tests that uses VCR requests

The following is my code in cucumber:

myfeature.feature


  Scenario: As an user I should see my posts type video
    Given A video posts list is created
    Then I should see a list of '8' posts from Tumblr

and now your step definitions with the following content:

  When(/^I visit the blog page$/) do
    visit '/blog' # or your blog_path
  end
  Given(/^A video posts list is created$/) do
    VCR.use_cassette 'video_posts_list' do
      step 'I visit the blog page'
    end
  end

BTW if you have the following error take a look into your response maybe you had and params that change

An HTTP request has been made that VCR does not know how to handle:
 GET http://api.tumblr.com/v2/blog/mytumblraccount.com/posts?api_key=TUMBLR_CONSUMER&limit=8&offset=16
 VCR is currently using the following cassette:
   - /home/myaccount/.cruise/projects/myproject/work/features/cassettes/video_posts_list.yml
   - :record => :once
   - :match_requests_on => [:method]
No Comments

Post A Comment