diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-01 21:01:37 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-01 21:01:37 -0700 |
| commit | cf11fac246c680b970280142d2127c86592da833 (patch) | |
| tree | cdd3882a62628d38bd23a0aeef3cea4224658439 /spec | |
| parent | e59f15cc9682380a1844e332b4854d287e579c5a (diff) | |
move page objects.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/features/sessions_spec.rb | 37 | ||||
| -rw-r--r-- | spec/support/pages/login_page.rb | 15 | ||||
| -rw-r--r-- | spec/support/web_page.rb | 18 |
3 files changed, 35 insertions, 35 deletions
diff --git a/spec/features/sessions_spec.rb b/spec/features/sessions_spec.rb index dfd236dc..82690920 100644 --- a/spec/features/sessions_spec.rb +++ b/spec/features/sessions_spec.rb @@ -1,38 +1,5 @@ require 'rails_helper' -class WebPage - include Capybara::DSL - include Rails.application.routes.url_helpers - attr_reader :page_path - - def initialize(page_path) - @page_path = page_path - end - - def visit_page - visit page_path - self - end - - def on_page? - current_path == page_path - end -end - -class LoginPage < WebPage - def initialize - super(new_session_path) - end - - def login_with(email:, password: 'password') - within('.form-inline') do - fill_in('session_username', with: email) - fill_in('session_password', with: password) - end - click_button("Sign In") - end -end - describe "Logins" do describe "GET /login" do subject { LoginPage.new } @@ -41,7 +8,7 @@ describe "Logins" do subject.visit_page end - context "when an email is registered", js: true do + context "when an email is registered" do let!(:user) { create(:user, password: "password") } before :each do @@ -57,7 +24,7 @@ describe "Logins" do end end - context "when an email is not known", js: true do + context "when an email is not known" do before :each do subject.login_with(email: 'test@example.com', password: 'password') end diff --git a/spec/support/pages/login_page.rb b/spec/support/pages/login_page.rb new file mode 100644 index 00000000..7e2e7542 --- /dev/null +++ b/spec/support/pages/login_page.rb @@ -0,0 +1,15 @@ +require_relative '../web_page.rb' + +class LoginPage < WebPage + def initialize + super(new_session_path) + end + + def login_with(email:, password: 'password') + within('.form-inline') do + fill_in('session_username', with: email) + fill_in('session_password', with: password) + end + click_button("Sign In") + end +end diff --git a/spec/support/web_page.rb b/spec/support/web_page.rb new file mode 100644 index 00000000..4144c866 --- /dev/null +++ b/spec/support/web_page.rb @@ -0,0 +1,18 @@ +class WebPage + include Capybara::DSL + include Rails.application.routes.url_helpers + attr_reader :page_path + + def initialize(page_path) + @page_path = page_path + end + + def visit_page + visit page_path + self + end + + def on_page? + current_path == page_path + end +end |
