Hey,
I'm a ruby beginner and I have a problem to keep my tests clean.
My Code:
require 'spec_helper'
>
>
>> describe "Static pages" do
>
>
>> def checkContentOfPage(content, page)
>
> it "should have the content '"+content+"'" do
>
> visit '/static_pages/'+page
>
> expect(page).to have_content(title)
>
> end
>
> end
>
>
>> describe "Home page" do
>
>
>>
>
> checkContentOfPage('Sample App', 'home')
>
>
>> it "should have the title 'Home'" do
>
> visit '/static_pages/home'
>
> expect(page).to have_title("Ruby on Rails Tutorial Sample App |
>> Home")
>
> end
>
> end
>
>
>> describe "Help page" do
>
>
>> it "should have the content 'Help'" do
>
> visit '/static_pages/help'
>
> expect(page).to have_content('Help')
>
> end
>
>
>> it "should have the title 'Help'" do
>
> visit '/static_pages/help'
>
> expect(page).to have_title("Ruby on Rails Tutorial Sample App |
>> Help")
>
> end
>
> end
>
>
>> describe "About page" do
>
>
>> it "should have the content 'About Us'" do
>
> visit '/static_pages/about'
>
> expect(page).to have_content('About Us')
>
> end
>
>
>> it "should have the title 'About Us'" do
>
> visit '/static_pages/about'
>
> expect(page).to have_title("Ruby on Rails Tutorial Sample App |
>> About Us")
>
> end
>
> end
>
> end
>
>
I tried to create a method checkContentOfPage to reduce the have_content
and have_title redundancy. But it doesnt work...
Can you tell me how to keep my tests clean? It seems like java like
refactoring is not possible.
regards
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/d6de4f67-744c-4935-b630-f58acab0763a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.