From a066553406e5a4d79af4a3f1f65096a752f4c323 Mon Sep 17 00:00:00 2001 From: hajee Date: Wed, 4 Sep 2013 13:41:04 +0200 Subject: [PATCH] Updated to V1.0.3 Added support for accessing the capybara element of a record Signed-off-by: hajee --- CHANGES.md | 5 ++++- Gemfile.lock | 2 +- lib/page_record/base.rb | 15 +++++++++++++++ lib/page_record/version.rb | 2 +- spec/base_spec.rb | 17 +++++++++++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5aafd56..e90324a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -29,4 +29,7 @@ Released to production ##V1.0.2 * Added the id of the record to the inspector. -* inspecting uses the Array variant of Capybara and doesn't wait. \ No newline at end of file +* inspecting uses the Array variant of Capybara and doesn't wait. + +##V1.0.3 +* Added support for getting the Capybara element of a record.ait. diff --git a/Gemfile.lock b/Gemfile.lock index 10c8dff..e65c75c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - page_record (1.0.2) + page_record (1.0.3) activemodel activesupport capybara (~> 2.1.0) diff --git a/lib/page_record/base.rb b/lib/page_record/base.rb index 6453190..4cfc72a 100644 --- a/lib/page_record/base.rb +++ b/lib/page_record/base.rb @@ -17,6 +17,21 @@ def initialize(id = nil, selector = nil, filter = nil) find_record(selector, filter) end + ## + # Return the Capybara element containg the record + # + # Example: + # + # ```ruby + # team_1 = TeamPage.find(1) # Get the first team + # team_1.element? # access the Capybara context + # end + # ``` + # + def element? + @record + end + ## # Set's the default selector for this class # diff --git a/lib/page_record/version.rb b/lib/page_record/version.rb index a7c99f5..9ec3488 100644 --- a/lib/page_record/version.rb +++ b/lib/page_record/version.rb @@ -1,3 +1,3 @@ module PageRecord - VERSION = '1.0.2' + VERSION = '1.0.3' end diff --git a/spec/base_spec.rb b/spec/base_spec.rb index 94ebb30..513c001 100644 --- a/spec/base_spec.rb +++ b/spec/base_spec.rb @@ -207,6 +207,23 @@ class FunnyRecord < PageRecord::Base end + describe "record.element?" do + + subject { TeamPage.find().element? } + + context "record on the page" do + before do + visit '/page-one-record' + end + + it "returns the capybara element containing the record" do + expect(subject.class).to eq Capybara::Node::Element + end + + end + end + + describe "found bugs" do describe "class name contains word page but doens't exist" do