Review All Gadget, Samsung Galaxy Note, Firmware/ Flash File, Auto Forward, Transfer from Note 7 to Computer/Mac, Transfer Data Contacts from HTC to Samsung, Chimera Tool Samsung

Jumat, 10 Januari 2014

Using Capybara and RSpec assertions in Page Objects

Using Capybara and RSpec assertions in Page Objects - do you know that every day there are new gadgets that are created, every gadget has its own way to use it, in blogs Review All Gadget we are reviewing gadgets from various brands ranging from spec, price and how to use the feature, now we are discussing iformasi that you are looking for Using Capybara and RSpec assertions in Page Objects this information we collect from many reliable sources so that complete for you. please see.

Articles : Using Capybara and RSpec assertions in Page Objects
full Link : Using Capybara and RSpec assertions in Page Objects

You can also see our article on:


    Using Capybara and RSpec assertions in Page Objects

    On my Rails project, I am using RSpec and Capybara to write functional tests.  I did not want to specify any HTML elements in my Capybara feature files, since that makes the feature files brittle to HTML / CSS changes. It also violates the DRY principle and basic code hygiene.

    So, I decided to refactor out my HTML centric Capybara code into separate Page Objects. If you are unfamiliar with Page Objects, then read the following:



    The Page Object pattern for encapsulating HTML centric DSL is a common pattern followed while writing UI level functional tests in ThoughtWorks.

    The problem I was facing when I refactored my code into Page objects was that I was unable to use the RSpec 'expect' syntax in Page Objects. Turns out all I had to do in my page objects was:

    include RSpec::Matchers

    Here is the full code from my project on Github.
    https://github.com/gsluthra/dakshina/tree/master/spec/features

    The appropriate feature files and page objects in a GIST:
    https://gist.github.com/gsluthra/8356015
    # Page Object
    class CapsuleCreateForm
    include Capybara::DSL
    def submit_form(capsule={})
    fill_in 'Title', :with => capsule[:title]
    fill_in 'Description', :with => capsule[:description]
    fill_in 'capsule_study_text', :with => capsule[:study_text]
    fill_in 'capsule_assignment_instructions', :with => capsule[:assignment_instructions]
    fill_in 'capsule_guidelines_for_evaluators', :with => capsule[:guidelines_for_evaluators]
    click_button 'Save Capsule'
    end
    end
    require 'spec_helper'
    #Feature File
    feature 'Capsules Feature' do
    let(:capsuleHash) { attributes_for(:tdd_capsule) }
    let(:capsuleForm) { CapsuleCreateForm.new }
    let(:capsuleViewPage) { CapsuleViewPage.new }
    scenario 'Add a new capsule and displays the capsule in view mode' do
    visit '/capsules/new'
    expect {
    capsuleForm.submit_form(capsuleHash)
    }.to change(Capsule, :count).by(1)
    capsuleViewPage.validate_on_page
    capsuleViewPage.validate_capsule_data(capsuleHash)
    end
    end
    require 'spec_helper'
    # Page Object
    class CapsuleViewPage
    include Capybara::DSL
    include RSpec::Matchers
    def validate_on_page
    expect(page).to have_selector('#capsule-title-page')
    expect(page).to have_link('Edit')
    end
    def validate_capsule_data (capsule={})
    expect(page).to have_content capsule[:title]
    expect(page).to have_content capsule[:description]
    expect(page).to have_content capsule[:study_text]
    expect(page).to have_content capsule[:assignment_instructions]
    expect(page).to have_content capsule[:guidelines_for_evaluators]
    end
    end



    information Using Capybara and RSpec assertions in Page Objects has been discussed

    hopefully the information we provide with title Using Capybara and RSpec assertions in Page Objects can provide more benefits for you.

    well this information Using Capybara and RSpec assertions in Page Objects we have finished, if you intend to bookmark or sharenya can use link https://almourasiloun2.blogspot.com/2014/01/using-capybara-and-rspec-assertions-in.html.

    Tag :
    Share on Facebook
    Share on Twitter
    Share on Google+
    Tags :

    Related : Using Capybara and RSpec assertions in Page Objects

      0 komentar:

      Posting Komentar