snippets.rb 1.72 KB
Newer Older
Andrew8xx8's avatar
Andrew8xx8 committed
1
class SnippetsFeature < Spinach::FeatureSteps
2 3 4
  include SharedAuthentication
  include SharedPaths
  include SharedProject
Andrew8xx8's avatar
Andrew8xx8 committed
5
  include SharedSnippet
6 7 8 9 10 11 12 13 14 15

  Given 'I click link "Personal snippet one"' do
    click_link "Personal snippet one"
  end

  And 'I should not see "Personal snippet one" in snippets' do
    page.should_not have_content "Personal snippet one"
  end

  And 'I click link "Edit"' do
16
    within ".file-title" do
17 18 19 20 21
      click_link "Edit"
    end
  end

  And 'I click link "Destroy"' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
22
    click_link "Remove"
23 24 25 26 27 28 29 30
  end

  And 'I submit new snippet "Personal snippet three"' do
    fill_in "personal_snippet_title", :with => "Personal snippet three"
    fill_in "personal_snippet_file_name", :with => "my_snippet.rb"
    within('.file-editor') do
      find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
    end
31
    click_button "Create snippet"
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  end

  Then 'I should see snippet "Personal snippet three"' do
    page.should have_content "Personal snippet three"
    page.should have_content "Content of snippet three"
  end

  And 'I submit new title "Personal snippet new title"' do
    fill_in "personal_snippet_title", :with => "Personal snippet new title"
    click_button "Save"
  end

  Then 'I should see "Personal snippet new title"' do
    page.should have_content "Personal snippet new title"
  end

  And 'I uncheck "Private" checkbox' do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
49
    choose "Public"
50 51 52 53
    click_button "Save"
  end

  Then 'I should see "Personal snippet one" public' do
Andrew8xx8's avatar
Andrew8xx8 committed
54
    page.should have_no_xpath("//i[@class='public-snippet']")
55 56 57 58 59 60 61
  end

  And 'I visit snippet page "Personal snippet one"' do
    visit snippet_path(snippet)
  end

  def snippet
skv's avatar
skv committed
62
    @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one")
63 64
  end
end