How about:

    Given I attach :attachment with:
      """
      :url => "/system/:attachment/:style/:filename"
      """

With this step definition:

    Given 'I attach :attachment_name with:' do |attachment_name, options|
      snippet = ''
      if must_expose_attachment?
        snippet = <<-HERE
          attr_accessible :name, :#{attachment_name}
        HERE
      end
      snippet += <<-HERE
        has_attached_file :#{attachment_name}, #{options}
      HERE
    
      file_name = "app/models/user.rb"
      in_current_dir do
        content = File.read(file_name)
        File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
      end
    end
    
    def must_expose_attachment?
      Rails::VERSION::MAJOR < 4
    end

The big ideas: abstract out the step even more, move the conditional
into Ruby, name the conditional.