Best Rr_ruby code snippet using Project.within
form_spec.rb
Source:form_spec.rb
...29 })30 end31 it 'creates new merge request' do32 click_button 'Assignee'33 page.within '.dropdown-menu-user' do34 click_link user2.name35 end36 expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user2.id.to_s)37 page.within '.js-assignee-search' do38 expect(page).to have_content user2.name39 end40 click_link 'Assign to me'41 expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)42 page.within '.js-assignee-search' do43 expect(page).to have_content user.name44 end45 click_button 'Milestone'46 page.within '.issue-milestone' do47 click_link milestone.title48 end49 expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)50 page.within '.js-milestone-select' do51 expect(page).to have_content milestone.title52 end53 click_button 'Labels'54 page.within '.dropdown-menu-labels' do55 click_link label.title56 click_link label2.title57 end58 page.within '.js-label-select' do59 expect(page).to have_content label.title60 end61 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)62 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)63 click_button 'Submit merge request'64 page.within '.issuable-sidebar' do65 page.within '.assignee' do66 expect(page).to have_content user.name67 end68 page.within '.milestone' do69 expect(page).to have_content milestone.title70 end71 page.within '.labels' do72 expect(page).to have_content label.title73 expect(page).to have_content label2.title74 end75 end76 page.within '.issuable-meta' do77 merge_request = MergeRequest.find_by(source_branch: 'fix')78 expect(page).to have_text("Merge request #{merge_request.to_reference}")79 # compare paths because the host differ in test80 expect(find_link(merge_request.to_reference)[:href])81 .to end_with(merge_request_path(merge_request))82 end83 end84 end85 context 'edit merge request' do86 before do87 merge_request = create(:merge_request,88 source_project: project,89 target_project: project,90 source_branch: 'fix',91 target_branch: 'master'92 )93 visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request)94 end95 it 'updates merge request' do96 click_button 'Assignee'97 page.within '.dropdown-menu-user' do98 click_link user.name99 end100 expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)101 page.within '.js-assignee-search' do102 expect(page).to have_content user.name103 end104 click_button 'Milestone'105 page.within '.issue-milestone' do106 click_link milestone.title107 end108 expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)109 page.within '.js-milestone-select' do110 expect(page).to have_content milestone.title111 end112 click_button 'Labels'113 page.within '.dropdown-menu-labels' do114 click_link label.title115 click_link label2.title116 end117 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)118 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)119 page.within '.js-label-select' do120 expect(page).to have_content label.title121 end122 click_button 'Save changes'123 page.within '.issuable-sidebar' do124 page.within '.assignee' do125 expect(page).to have_content user.name126 end127 page.within '.milestone' do128 expect(page).to have_content milestone.title129 end130 page.within '.labels' do131 expect(page).to have_content label.title132 expect(page).to have_content label2.title133 end134 end135 end136 end137 end138 context 'forked project' do139 before do140 fork_project.team << [user, :master]141 login_as(user)142 end143 context 'new merge request' do144 before do145 visit new_namespace_project_merge_request_path(146 fork_project.namespace,147 fork_project,148 merge_request: {149 source_project_id: fork_project.id,150 target_project_id: project.id,151 source_branch: 'fix',152 target_branch: 'master'153 })154 end155 it 'creates new merge request' do156 click_button 'Assignee'157 page.within '.dropdown-menu-user' do158 click_link user.name159 end160 expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)161 page.within '.js-assignee-search' do162 expect(page).to have_content user.name163 end164 click_button 'Milestone'165 page.within '.issue-milestone' do166 click_link milestone.title167 end168 expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)169 page.within '.js-milestone-select' do170 expect(page).to have_content milestone.title171 end172 click_button 'Labels'173 page.within '.dropdown-menu-labels' do174 click_link label.title175 click_link label2.title176 end177 page.within '.js-label-select' do178 expect(page).to have_content label.title179 end180 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)181 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)182 click_button 'Submit merge request'183 page.within '.issuable-sidebar' do184 page.within '.assignee' do185 expect(page).to have_content user.name186 end187 page.within '.milestone' do188 expect(page).to have_content milestone.title189 end190 page.within '.labels' do191 expect(page).to have_content label.title192 expect(page).to have_content label2.title193 end194 end195 end196 end197 context 'edit merge request' do198 before do199 merge_request = create(:merge_request,200 source_project: fork_project,201 target_project: project,202 source_branch: 'fix',203 target_branch: 'master'204 )205 visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request)206 end207 it 'should update merge request' do208 click_button 'Assignee'209 page.within '.dropdown-menu-user' do210 click_link user.name211 end212 expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)213 page.within '.js-assignee-search' do214 expect(page).to have_content user.name215 end216 click_button 'Milestone'217 page.within '.issue-milestone' do218 click_link milestone.title219 end220 expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)221 page.within '.js-milestone-select' do222 expect(page).to have_content milestone.title223 end224 click_button 'Labels'225 page.within '.dropdown-menu-labels' do226 click_link label.title227 click_link label2.title228 end229 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)230 expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)231 page.within '.js-label-select' do232 expect(page).to have_content label.title233 end234 click_button 'Save changes'235 page.within '.issuable-sidebar' do236 page.within '.assignee' do237 expect(page).to have_content user.name238 end239 page.within '.milestone' do240 expect(page).to have_content milestone.title241 end242 page.within '.labels' do243 expect(page).to have_content label.title244 expect(page).to have_content label2.title245 end246 end247 end248 end249 end250end...
sidebar_spec.rb
Source:sidebar_spec.rb
...40 expect(page).not_to have_selector('.issue-boards-sidebar')41 end42 it 'shows issue details when sidebar is open' do43 click_card(card)44 page.within('.issue-boards-sidebar') do45 expect(page).to have_content(issue2.title)46 expect(page).to have_content(issue2.to_reference)47 end48 end49 it 'removes card from board when clicking ' do50 click_card(card)51 page.within('.issue-boards-sidebar') do52 click_button 'Remove from board'53 end54 wait_for_requests55 page.within(first('.board')) do56 expect(page).to have_selector('.card', count: 1)57 end58 end59 context 'assignee' do60 it 'updates the issues assignee' do61 click_card(card)62 page.within('.assignee') do63 click_link 'Edit'64 wait_for_requests65 page.within('.dropdown-menu-user') do66 click_link user.name67 wait_for_requests68 end69 expect(page).to have_content(user.name)70 end71 expect(card).to have_selector('.avatar')72 end73 it 'removes the assignee' do74 card_two = first('.board').find('.card:nth-child(2)')75 click_card(card_two)76 page.within('.assignee') do77 click_link 'Edit'78 wait_for_requests79 page.within('.dropdown-menu-user') do80 click_link 'Unassigned'81 end82 wait_for_requests83 expect(page).to have_content('No assignee')84 end85 expect(card_two).not_to have_selector('.avatar')86 end87 it 'assignees to current user' do88 click_card(card)89 page.within(find('.assignee')) do90 expect(page).to have_content('No assignee')91 click_button 'assign yourself'92 wait_for_requests93 expect(page).to have_content(user.name)94 end95 expect(card).to have_selector('.avatar')96 end97 it 'updates assignee dropdown' do98 click_card(card)99 page.within('.assignee') do100 click_link 'Edit'101 wait_for_requests102 page.within('.dropdown-menu-user') do103 click_link user.name104 wait_for_requests105 end106 expect(page).to have_content(user.name)107 end108 page.within(first('.board')) do109 find('.card:nth-child(2)').trigger('click')110 end111 page.within('.assignee') do112 click_link 'Edit'113 expect(find('.dropdown-menu')).to have_selector('.is-active')114 end115 end116 end117 context 'milestone' do118 it 'adds a milestone' do119 click_card(card)120 page.within('.milestone') do121 click_link 'Edit'122 wait_for_requests123 click_link milestone.title124 wait_for_requests125 page.within('.value') do126 expect(page).to have_content(milestone.title)127 end128 end129 end130 it 'removes a milestone' do131 click_card(card)132 page.within('.milestone') do133 click_link 'Edit'134 wait_for_requests135 click_link "No Milestone"136 wait_for_requests137 page.within('.value') do138 expect(page).not_to have_content(milestone.title)139 end140 end141 end142 end143 context 'due date' do144 it 'updates due date' do145 click_card(card)146 page.within('.due_date') do147 click_link 'Edit'148 click_button Date.today.day149 wait_for_requests150 expect(page).to have_content(Date.today.to_s(:medium))151 end152 end153 end154 context 'labels' do155 it 'adds a single label' do156 click_card(card)157 page.within('.labels') do158 click_link 'Edit'159 wait_for_requests160 click_link bug.title161 wait_for_requests162 find('.dropdown-menu-close-icon').click163 page.within('.value') do164 expect(page).to have_selector('.label', count: 3)165 expect(page).to have_content(bug.title)166 end167 end168 expect(card).to have_selector('.label', count: 2)169 expect(card).to have_content(bug.title)170 end171 it 'adds a multiple labels' do172 click_card(card)173 page.within('.labels') do174 click_link 'Edit'175 wait_for_requests176 click_link bug.title177 click_link regression.title178 wait_for_requests179 find('.dropdown-menu-close-icon').click180 page.within('.value') do181 expect(page).to have_selector('.label', count: 4)182 expect(page).to have_content(bug.title)183 expect(page).to have_content(regression.title)184 end185 end186 expect(card).to have_selector('.label', count: 3)187 expect(card).to have_content(bug.title)188 expect(card).to have_content(regression.title)189 end190 it 'removes a label' do191 click_card(card)192 page.within('.labels') do193 click_link 'Edit'194 wait_for_requests195 click_link stretch.title196 wait_for_requests197 find('.dropdown-menu-close-icon').click198 page.within('.value') do199 expect(page).to have_selector('.label', count: 1)200 expect(page).not_to have_content(stretch.title)201 end202 end203 expect(card).not_to have_selector('.label')204 expect(card).not_to have_content(stretch.title)205 end206 end207 context 'subscription' do208 it 'changes issue subscription' do209 click_card(card)210 page.within('.subscription') do211 click_button 'Subscribe'212 wait_for_requests213 expect(page).to have_content("Unsubscribe")214 end215 end216 end217 def click_card(card)218 page.within(card) do219 first('.card-number').click220 end221 wait_for_sidebar222 end223 def wait_for_sidebar224 # loop until the CSS transition is complete225 Timeout.timeout(0.5) do226 loop until evaluate_script('$(".right-sidebar").outerWidth()') == 290227 end228 end229end...
within
Using AI Code Generation
1 def initialize(name, description)2 def name=(new_name)3 def description=(new_description)4 def initialize(name, description)5 def name=(new_name)6 def description=(new_description)7 def initialize(name, description)8 def initialize(name, description)
within
Using AI Code Generation
1def add_tasks(task)2def add_tasks(task)3def add_tasks(task)4def add_tasks(task)5def add_tasks(task)
within
Using AI Code Generation
1 Find.find(self.dir) do |path|2 all_files << path if FileTest.file?(path)3 Find.find(self.dir) do |path|4 all_files << path if FileTest.file?(path)5 Find.find(self.dir) do |path|6 all_files << path if FileTest.file?(path)7 Find.find(self.dir) do |path|8 all_files << path if FileTest.file?(path)9 Find.find(self.dir) do |path|10 all_files << path if FileTest.file?(path)11 Find.find(self.dir) do |path|12 all_files << path if FileTest.file?(path)13 Find.find(self.dir) do |
within
Using AI Code Generation
1 @project_name = File.basename(Dir.pwd)2 Dir.mkdir(@project_directory)3 Dir.mkdir(@project_directory + "/data")4 File.new(@project_directory + "/data/data.txt", "w")5 File.new(@project_directory + "/log.txt", "w")6 File.new(@project_directory + "/config.txt", "w")7 Dir.mkdir(@project_directory + "/
within
Using AI Code Generation
1 @team.delete(@name)2def add_to_team(name)3def remove_from_team(name)4 @team.delete(name)5def add_to_team(name)6def remove_from_team(name)7 @team.delete(name)8def add_to_team(name)9def remove_from_team(name)10 @team.delete(name)11def add_to_team(name)12def remove_from_team(name)13 @team.delete(name)14def add_to_team(name)15def remove_from_team(name)16 @team.delete(name)17def add_to_team(name)18def remove_from_team(name)19 @team.delete(name)20def add_to_team(name)21def remove_from_team(name)22 @team.delete(name)23def add_to_team(name)24def remove_from_team(name)25 @team.delete(name)26def add_to_team(name)
within
Using AI Code Generation
1 def initialize(name, description)2 def name=(new_name)3 def description=(new_description)4 def initialize(name, description)5 def name=(new_name)6 def description=(new_description)7 def initialize(name, description)8 def initialize(name, description)
within
Using AI Code Generation
1def add_tasks(task)2def add_tasks(task)3def add_tasks(task)4def add_tasks(task)5def add_tasks(task)
within
Using AI Code Generation
1 @project_name = File.basename(Dir.pwd)2 Dir.mkdir(@project_directory)3 Dir.mkdir(@project_directory + "/data")4 File.new(@project_directory + "/data/data.txt", "w")5 File.new(@project_directory + "/log.txt", "w")6 File.new(@project_directory + "/config.txt", "w")7 Dir.mkdir(@project_directory + "/
within
Using AI Code Generation
1 def initialize(name, description)2 def name=(new_name)3 def description=(new_description)4 def initialize(name, description)5 def name=(new_name)6 def description=(new_description)7 def initialize(name, description)8 def initialize(name, description)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!