module RailsGwt::DSL
Public Instance Methods
dump_page()
click to toggle source
# File lib/rails_gwt/dsl.rb, line 54 def dump_page puts page.html.gsub(/></, ">\n<") end
login_session(username, use_last_pwd = false) { || ... }
click to toggle source
# File lib/rails_gwt/dsl.rb, line 25 def login_session(username, use_last_pwd = false) puts "login user: '#{username}'" if use_last_pwd line = File.read('log/test.log').gsub(/\r/, '').split("\n").grep(/new password :/).last pwd = line.gsub(/.*new password : (.*)/ , '\1') if line end if pwd.blank? fill_in 'username', :with => username click_on('password reset') page.should have_content('new password was sent to your email address') pwd = File.read('log/test.log').gsub(/\r/, '').split("\n").grep(/new password :/).last.gsub(/.*new password : (.*)/ , '\1') end fill_in 'login', :with => username fill_in 'password', :with => pwd click_on('login') should_have_no_loading yield click_on('logout') page.should have_content('password reset') end
should_have_model_display()
click to toggle source
# File lib/rails_gwt/dsl.rb, line 82 def should_have_model_display find(:xpath, "//div[@class='gwt-rails-model' and not(@style='display: none;')]") end
should_have_model_list_display()
click to toggle source
# File lib/rails_gwt/dsl.rb, line 78 def should_have_model_list_display find(:xpath, "//div[@class='gwt-rails-model-list' and not(table/@style='display: none;')]") end
should_have_no_loading()
click to toggle source
# File lib/rails_gwt/dsl.rb, line 50 def should_have_no_loading page.should have_xpath('//div[@class = "gwt-rails-loading" and @style = "display: none;"]') end
should_have_no_model_display()
click to toggle source
# File lib/rails_gwt/dsl.rb, line 74 def should_have_no_model_display find(:xpath, "//div[@class='gwt-rails-model' and @style='display: none;']") end
should_have_no_model_list_display()
click to toggle source
# File lib/rails_gwt/dsl.rb, line 86 def should_have_no_model_list_display find(:xpath, "//div[@class='gwt-rails-model-list' and table/@style='display: none;']") end
visit_resource(config, &block)
click to toggle source
# File lib/rails_gwt/dsl.rb, line 156 def visit_resource(config, &block) puts "----- resource: '#{config.resource}'" page.should have_content("Welcome #{config.name}") page.should have_content('logout') should_have_menu_items(config.menu) config.action = :new if config.action within_page("/Users.html##{config.resource}/new", config.mode) do should_have_action_buttons(config.action_buttons) should_have_buttons(config.buttons) end end config.action = :edit if config.action id = config.mode == :singleton ? '' : "/#{config.resource_id}" within_page("/Users.html##{config.resource}#{id}/edit", config.mode) do should_have_action_buttons(config.action_buttons) should_have_buttons(config.buttons) end end config.action = :show if config.action id = config.mode == :singleton ? '' : "/#{config.resource_id}" within_page("/Users.html##{config.resource}#{id}", config.mode) do should_have_action_buttons(config.action_buttons) should_have_buttons(config.buttons) end end config.action = :index if config.action within_page("/Users.html##{config.resource}", :index) do should_have_action_buttons(config.action_buttons) should_have_buttons(config.buttons) end # list config.content.each do |item| page.should have_content(item) end # no user list after search # fill_in 'search', :with => 'pipapo' # page.should have_no_content('root@example.com') end block.call(config) if block end
within_page(path, mode = :page, &block)
click to toggle source
# File lib/rails_gwt/dsl.rb, line 98 def within_page(path, mode = :page, &block) puts "visit page: #{path}" visit "#{path}" should_have_no_loading case mode when :index should_have_no_model_display should_have_model_list_display when :page should_have_model_display should_have_no_model_list_display when :singleton should_have_model_display end block.call if block end